You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build cocos2d-x as a shared library on Linux with BUILD_SHARED_LIBS:BOOL=ON fails with "libfreetype.a(ftbase.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC"
#18399
Open
cirosantilli opened this issue
Oct 23, 2017
· 2 comments
cmake -DBUILD_SHARED_LIBS:BOOL=ON && make
(Using gcc 6.3 from my distro)
Outcome: link fails with:
/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 shared object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libcurl.so: undefined reference to symbol 'inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libz.so: error adding symbols: DSO missing from command line
which ends up looking for my system's shared library, which cannot be used for a shared link .
I also don't understand the error because: readelf says that the /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libz.so on my system does have inflateEnd.
I then copy pasted the failing linker command, and replaced all -lz entries with the full path to the built libz.a and the link now works, and cpp-tests runs!
However, even after the link works, I sill have the following conerns:
the executable 2x larger rather than smaller!
the library is called libcocos2dInternal.so, should be just libcocos2d.so. libcocos2d.so does exist but is much smaller, not sure what it is for.
The text was updated successfully, but these errors were encountered:
cirosantilli
changed the title
Build cocos as a shared library on Linux with BUILD_SHARED_LIBS:BOOL=ON fails with "libfreetype.a(ftbase.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC"
Build cocos2d-x as a shared library on Linux with BUILD_SHARED_LIBS:BOOL=ON fails with "libfreetype.a(ftbase.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC"
Oct 23, 2017
Any progress on this yet? Right now I'm using v3.13.1 for building on Linux and v3.16 for iOS, due to all previous versions apparently being deprecated due to a system-call which does not exist in iOS 11 anymore.
Why I want to do this:
Specs:
trunk
Steps to Reproduce:
cmake -DBUILD_SHARED_LIBS:BOOL=ON && make
(Using gcc 6.3 from my distro)
Outcome: link fails with:
However, freetype is already compiled with
-fPIC
if you compile it yourself, https://github.com/cocos2d/cocos2d-x-3rd-party-libs-src/blob/d020d9ef98dea233992802d151afdbbbff3acd8e/contrib/src/main.mak#L288 so I think it is about having the prebuilt binary built with an old GCC? So I just compile it myself with:and copy into the prebuilts and it works.
Next, the link fails with:
libz.a
gets built together with freetype:linux/z/prebuilt/x86_64/libz.a
, which uses libz functions, however for some reason it is not present in the binaries https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin/tree/8d1bf3e7199948755c98a36a59bf15c50943e27e andmake VERBOSE=1
says it is not used during link, only:which ends up looking for my system's shared library, which cannot be used for a shared link .
I also don't understand the error because:
readelf
says that the/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libz.so
on my system does haveinflateEnd
.I then copy pasted the failing linker command, and replaced all
-lz
entries with the full path to the builtlibz.a
and the link now works, andcpp-tests
runs!However, even after the link works, I sill have the following conerns:
libcocos2dInternal.so
, should be justlibcocos2d.so
.libcocos2d.so
does exist but is much smaller, not sure what it is for.The text was updated successfully, but these errors were encountered: