[CMake] Incorrectly adding "-l" flag to ".lib.a" files

Alejandro Pulver alepulver at gmail.com
Fri Jun 1 13:04:22 EDT 2012


Hello,

I'm using CMake 2.8.7 on Ubuntu 12.04 64-bit for cross-compiling with MinGW. The following link.txt is generated:

/usr/bin/cmake -E remove -f CMakeFiles/dhewm3.dir/objects.a
/usr/bin/i686-w64-mingw32-ar cr CMakeFiles/dhewm3.dir/objects.a @CMakeFiles/dhewm3.dir/objects1.rsp
/usr/bin/i686-w64-mingw32-g++  -DID_ENFORCE_KEY=0 -DNDEBUG -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer    -mwindows  -m32 -Wl,--whole-archive CMakeFiles/dhewm3.dir/objects.a -Wl,--no-whole-archive  -o dhewm3.exe -Wl,--out-implib,libdhewm3.dll.a -Wl,--major-image-version,0,--minor-image-version,0  libidlib.a -lopengl32 /home/ale/temp/dhewm3-libs/i686-w64-mingw32/lib/OpenAL32.lib -l../../dhewm3-libs/i686-w64-mingw32/lib/libogg.dll.a -l../../dhewm3-libs/i686-w64-mingw32/lib/libvorbisfile.dll.a -l../../dhewm3-libs/i686-w64-mingw32/lib/libvorbis.dll.a -l../../dhewm3-libs/i686-w64-mingw32/lib/libcurl.dll.a -l../../dhewm3-libs/i686-w64-mingw32/lib/libjpeg.dll.a -l../../dhewm3-libs/i686-w64-mingw32/lib/libSDL.dll.a -lwinmm -liphlpapi -lwsock32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32

Notice that library archive files such as libogg.dll.a have an incorrect "-l" option added, in contrast to "libdhewm3.dll.a" and "libidlib.a". That's why linking fails. If I remove the "-l" flags on those, then it builds and runs fine.

The CMakeLists.txt is at:
https://github.com/alepulver/dhewm3/blob/master/neo/CMakeLists.txt

I believe you can ignore the "mods" subdirectory, as well as GAME, D3XP, DEDICATED options for this issue. Only CORE is required. In the "sys/cmake" subdirectory there are CMake scripts to find Ogg, Vorbis and VorbisFile. There are build instructions in the parent folder in case you want to reproduce. 

Please note that configure fails when checking for "-fvisibility=hidden" availability (though it works fine when removing the check and adding the flag). I don't know if I should sent another mail for this one, or even how to get the compiler error log for the test program.

Thanks in advance,
Alejandro


More information about the CMake mailing list