This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Help about CMakeLists, again and again :(

Tags: None
(comma "," separated)
wotan
Registered Member
Posts
131
Karma
-2
OS
I there I am trying to follow http://www.cmake.org/cmake/help/cmake_tutorial.html


That is to say, I try to compile a programm (test_of_vector_tools) that includes .cpp and .h files that are in an other direcotry (lib_kinematic) where I put all my includes.
If I understand it right:
I just put a CMakeLists in the libkinematic directory
in the test_of_vector_tools one, I have to
add an "include directories"
add "add_subdirectory" as well to actually build the library
add a targetl_link_library

Compared to the tutorial
In my case lib_kinematic is Mathfunction
and test_of_vector_tools is Tutorial


Code: Select all
CMake Error at CMakeLists.txt:10 (add_subdirectory):
  add_subdirectory given source "/home/max/Documents/C/Inckude/lib_kinematic"
which is not an existing directory.


Code: Select all
project(test_of_vector_tools)
cmake_minimum_required(VERSION 2.6)
find_package(Qt4 REQUIRED)
# The version number.
set (test_of_vector_tools_VERSION_MAJOR 1)
set (test_of_vector_tools_VERSION_MINOR 0)
#include subdirectories
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
include_directories ("/home/max/Documents/C/Include/lib_kinematic")
add_subdirectory(/home/max/Documents/C/Inckude/lib_kinematic)
set(test_of_vector_tools_SRCS test_of_vector_tools.cpp main.cpp)
qt4_automoc(${test_of_vector_tools_SRCS})
add_executable(test_of_vector_tools ${test_of_vector_tools_SRCS})
target_link_libraries(test_of_vector_tools ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} lib_kinematic)
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You appear to have a minor typo...
Code: Select all
/home/max/Documents/C/Inckude/lib_kinematic

should be
Code: Select all
/home/max/Documents/C/Include/lib_kinematic


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
wotan
Registered Member
Posts
131
Karma
-2
OS
OOps that's right,
But the problem now is that he is complaining that
Code: Select all
/home/max/Documents/C/Include/lib_kinematic

is not a subdirectory, which is indeed right, but I don't have no "add_directory" command
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
It is likely referring to the fact that the paths CMake needs should be relative to where the CMakeLists.txt file is.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
wotan
Registered Member
Posts
131
Karma
-2
OS
Okay yeah but the stuff is I am not so keen to write a relative link
Anyway, I now do it another way, I compile a .so file separtely, which I try to link .
I still have a final linking problem:
Code: Select all
max@netbook:~$ ls /home/max/Documents/C/Library/lib/
libkinematic.so
max@netbook:~$ echo $LD_LIBRARY_PATH
/home/max/Documents/C/Library/lib:


Compilation
Code: Select all
Linking CXX executable test_of_vector_tools
/usr/bin/ld: cannot find -lkinematic


in the CMakesLists
Code: Select all
target_link_libraries(test_of_vector_tools ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} kinematic)


To me it should find it since it is in a directory that is scaned by ld
So far as I have read on the internet the -lkinematic should add a "lib" before and a ".so" at the end , also it should be gould ?
I googled and don't find something else than the LD_LIBRARY_PATH stuff (which I have done)

Thanks a lot.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
If "kinematic" is already linked to in your CMakeLists.txt, then it should be linked to automatically.

I'm not sure of the exact CMake macro, but you probably need to add the linker path however - this is seperate to LD_LIBRARY_PATH.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
wotan
Registered Member
Posts
131
Karma
-2
OS
hmm I don't clearly understand. To me it is rather a problem that the .so files does not get indexed even when running ldconfing on the path where it is because
If I place the .so file in /usr/lib then the compilation will work without a problem and it will run too

What do you mean by adding the linker path?
My CMakeLists looks like that:

Code: Select all
project(test_kinematic)
cmake_minimum_required(VERSION 2.6)
find_package(Qt4 REQUIRED)
#find_library(kinematic REQUIRED)

# The version number.
set (test_of_vector_tools_VERSION_MAJOR 1)
set (test_of_vector_tools_VERSION_MINOR 0)
#include subdirectories
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} /home/max/Documents/C/Library/kinematic/include/)

set(test_of_vector_tools_SRCS test_of_vector_tools.cpp main.cpp )
qt4_automoc(${test_of_vector_tools_SRCS})
add_executable(test_of_vector_tools ${test_of_vector_tools_SRCS})
target_link_libraries(test_of_vector_tools ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} kinematic)
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Please see http://www.cmake.org/Wiki/CMake_2.6_Not ... irectories

The linker is the program which runs after the compiler, and is responsible for creating the final binary from the now compiled code. The GNU Compiler usually uses "ld" as it's linker.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft