[SOLVED]different compile behavior between codelite and cmd
Posted: Mon Jun 19, 2017 12:59 pm
When trying to link gtest library, the codelite compile failed but the command line compile successfully.
the cmakelists.txt generated by codelite:
make in command line:
the compile result in codelite
the compile result in command line:
the cmakelists.txt generated by codelite:
Code: Select all
add_executable(TEST_codelite ${RC_SRCS} ${CXX_SRCS} ${C_SRCS})
target_link_libraries(TEST_codelite ${LINK_OPTIONS})
target_link_libraries(TEST_codelite
${WORKSPACE_PATH}gtest/lib/libgtest.a
)
Code: Select all
cmake -G "MinGW Makefiles" ../
mingw32-make
Code: Select all
C:\Windows\system32\cmd.exe /C cd D:\Projects\TEST_codelite\cmake-build-Debug\TEST_codelite && D:/Tools/mingw-w64/x86_64-7.1.0-posix-seh-rt_v5-rev0/mingw64/bin/mingw32-make.exe -j8 SHELL=cmd.exe -e
[ 33%] Linking CXX executable ..\output\TEST_codelite.exe
CMakeFiles\TEST_codelite.dir/objects.a(TestFramework.cpp.obj): In function `__static_initialization_and_destruction_0':
D:/Projects/TEST_codelite/CTest/src/TestFramework.cpp:54: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
D:/Projects/TEST_codelite/CTest/src/TestFramework.cpp:97: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
D:/Projects/TEST_codelite/CTest/src/TestFramework.cpp:141: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
D:/Projects/TEST_codelite/CTest/src/TestFramework.cpp:175: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
D:/Projects/TEST_codelite/CTest/src/TestFramework.cpp:212: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CMakeFiles\TEST_codelite.dir/objects.a(TestFramework.cpp.obj):D:/Projects/TEST_codelite/CTest/src/TestFramework.cpp:257: more undefined references to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' follow
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [../output/TEST_codelite.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/TEST_codelite.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
CMakeFiles\TEST_codelite.dir\build.make:125: recipe for target '../output/TEST_codelite.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/TEST_codelite.dir/all' failed
Makefile:82: recipe for target 'all' failed
====6 errors, 0 warnings====
Code: Select all
D:\Projects\TEST_codelite\build>cmake -G "MinGW Makefiles" ../
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Projects/TEST_codelite/build
D:\Projects\TEST_codelite\build>mingw32-make
[ 33%] Linking CXX executable ..\cmake-build-Debug\output\TEST_codelite.exe
[100%] Built target TEST_codelite