🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Compiler error in svn trunk on linux

Started by
3 comments, last by WitchLord 6 years, 2 months ago

Hi,

I tried compiling the latest trunk version (2481). With gcc on linux and I got this error (I'm using cmake):


Building CXX object CMakeFiles/angelscript.dir/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp.o
/usr/bin/c++  -D-fPIC -DANGELSCRIPT_EXPORT -D_LIB -I/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/projects/cmake/../../include  -O2 -g -DNDEBUG   -o CMakeFiles/angelscript.dir/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp.o -c /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp
<komentorivi>:0:1: virhe: makrojen nimien on oltava tunnisteita
make[2]: *** [CMakeFiles/angelscript.dir/build.make:63: CMakeFiles/angelscript.dir/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp.o] Virhe 1
make[2]: Poistutaan hakemistosta ”/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/build”
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/angelscript.dir/all] Virhe 2
make[1]: Poistutaan hakemistosta ”/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/build”
make: *** [Makefile:130: all] Virhe 2

The interesting part here is `-D-fPIC` which is the cause of the error. I was able to fix this by changing this configuration `target_compile_definitions(${ANGELSCRIPT_LIBRARY_NAME} PRIVATE -fPIC)` to this: `target_compile_options(${ANGELSCRIPT_LIBRARY_NAME} PRIVATE -fPIC)`. I changed the compile definition to be compile option which correctly no longer adds `-D` in front of `-fPIC`. I Also added a check to the if condition that contains that setting to include check for UNIX as I think as it currently is it won't work on windows (I also use cmake with angelscript on windows, but didn't test that yet).

I included a diff of the change.

patch.diff

Advertisement

I think -fPIC is gnuc specific. If gnuc (or better mingw) is used to compile on Windows the -fPIC option should be used too. 

But, as I do not use cmake myself I'll just take your word for it and check in the patch you provided.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I don't have experience with mingw on windows but I've used cygwin and (I just checked again from the documentation) that sets the UNIX flag in cmake. Not sure if a check for `NOT MSVC` would be better, then.

Yes, NOT MSVC is probably a safer bet.

However, I checked in your patch as-is in revision 2482. If you find any further problems let me know.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement