ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Dependancy Problem Packaging c library

asked 2015-01-05 11:01:23 -0500

JanOr gravatar image

updated 2015-01-08 05:19:28 -0500

Hey there. Unfortunately I have another problem: With the dependencies in the Cmakelist:

cmake_minimum_required(VERSION 2.8)
project(grampc)

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_runtime rosbag)

add_service_files(FILES grampc_IO.srv)
generate_messages(DEPENDENCIES std_msgs)

catkin_package(
  CATKIN_DEPENDS roscpp rospy std_msgs message_runtime message_generation rosbag
)

include_directories(
  include ${catkin_INCLUDE_DIRS}
)

# define libgrampc sources
set(
  grampc_SRCS

  src/euler1.c
  src/eulermod2.c
  src/grampc_init.c
  src/grampc_mess.c
  src/grampc_run.c
  src/grampc_setopt.c
  src/grampc_setparam.c
  src/heun2.c
  src/probfct.c
  src/ruku45.c
)

# define a libgrampc target
add_library(grampc ${grampc_SRCS})

# define a grampc_node target
add_executable(grampc_node src/grampc.cpp)

# now link our node to the library, and all the libraries from the other pkgs
target_link_libraries(grampc_node grampc ${catkin_LIBRARIES})

add_dependencies(grampc_node grampc_gencpp)

When I execute: catkin_make grampc, than the pkg compiles:

####
#### Running command: "make grampc -j4 -l4" in "/home/dentler/Workspace/catkin/build"
####
[100%] Built target grampc

But when I build the whole workspace with catkin_make I have the same issue like before?!

Linking CXX executable /home/dentler/Workspace/catkin/devel/lib/grampc/grampc_node
[100%] Built target record
[100%] Built target poller
CMakeFiles/grampc_node.dir/src/grampc.cpp.o: In function `grampc_IO_callback(grampc::grampc_IORequest_<std::allocator<void> >&, grampc::grampc_IOResponse_<std::allocator<void> >&)':
grampc.cpp:(.text+0x88): undefined reference to `grampc_run(typeGRAMPC*)'
grampc.cpp:(.text+0xaa): undefined reference to `grampc_setparam_vector(typeGRAMPC*, char*, double*)'
CMakeFiles/grampc_node.dir/src/grampc.cpp.o: In function `main':
grampc.cpp:(.text+0x45e): undefined reference to `grampc_init(typeGRAMPC**)'
grampc.cpp:(.text+0x477): undefined reference to `grampc_setopt_string(typeGRAMPC*, char*, char*)'
grampc.cpp:(.text+0x4a4): undefined reference to `grampc_setopt_real(typeGRAMPC*, char*, double)'
grampc.cpp:(.text+0x4d1): undefined reference to `grampc_setopt_real(typeGRAMPC*, char*, double)'
grampc.cpp:(.text+0x4ea): undefined reference to `grampc_setopt_string(typeGRAMPC*, char*, char*)'
grampc.cpp:(.text+0x517): undefined reference to `grampc_setopt_real(typeGRAMPC*, char*, double)'
grampc.cpp:(.text+0x544): undefined reference to `grampc_setopt_real(typeGRAMPC*, char*, double)'
grampc.cpp:(.text+0x571): undefined reference to `grampc_setopt_real(typeGRAMPC*, char*, double)'
grampc.cpp:(.text+0x59e): undefined reference to `grampc_setopt_real(typeGRAMPC*, char*, double)'
grampc.cpp:(.text+0x5cb): undefined reference to `grampc_setopt_real(typeGRAMPC*, char*, double)'
CMakeFiles/grampc_node.dir/src/grampc.cpp.o:grampc.cpp:(.text+0x5f8): more undefined references to `grampc_setopt_real(typeGRAMPC*, char*, double)' follow
CMakeFiles/grampc_node.dir/src/grampc.cpp.o: In function `main':
grampc.cpp:(.text+0x607): undefined reference to `grampc_printopt(typeGRAMPC*)'
grampc.cpp:(.text+0x631): undefined reference to `grampc_setparam_real(typeGRAMPC*, char*, double)'
grampc.cpp:(.text+0x65b): undefined reference to `grampc_setparam_real(typeGRAMPC*, char*, double)'
grampc.cpp:(.text+0x675): undefined reference to `grampc_setparam_int(typeGRAMPC*, char*, int)'
grampc.cpp:(.text+0x690): undefined reference to `grampc_setparam_vector(typeGRAMPC*, char*, double*)'
grampc.cpp:(.text+0x6ab): undefined reference to `grampc_setparam_vector(typeGRAMPC*, char*, double*)'
grampc.cpp:(.text+0x6c5): undefined reference to `grampc_setparam_int(typeGRAMPC*, char*, int)'
grampc.cpp:(.text+0x6e0): undefined reference to `grampc_setparam_vector(typeGRAMPC*, char*, double*)'
grampc.cpp:(.text+0x6fb): undefined reference to `grampc_setparam_vector(typeGRAMPC*, char*, double*)'
grampc.cpp:(.text+0x716): undefined reference to `grampc_setparam_vector(typeGRAMPC*, char*, double*)'
grampc.cpp:(.text+0x731): undefined reference to `grampc_setparam_vector(typeGRAMPC*, char*, double*)'
grampc.cpp:(.text+0x74c): undefined reference to `grampc_setparam_vector(typeGRAMPC*, char*, double*)'
grampc.cpp:(.text ...
(more)
edit retag flag offensive close merge delete

Comments

Please do not overwrite your previous question with a new one. Either add information to your question or create a new question.

Dirk Thomas gravatar image Dirk Thomas  ( 2015-01-07 11:07:32 -0500 )edit

In addition to what @Dirk Thomas said: try cleaning out your current build/ and devel/ directories (as in: delete them), then invoke catkin_make again. You cannot use catkin_make as a 1-on-1 substitute for regular make.

gvdhoorn gravatar image gvdhoorn  ( 2015-01-08 01:35:55 -0500 )edit

@JanOr: if you make your current pkg available somewhere, I can take a look.

gvdhoorn gravatar image gvdhoorn  ( 2015-01-12 04:09:55 -0500 )edit

Thanks to your help, I learned a lot. As I changed the problem specification. I will open a question more specific soon. Thx

JanOr gravatar image JanOr  ( 2015-01-14 04:03:05 -0500 )edit
JanOr gravatar image JanOr  ( 2015-01-14 05:14:59 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-01-05 13:00:52 -0500

gvdhoorn gravatar image

updated 2015-01-07 01:48:42 -0500

What is the purpose of the Makefile? Are you trying to do a hybrid package that can be compiled using both CMak/catkin & make? Catkin pkgs don't use/have a Makefile.

Also:

[..] With $ make grampc in - catkin/src i get: [..]

Unless you are really doing some hybrid thing, I wouldn't do that. This doesn't look like a normal cmake / catkin workflow to me.

From what I can gather from your OP:

  1. remove grampc/Makefile
  2. remove any other 'left overs' from your previous build attempts in the src dir
  3. cd /path/to/catkin/
  4. catkin_make -j1

Now see whether you get any more errors, and try to solve them.

The -j1 is just for debugging your build infrastructure, it disables parallel building, which can get confusing when trying to fix things.


Edit:

Try something like this. I've assumed there is something called grampc_node.cpp, as it seems like you are trying to create a ROS node, that uses libgrampc to do something. If not (and this is a library-only pkg), just remove the add_executable(..) (and associated target_link_libraries(..)) statement.

In general, you'll want to link against ${catkin_LIBRARIES}, which will contain all libraries exported by the packages that you specify in your find_package(catkin REQUIRED COMPONENTS ..) statement. You were only linking roscpp, hence the linker errors about rosbag fi.

cmake_minimum_required(VERSION 2.8)
project(grampc)

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg message_runtime rosbag)

add_service_files(FILES grampc_IO.srv)
generate_messages(DEPENDENCIES std_msgs)

catkin_package(
  CATKIN_DEPENDS roscpp rospy std_msgs genmsg message_runtime message_generation rosbag
)

include_directories(
  include ${catkin_INCLUDE_DIRS}
)

# define libgrampc sources
set(
  grampc_SRCS

  src/euler1.c
  src/eulermod2.c
  src/grampc_init.c
  src/grampc_mess.c
  src/grampc_run.c
  src/grampc_setopt.c
  src/grampc_setparam.c
  src/heun2.c
  src/probfct.c
  src/ruku45.c
)

# define a libgrampc target
add_library(grampc ${grampc_SRCS})

# define a grampc_node target
add_executable(grampc_node src/grampc_node.cpp)

# now link our node to the library, and all the libraries from the other pkgs
target_link_libraries(grampc_node grampc ${catkin_LIBRARIES})

add_dependencies(grampc_node grampc_gencpp)

This is untested, so this could still fail, but at least it should be closer to what you need.

Also: make sure to check your (catkin) dependency lists, I don't know which packages you really need.

edit flag offensive delete link more
0

answered 2015-01-07 11:09:18 -0500

Dirk Thomas gravatar image

updated 2015-01-07 11:09:46 -0500

The command catkin_make grampc does not build your whole package but only the library target named grampc.

The error messages when you build are coming from the executable your package builds beside the library.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2015-01-05 11:01:23 -0500

Seen: 313 times

Last updated: Jan 14 '15