Using Catkin with CMake Interface Library
I am currently trying to use a c++ header-only library declared as a cmake interface library within catkin. This library is supposed to be used by other packages in catkin_ws/src. I was able to compile all packages with catkin_make
but not with catkin build
.
catkin build
fails within the cmake command find_package(... interface_lib)
in dependent packages.
Error-Message for the example below would be:
Project 'testnode' tried to find library 'interface_library'. The library
is neither a target nor built/installed properly. Did you compile project
'interface_library'? Did you find_package() it before the subdirectory
containing its code is included?
How do i need to setup CMakeLists.txt and package.xml files to make catkin build
work with interface libraries?
Minimal example:
Interface Library
File: catkin_ws/src/interface_library/include/interface_library.hpp
#pragma once
#define RATE 10
File: catkin_ws/src/interface_library/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(interface_library)
find_package(catkin REQUIRED)
catkin_package(INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME})
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE include)
File: catkin_ws/src/interface_library/package.xml
<package format="2">
<name>interface_library</name>
<description>Test interface library</description>
<version>0.0.1</version>
<maintainer email="master@disaster.com">Master of Disaster</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
</package>
Testnode
File: catkin_ws/src/testnode/src/testnode.cpp
#include <iostream>
#include "interface_library.hpp"
int main(void)
{
std::cout << RATE << std::endl;
}
File: catkin_ws/src/testnode/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(testnode)
find_package(catkin REQUIRED COMPONENTS interface_library)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
add_executable(${PROJECT_NAME}_node src/testnode.cpp)
File: catkin_ws/src/testnode/package.xml
<?xml version="1.0"?>
<package format="2">
<name>testnode</name>
<version>0.0.0</version>
<description>The testnode package</description>
<maintainer email="master@disaster.com">Master of Disaster</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>interface_library</build_depend>
<build_export_depend>interface_library</build_export_depend>
<exec_depend>interface_library</exec_depend>
</package>
c++ cmake ros catkin
add a comment |
I am currently trying to use a c++ header-only library declared as a cmake interface library within catkin. This library is supposed to be used by other packages in catkin_ws/src. I was able to compile all packages with catkin_make
but not with catkin build
.
catkin build
fails within the cmake command find_package(... interface_lib)
in dependent packages.
Error-Message for the example below would be:
Project 'testnode' tried to find library 'interface_library'. The library
is neither a target nor built/installed properly. Did you compile project
'interface_library'? Did you find_package() it before the subdirectory
containing its code is included?
How do i need to setup CMakeLists.txt and package.xml files to make catkin build
work with interface libraries?
Minimal example:
Interface Library
File: catkin_ws/src/interface_library/include/interface_library.hpp
#pragma once
#define RATE 10
File: catkin_ws/src/interface_library/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(interface_library)
find_package(catkin REQUIRED)
catkin_package(INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME})
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE include)
File: catkin_ws/src/interface_library/package.xml
<package format="2">
<name>interface_library</name>
<description>Test interface library</description>
<version>0.0.1</version>
<maintainer email="master@disaster.com">Master of Disaster</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
</package>
Testnode
File: catkin_ws/src/testnode/src/testnode.cpp
#include <iostream>
#include "interface_library.hpp"
int main(void)
{
std::cout << RATE << std::endl;
}
File: catkin_ws/src/testnode/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(testnode)
find_package(catkin REQUIRED COMPONENTS interface_library)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
add_executable(${PROJECT_NAME}_node src/testnode.cpp)
File: catkin_ws/src/testnode/package.xml
<?xml version="1.0"?>
<package format="2">
<name>testnode</name>
<version>0.0.0</version>
<description>The testnode package</description>
<maintainer email="master@disaster.com">Master of Disaster</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>interface_library</build_depend>
<build_export_depend>interface_library</build_export_depend>
<exec_depend>interface_library</exec_depend>
</package>
c++ cmake ros catkin
add a comment |
I am currently trying to use a c++ header-only library declared as a cmake interface library within catkin. This library is supposed to be used by other packages in catkin_ws/src. I was able to compile all packages with catkin_make
but not with catkin build
.
catkin build
fails within the cmake command find_package(... interface_lib)
in dependent packages.
Error-Message for the example below would be:
Project 'testnode' tried to find library 'interface_library'. The library
is neither a target nor built/installed properly. Did you compile project
'interface_library'? Did you find_package() it before the subdirectory
containing its code is included?
How do i need to setup CMakeLists.txt and package.xml files to make catkin build
work with interface libraries?
Minimal example:
Interface Library
File: catkin_ws/src/interface_library/include/interface_library.hpp
#pragma once
#define RATE 10
File: catkin_ws/src/interface_library/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(interface_library)
find_package(catkin REQUIRED)
catkin_package(INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME})
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE include)
File: catkin_ws/src/interface_library/package.xml
<package format="2">
<name>interface_library</name>
<description>Test interface library</description>
<version>0.0.1</version>
<maintainer email="master@disaster.com">Master of Disaster</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
</package>
Testnode
File: catkin_ws/src/testnode/src/testnode.cpp
#include <iostream>
#include "interface_library.hpp"
int main(void)
{
std::cout << RATE << std::endl;
}
File: catkin_ws/src/testnode/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(testnode)
find_package(catkin REQUIRED COMPONENTS interface_library)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
add_executable(${PROJECT_NAME}_node src/testnode.cpp)
File: catkin_ws/src/testnode/package.xml
<?xml version="1.0"?>
<package format="2">
<name>testnode</name>
<version>0.0.0</version>
<description>The testnode package</description>
<maintainer email="master@disaster.com">Master of Disaster</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>interface_library</build_depend>
<build_export_depend>interface_library</build_export_depend>
<exec_depend>interface_library</exec_depend>
</package>
c++ cmake ros catkin
I am currently trying to use a c++ header-only library declared as a cmake interface library within catkin. This library is supposed to be used by other packages in catkin_ws/src. I was able to compile all packages with catkin_make
but not with catkin build
.
catkin build
fails within the cmake command find_package(... interface_lib)
in dependent packages.
Error-Message for the example below would be:
Project 'testnode' tried to find library 'interface_library'. The library
is neither a target nor built/installed properly. Did you compile project
'interface_library'? Did you find_package() it before the subdirectory
containing its code is included?
How do i need to setup CMakeLists.txt and package.xml files to make catkin build
work with interface libraries?
Minimal example:
Interface Library
File: catkin_ws/src/interface_library/include/interface_library.hpp
#pragma once
#define RATE 10
File: catkin_ws/src/interface_library/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(interface_library)
find_package(catkin REQUIRED)
catkin_package(INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME})
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE include)
File: catkin_ws/src/interface_library/package.xml
<package format="2">
<name>interface_library</name>
<description>Test interface library</description>
<version>0.0.1</version>
<maintainer email="master@disaster.com">Master of Disaster</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
</package>
Testnode
File: catkin_ws/src/testnode/src/testnode.cpp
#include <iostream>
#include "interface_library.hpp"
int main(void)
{
std::cout << RATE << std::endl;
}
File: catkin_ws/src/testnode/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(testnode)
find_package(catkin REQUIRED COMPONENTS interface_library)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
add_executable(${PROJECT_NAME}_node src/testnode.cpp)
File: catkin_ws/src/testnode/package.xml
<?xml version="1.0"?>
<package format="2">
<name>testnode</name>
<version>0.0.0</version>
<description>The testnode package</description>
<maintainer email="master@disaster.com">Master of Disaster</maintainer>
<license>MIT</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>interface_library</build_depend>
<build_export_depend>interface_library</build_export_depend>
<exec_depend>interface_library</exec_depend>
</package>
c++ cmake ros catkin
c++ cmake ros catkin
asked Nov 12 at 17:53
JFT
143
143
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
older catkin or catkin_make
uses merged development space but newer catkin or catkin build
use linked development space by default.
First thing you should do is to separate catkin workspaces from each other in 2 different folder. Then set up change catkin build
's workspace to merged-devel with:
catkin config --merge-devel
and also manually expand it's search areas to both your main ROS folder (default in /opt/ros/<your-version>
) and other catkin workspaces which you may use with:
catkin config --expand <path-to-ros-workspace>
after that add your projects and build.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267571%2fusing-catkin-with-cmake-interface-library%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
older catkin or catkin_make
uses merged development space but newer catkin or catkin build
use linked development space by default.
First thing you should do is to separate catkin workspaces from each other in 2 different folder. Then set up change catkin build
's workspace to merged-devel with:
catkin config --merge-devel
and also manually expand it's search areas to both your main ROS folder (default in /opt/ros/<your-version>
) and other catkin workspaces which you may use with:
catkin config --expand <path-to-ros-workspace>
after that add your projects and build.
add a comment |
older catkin or catkin_make
uses merged development space but newer catkin or catkin build
use linked development space by default.
First thing you should do is to separate catkin workspaces from each other in 2 different folder. Then set up change catkin build
's workspace to merged-devel with:
catkin config --merge-devel
and also manually expand it's search areas to both your main ROS folder (default in /opt/ros/<your-version>
) and other catkin workspaces which you may use with:
catkin config --expand <path-to-ros-workspace>
after that add your projects and build.
add a comment |
older catkin or catkin_make
uses merged development space but newer catkin or catkin build
use linked development space by default.
First thing you should do is to separate catkin workspaces from each other in 2 different folder. Then set up change catkin build
's workspace to merged-devel with:
catkin config --merge-devel
and also manually expand it's search areas to both your main ROS folder (default in /opt/ros/<your-version>
) and other catkin workspaces which you may use with:
catkin config --expand <path-to-ros-workspace>
after that add your projects and build.
older catkin or catkin_make
uses merged development space but newer catkin or catkin build
use linked development space by default.
First thing you should do is to separate catkin workspaces from each other in 2 different folder. Then set up change catkin build
's workspace to merged-devel with:
catkin config --merge-devel
and also manually expand it's search areas to both your main ROS folder (default in /opt/ros/<your-version>
) and other catkin workspaces which you may use with:
catkin config --expand <path-to-ros-workspace>
after that add your projects and build.
answered Nov 21 at 16:15
Mohammad Ali
30018
30018
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267571%2fusing-catkin-with-cmake-interface-library%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown