Failure to find libgpgme.so while building rosbag_storage
I'm building on FreeBSD from source, using catkin_make_isolated
.
When I'm building rosbag_storage
the linker fails to find libgpgme.so
with the error ld: cannot find -lgpgme
.
I have installed the libgpgme
package and confirm libgpgme.so
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.
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.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...?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).
I'm new to cmake (and catkin), so I'm having a hard time either understanding or implementing your response.
For
rosbag_storage
, theCMakeList.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 errorld: cannot find -lgpgme
.The only thing I've found that works is to place
link_directories(/usr/local/lib)
inCMakeList.txt
beforeset(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()