开发者

kdevelop: editing CMakeLists.txt

开发者 https://www.devze.com 2023-01-08 06:36 出处:网络
I am having troubles trying to make my project work with kdevelop. In the CMakeLists.txt I have included the paths to the libraries that I use:

I am having troubles trying to make my project work with kdevelop.

In the CMakeLists.txt I have included the paths to the libraries that I use:

cmake_minimum_required(VERSION 2.4.6)
PROJECT(Ormapi)
INCLUDE_DIRECTORIES("/dir/whatever/local/dir/include") < here is defined global.h
INCLUDE_DIRECTORIES("/dir/whatever/local/src")    

ADD_EXECUTABLE(Ormapi main.cpp OrmAPI.cpp)

main.cpp uses an instance of the class I have defined in OrmAPI.cpp. The problem is when I try to create an instance of any other class defined in the above included_directories, I get the both errors "undefined reference to " and "undefined reference to ".

This is the call from the constructor of OrmAPI.cpp (Global is the class that exist开发者_StackOverflows inside the included directories):

OrmAPI::OrmAPI(){        
 Global::dirs()->addResourceDir("mydir");    

}

I am 99% sure that it is related with the CMakeLists.txt, but I do not know what on Earth can be happening.

Any directions?


Finally found the problem:

cmake_minimum_required(VERSION 2.4.6)
PROJECT(Ormapi)
INCLUDE_DIRECTORIES("/dir/whatever/local/dir/include") < here is defined global.h
INCLUDE_DIRECTORIES("/dir/whatever/local/src")    

ADD_EXECUTABLE(Ormapi main.cpp OrmAPI.cpp)
target_link_libraries(Ormapi /dirdir/lib.so) <<<

Since I am creating instances of objects declared in those paths, I have to include a shared library too. But It has to be after the ADD_EXECUTABLE. I was reading the tree of dependencies from the other side.

BTW: I found here a huge ammount of interesting information about dealing with Makefiles, CMakeLists, etc..

0

精彩评论

暂无评论...
验证码 换一张
取 消