Add a new library (.so files) in project [closed]

asked 2020-10-20 06:54:36 -0500

tuan gravatar image

updated 2020-10-20 07:08:10 -0500

Hi,

I need to use a library named 'lib" which contains many .so files. To use them, in CmakeList.txt I set:

target_link_libraries( NodeName ${catkin_LIBRARIES}

${PROJECT_SOURCE_DIR}/lib/first_file.so

${PROJECT_SOURCE_DIR}/lib/second_file.so
)

and it worked.

The problem is that I have so many .so files in the library and it would be nightmare if we list all .so files as above. I tried to use such

${PROJECT_SOURCE_DIR}/lib/*.so

with a hope that this would include all .so file but it generated an error.

I also tried several ways using find_library() or add_library() but all weren't successful.

Could you please let me know your suggestion.

Thank you,

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by gvdhoorn
close date 2020-10-20 07:13:44.153579

Comments

I'm sorry, but this is a pure CMake question, not a ROS question. In this case CMake == Catkin.

Please post your question on a more suitable forum instead.

gvdhoorn gravatar image gvdhoorn  ( 2020-10-20 07:14:33 -0500 )edit

Sorry if it causes any confusion. But I would confirm that this is a ROS related question and I face this problem when working on a ROS project. You can realize this in the setting of the Cmakelist file I mentioned in the question.

target_link_libraries( NodeName ${catkin_LIBRARIES}...

where NodeName is a node in the project.

Hope this clarification allows the question still in the post here.

Thanks.

tuan gravatar image tuan  ( 2020-10-20 07:19:35 -0500 )edit

The fact you link against ${catkin_LIBRARIES} does not make this a ROS question, neither does the fact your CMakeList.txt builds a ROS node/package.

Catkin does not change this either. It's really plain CMake. target_link_libraries(..) is basic CMake. It's not part of Catkin.

You'd do yourself a favour by searching for generic CMake solutions to your problem, as you'll find there are many more resources to learn from. It does not make sense to limit your searches to ROS Answers in this case.

gvdhoorn gravatar image gvdhoorn  ( 2020-10-20 07:28:59 -0500 )edit