Reputation: 2541
just faced with a GCC on ubuntu when was trying to build my sample project, found those three libraries (from subject) required to link. and also found that order of '-lxxx' parameters is important in a commandline
however I'm using cmake as a build system and could find this applying to cmake.
currently this is :
if (${GCC})
target_link_libraries(${PROJECT_NAME} rt pthread stdc++fs)
endif (${GCC})
and it doesn't work for me, linker still can't find referred symbols from all referred libs.
could someone help with this libraries linkage from cmake perspective?
Upvotes: 2
Views: 1112
Reputation: 8260
As it stands, your conditions is always false (the variable doesn't exist AFAIK), so the statements inside of it are never taken into account!
You need to change:
if(${GCC})
To:
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Or:
if(CMAKE_COMPILER_IS_GNUCXX)
This now checks if the C++ compiler is gcc/g++.
Upvotes: 4