How to add sqlite3 dependency to catkin package?

asked 2020-02-04 12:18:13 -0500

alexmussell gravatar image

I am writing a ROS node that uses the sqlite3 c library. I have been including it with:

#include <sqlite3.h>

I have the header in /usr/include, but when I build with catkin I get linker errors to all of the sqlite functions. I think that I need to add the library as a depency somehow with CMake, but I'm not sure how. How can I add sqlite3 as a dependency?

edit retag flag offensive close merge delete


Something to consider: how would you do this with plain CMake?

gvdhoorn gravatar image gvdhoorn  ( 2020-02-04 14:25:29 -0500 )edit

I don't know, I am new to CMake. Do you know?

alexmussell gravatar image alexmussell  ( 2020-02-04 14:31:19 -0500 )edit

Reason I posted this comment is that I wanted to make you realise your question is not ROS-specific. There is nothing that Catkin adds or modifies here. With that, this opens up the pool of resources you have at your disposal to include the entire global CMake community (ie: the internet).

Asking this sort of question here on ROS Answers is of course completely OK. However, it also means you have to wait for answers, which can take a long time (sometimes). And there is no need to wait. Just use google and search for how to link to sqlite3 using CMake.

We're here to help, but with this kind of question it's best to turn to a venue that is suited for the type of question. As this is a pure CMake question, ROS Answers is not that venue.

gvdhoorn gravatar image gvdhoorn  ( 2020-02-04 14:35:47 -0500 )edit

I do believe there are ROS specific aspects of this question (correct me if I am wrong). For example I need to make catkin aware that I am dependent on this system library so that if another package (package A) depends on my package, catkin will automatically figure out that package A also depends on the system library. I think I need something like this here:

alexmussell gravatar image alexmussell  ( 2020-02-04 14:55:15 -0500 )edit

That would be a separate issue (namely: dependency management).

You mention:

I get linker errors to all of the sqlite functions

That's an issue with your build script, not with how dependencies in your package manifest are stated.

And technically, that would still be independent of Catkin: the package manifest is not tied to Catkin. It's build tool agnostic (it's also used in ROS 2 for instance, which doesn't do anything with Catkin).

Please understand I'm being pedantic for a reason here: you are new to "all" of this, so it's important to immediately understand what is "part of ROS" and what is not. CMake is not. As I wrote earlier, realising this should make it easier to find resources you could ask for help, as the CMake user community is larger than the ROS one.

gvdhoorn gravatar image gvdhoorn  ( 2020-02-04 15:01:32 -0500 )edit

Thanks for the help! I'll keep that in mind.

alexmussell gravatar image alexmussell  ( 2020-02-04 16:25:45 -0500 )edit