[CMake] linking main.cpp to class in the same folder.
eial at cs.bgu.ac.il
eial at cs.bgu.ac.il
Thu Jun 11 07:52:14 EDT 2009
hello.
I've got a class in a folder that I want to run from a main.cpp file, when I compile it, I get a undefined reference to the class's methods.
do I must create a lib from that single class in order to get the linking working?
the CMakeList.txt looks like this:
ADD_LIBRARY(lib1 STATIC ${lib1})
ADD_LIBRARY(lib2 STATIC ${lib2})
#link libs
target_link_libraries(lib1 ${extlib1})
target_link_libraries(lib2 ${extlib1} ${extlib2})
#list all source files here
ADD_EXECUTABLE(prog main.cpp)
#need to link to some other libraries
TARGET_LINK_LIBRARIES(prog lib1 lib2)
main.cpp looks like that:
#include "Class1.h"
int main(int argc, const char* argv[]) {
Class1 cls;
cls.Do1();
cls.Do2();
cls.Do3();
cls.close();
return 0;
}
More information about the CMake
mailing list