New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cocos2d-x compile broken on Ubuntu 17、18 #19246

Open
drelaptop opened this Issue Dec 14, 2018 · 7 comments

Comments

Projects
None yet
5 participants
@drelaptop
Copy link
Collaborator

drelaptop commented Dec 14, 2018

  • cocos2d-x version: 3.17, 3.17.1
  • devices test on: ubuntu 17, 18

compile errors like:

usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftbase.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftinit.linux64.o): relocation R_X86_64_32 against symbol `tt_driver_class' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftsystem.linux64.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(sfnt.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(psaux.linux64.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(psnames.linux64.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(pfr.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(truetype.linux64.o): relocation R_X86_64_32 against `.text' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(winfnt.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(type1.linux64.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(type42.linux64.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(cff.linux64.o): relocation R_X86_64_32 against `.text' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(type1cid.linux64.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(bdf.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(pcf.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftf.linux64.o): relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(smooth.linux64.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(raster.linux64.o): relocation R_X86_64_32S against symbol `ft_raster1_renderer_class' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(autofit.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(pshinter.linux64.o): relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftglyph.linux64.o): relocation R_X86_64_32S against symbol `ft_bitmap_glyph_class' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftstroke.linux64.o): relocation R_X86_64_32S against symbol `ft_outline_glyph_class' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftgzip.linux64.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftlzw.linux64.o): relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../../../../external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftbitmap.linux64.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
engine/tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/build.make:185: recipe for target 'bin/Debug/cpp-empty-test/cpp-empty-test' failed
make[2]: *** [bin/Debug/cpp-empty-test/cpp-empty-test] Error 1
CMakeFiles/Makefile2:1445: recipe for target 'engine/tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/all' failed
make[1]: *** [engine/tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

@drelaptop drelaptop added this to the next milestone Dec 14, 2018

@drelaptop drelaptop changed the title cocos2d-x compile broken on ubuntu 17 or 18 cocos2d-x compile broken on ubuntu 17、18 Dec 14, 2018

@drelaptop drelaptop changed the title cocos2d-x compile broken on ubuntu 17、18 cocos2d-x compile broken on Ubuntu 17、18 Dec 14, 2018

@flykule

This comment has been minimized.

Copy link

flykule commented Dec 20, 2018

Hi, you can add " set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie -fno-exceptions -std=c++11 -Wno-deprecated-declarations -Wno-reorder") " to CMakeList below line 70.It worked for me!

@slackmoehrle

This comment has been minimized.

Copy link
Contributor

slackmoehrle commented Dec 21, 2018

@flykule Thank you for commenting! I am going to try this out.

@slackmoehrle

This comment has been minimized.

Copy link
Contributor

slackmoehrle commented Dec 21, 2018

@flykule Thank you so much!

I have to modify a bit to:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie -fexceptions -std=c++11 -Wno-deprecated-declarations -Wno-reorder")
@playmyskay

This comment has been minimized.

Copy link

playmyskay commented Dec 21, 2018

@flykule Thank you so much!

I have to modify a bit to:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie -fexceptions -std=c++11 -Wno-deprecated-declarations -Wno-reorder")

Compiling with -no-pie option just for one library (freetype2) sounds a little bit strange. In my opinion the prebuilt of libfreetype.a should be compiled with -fPIC option, or i am wrong?

Sorry, i am not a compiler/linker expert.

If you remove the dependency to libfreetype.a (i.e. in link.txt) you are able to successfully link everything with a clean/new project.

I compiled and linked the libfreetype.a by myself and replaced it with the prebuilt. Now it's linking.

@slackmoehrle

This comment has been minimized.

Copy link
Contributor

slackmoehrle commented Dec 21, 2018

@playmyskay Yeah, true perhaps.

I have tried a few things, so far and nothing works.

elseif(LINUX)
        #target_compile_options(${target} PUBLIC -fPIC)
        #target_compile_options(${target} PUBLIC -no-pie)
@playmyskay

This comment has been minimized.

Copy link

playmyskay commented Dec 21, 2018

@slackmoehrle

step1:
Compile the freetype library by yourself from: https://github.com/cocos2d/cocos2d-x-3rd-party-libs-src

./build.sh -p=linux --libs=freetype --arch=x86_64 --mode=release

output file: cocos2d-x-3rd-party-libs-src/build/linux/freetype/prebuilt/x86_64/libfreetype.a

step2:
Create or use an existing project and replace the file libfreetype.a with the output file of step1. Now link again and it works in my case.

file to replace: _YourProject_/cocos2d/external/freetype2/prebuilt/linux/64-bit/libfreetype.a

The file in repo 'https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin' must be replaced with a correct binary.

@leJTA

This comment has been minimized.

Copy link

leJTA commented Jan 7, 2019

@slackmoehrle

step1:
Compile the freetype library by yourself from: https://github.com/cocos2d/cocos2d-x-3rd-party-libs-src

./build.sh -p=linux --libs=freetype --arch=x86_64 --mode=release

output file: cocos2d-x-3rd-party-libs-src/build/linux/freetype/prebuilt/x86_64/libfreetype.a

step2:
Create or use an existing project and replace the file libfreetype.a with the output file of step1. Now link again and it works in my case.

file to replace: _YourProject_/cocos2d/external/freetype2/prebuilt/linux/64-bit/libfreetype.a

The file in repo 'https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin' must be replaced with a correct binary.

Thank you very much i had the same problem and it solved it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment