Reputation: 21
I have sources from a project with a CMakeLists.txt which contains:
ADD_LIBRARY(ACGL${COMPILE_POSTFIX} STATIC ${SOURCE_FILES} ${HEADER_FILES})
TARGET_LINK_LIBRARIES(ACGL${COMPILE_POSTFIX} ${LIBRARIES})
Using cmake I generate a makefile for MSYS with the -std=gnu++11 option set via
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
This is working fine and all the .obj files are created upon using make. However after creating all the .obj files it doesn't generate a static library and thus terminates with the error:
[...]
[ 90%] Building CXX object CMakeFiles/ACGL.dir/src/rgbe/rgbe.cc.obj
[ 93%] Building CXX object CMakeFiles/ACGL.dir/src/lodepng/lodepng.cpp.obj
[ 95%] Building CXX object CMakeFiles/ACGL.dir/src/nv_dds/nv_dds.cpp.obj
Linking CXX static library "/C/Users/Tarek/Desktop/Netbeans Workspace/acgl/lib/l
ibACGL.a"
C:/MinGW/bin/ar.exe: /C/Users/Tarek/Desktop/Netbeans Workspace/acgl/lib/libACGL.
a: No such file or directory
make[2]: *** [C:/Users/Tarek/Desktop/Netbeans Workspace/acgl/lib/libACGL.a] Erro
r 1
make[1]: *** [CMakeFiles/ACGL.dir/all] Error 2
make: *** [all] Error 2
Can somebody explain to me why the library isn't created, even though the ADD_LIBRARY is specified in the cmakelists? If it helps this is the complete generated makefile: https://gist.github.com/anonymous/1c4982a86794f8c490b6
Is there something wrong in the generating of the makefile?
Also if you need anything else, please comment and I will provide it.
Upvotes: 1
Views: 965
Reputation: 21
I fixed this, by looking at the link.txt which in my case was located at acgl_bin\CMakeFiles\ACGL.dir\link.txt It contains the line responsible for creating the library:
C:/MinGW/bin/ar.exe cr "/c/Users/Tarek/Desktop/Netbeans Workspace/acgl/lib/libACGL.a" CMakeFiles/ACGL.dir/src/ACGL/ACGL.cc.obj [more obj files]
C:/MinGW/bin/ranlib.exe "/c/Users/Tarek/Desktop/Netbeans Workspace/acgl/lib/libACGL.a"
ar couldn't find the path, so I changed it to a relative path:
C:/MinGW/bin/ar.exe cr "../acgl/lib/libACGL.a" CMakeFiles/ACGL.dir/src/ACGL/ACGL.cc.obj [more obj files]
C:/MinGW/bin/ranlib.exe "../acgl/lib/libACGL.a"
and everything compiled fine.
Upvotes: 1