Open drelaptop opened 5 years ago
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!
@flykule Thank you for commenting! I am going to try this out.
@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")
@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.
@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)
@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.
@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
It solve by rollback gcc version and g++ version ,reference the file cocos2d-x-3.17.1/build/install-deps-linux.sh
, in the end:
........
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 60
echo "Cocos uses GCC Version: `gcc --version`"
echo "Cocos uses G++ Version: `g++ --version`"
echo "Cocos uses ld Version: `ld --version`"
echo "Cocos uses /usr/bin/ld Version: `/usr/bin/ld --version`"
the "-fPIC" error occur because gcc\g++ version too new (ubuntu17 or 18) , may be cocos2d-x should update gcc version
i think we can use ubuntu 18 for next the testing version
That would be fantastic, @minggo! I just started learning Cocos and this was a pain point.
Just to share another [easier] solution for 3.17.1 (Ubuntu 18.04 LTS / LinuxMint 19.1): I just created a symlink to avoid editing my shared CMake build's link.txt.
$ cd ~/cocos2d-x/external/freetype2/prebuilt/linux/64-bit
$ mv libfreetype.a libfreetype.a.bak
$ ln -s /usr/lib/x86_64-linux-gnu/libfreetype.a
(Edit) Note: The package libfreetype6-dev must be installed.
I just had a similar issue with libfmod:
/usr/bin/ld: ../../cocos2d/external/linux-specific/fmod/prebuilt/64-bit/libfmod.so: .dynsym local symbol at index 2 (>= sh_info of 2)
How can I solve it?
Can you improve the documentation for cocos2dx installation in Linux? It’s best not to set the operating system dependency. but I can’t see it in the documentation. I use kubuntu 20.04
compile errors like: