Ask Your Question

Failure to find while building rosbag_storage

asked 2020-01-22 10:45:37 -0600

broomstick gravatar image

I'm building on FreeBSD from source, using catkin_make_isolated.

When I'm building rosbag_storage the linker fails to find with the error ld: cannot find -lgpgme.

I have installed the libgpgme package and confirm is in /usr/local/lib. Apparently, this is not a default search path (on FreeBSD only?) for libraries to link, however.

I added link_directories(/usr/local/lib) at the top of the CMakeList.txt file for rosbag_storage. The linker now finds the library and rosbag_storage builds just fine.

Is there a better way to do this than to modify the CMakeList.txt? I'm trying to keep the FreeBSD build process as close as possible to the Ubuntu process, so the fewer manual modifications I have to make, the better.

edit retag flag offensive close merge delete


As much as you're encountering this while building a ROS package, I don't believe this is a ROS problem necessarily, but more a general CMake how-to-link-a-library problem (but the specifically with libgpgme).

Could you try creating an MWE which just tries to link libgpgme to a test program? If that also doesn't work, it would seem to be a general issue.

gvdhoorn gravatar imagegvdhoorn ( 2020-01-22 11:42:17 -0600 )edit

It does appear to be a general issue with FreeBSD not automatically including /usr/local/lib.

My question, more specifically, is whether there is a way for me to specify link directories at build time so I don't have to modify the CMakeList.txt file.

I suppose this is a catkin question...?

broomstick gravatar imagebroomstick ( 2020-01-22 12:24:03 -0600 )edit

No. That would make it a CMake one. Catkin doesn't do anything with this. And I guess the keyword would be: specify a library search path. Not link directories (as that is the name of the CMake command).

gvdhoorn gravatar imagegvdhoorn ( 2020-01-22 13:29:37 -0600 )edit

I'm new to cmake (and catkin), so I'm having a hard time either understanding or implementing your response.

For rosbag_storage, the CMakeList.txt file includes the following:

set(AES_ENCRYPT_LIBRARIES "crypto" "gpgme")

The variable is then used as follows:

target_link_libraries(rosbag_storage ... ${AES_ENCRYPT_LIBRARIES})

I cannot find a command line argument to pass to cmake (via catkin_make) to allow the linker to find libgpgme. I continue to get the error ld: cannot find -lgpgme.

The only thing I've found that works is to place link_directories(/usr/local/lib) in CMakeList.txt before set(AES_ENCRYPT_LIBRARIES "crypto" "gpgme").

I can limit the superfluity of this with a check for the target OS: if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") link_directories(/usr/local/lib) endif()

broomstick gravatar imagebroomstick ( 2020-01-22 16:11:56 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-01-30 05:21:24 -0600

broomstick gravatar image

To close this out:

I fixed this (for both my Mac and FreeBSD builds), by using cmake's find_library function in the CMakeList.txt file.

You can see my full solution here:

There is also a (currently pending) pull request:

edit flag offensive delete link more


Thanks for submitting the PR and fixing this.

And thanks for reporting back here on ROS Answers.

gvdhoorn gravatar imagegvdhoorn ( 2020-01-30 05:54:37 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-01-22 10:45:37 -0600

Seen: 14 times

Last updated: Jan 30