Skip to content

Link module with an external library #976

Answered by ThibFrgsGmz
ugo94490 asked this question in Q&A
Discussion options

You must be logged in to vote

If you tried to link an external C library, make sure you have the external "c" tag so that the C++ compiler does not add extra manipulation information to the function name symbols.

Then in the CMakeLists.txt of the component in which you want to use the external library you must add the following lines. In my case I try to link a quaternion calculation library (named libQuaternion.a).

# Retrieve the name of the module that converts the root path of your project to a underscore, i.e. Fw/Types becomes Fw_Types.
get_module_name("${CMAKE_CURRENT_LIST_DIR}")

# Tell the compiler the path to the library header file.
include_directories("${PROJECT_SOURCE_DIR}/libs")

# Find all the libraries c…

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
10 replies
@ThibFrgsGmz
Comment options

@ThibFrgsGmz
Comment options

@astroesteban
Comment options

@ThibFrgsGmz
Comment options

@astroesteban
Comment options

Comment options

You must be logged in to vote
1 reply
@ugo94490
Comment options

Answer selected by ugo94490
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants