CURL package not found

Hi, I have just downloaded the latest Dronecode commit from github and, when I try to launch cmake .. from an example’s build folder (i.e. takeoff_land) I get the following error:

– The C compiler identification is GNU 5.4.0
– The CXX compiler identification is GNU 5.4.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
CMake Error at /usr/local/lib/cmake/DronecodeSDK/DronecodeSDKConfig.cmake:4 (find_package):
Could not find a package configuration file provided by “CURL” with any of
the following names:

CURLConfig.cmake
curl-config.cmake

Add the installation prefix of “CURL” to CMAKE_PREFIX_PATH or set
“CURL_DIR” to a directory containing one of the above files. If “CURL”
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)

– Configuring incomplete, errors occurred!
See also “/home/…/PX4/DronecodeSDK/example/takeoff_land/build/CMakeFiles/CMakeOutput.log”.

I cannot understand what’s wrong with curl. I installed it, but cmake can’t find some file…

@JulianOes, I saw that somebody before had the same problem on Ubuntu 17.04… but I am using Ubuntu 16.04 LTS.

How can I solve this problem?

Thank you so much!

1 Like

There have recently been some build system changes: https://github.com/Dronecode/DronecodeSDK/pull/724

I’m going to ping @JonasVautherin, hopefully he can help.

1 Like

When building with cmake, by default it will build the dependencies and the SDK as static libraries (*.a) (as opposed to shared libraries (*.so)). Installing the SDK static libs on the system (libdronecode_sdk_action.so, libdronecode_sdk_telemetry.so, …) would mean that you need to install the dependencies on the system as well. And by default we install them locally.

Long story short, I think that you want to build the SDK as shared libraries (using BUILD_SHARED_LIBS) and install that on the system, which would mean:

cmake -DBUILD_SHARED_LIBS=ON ..

Note that the above command is to build the SDK, not to build the example (in the question you are building the example).

Another way, this time when building the example, is to tell cmake where to go find CURLConfig.cmake by setting CMAKE_PREFIX_PATH to the install directory of the deps, which should be something like:

cmake -DCMAKE_PREFIX_PATH=/path/to/DronecodeSDK/build/default/third_party/install ..

It is not easy to find a straightforward default for BUILD_SHARED_LIBS: if you want to install the SDK on your system, you probably want to build shared libs (first solution above). When building an example, you may want to statically link the SDK into your binary (that would be the second solution above). And if you want to build the gRPC backend, you probably want static libs again.

Anyway, I’m working on updating our documentation, I’ll write a note about that!

Let us know how it goes with one of the above solutions!

4 Likes

Thank you so much. I’ll try and I will let you know…
In the meantime I have found a workaround by tweaking the example’s CMakeLists.txt file as follows:

cmake_minimum_required(VERSION 2.8.12)

project(offboard)

if(MINGW)
add_definitions(“-D_USE_MATH_DEFINES”) # For M_PI
endif()

if(MSVC)
add_definitions(“-std=c++11 -WX -W2”)
add_definitions(“-D_USE_MATH_DEFINES”) # For M_PI
else()
add_definitions(“-std=c++11 -Wall -Wextra -Werror”)
endif()

#find_package(DronecodeSDK REQUIRED)

include_directories(/usr/local/include/dronecode_sdk/)
link_directories(/usr/local/lib)

add_executable(offboard
offboard_velocity.cpp
)

target_link_libraries(offboard
dronecode_sdk_action
dronecode_sdk_offboard
dronecode_sdk_telemetry
dronecode_sdk
pthread
)

Haha please don’t do that :sweat_smile:. BUILD_SHARED_LIBS will require you to rebuild the SDK, which will take some time, but CMAKE_PREFIX_PATH is done for building the example, which means that it will be super quick to try. Make sure to clean the previous build of the example (usually that’s about removing the build/ folder in which CMake did its configuration).

1 Like

I am sorry I messed with your CMakeLists :sweat_smile:

I tried this (to build the SDK):

mkdir -p build/default
cd build/default
cmake -DBUILD_SHARED_LIBS=ON …/…
make
sudo make install

but CURL is still missing :roll_eyes:

On the contrary, the DCMAKE_PREFIX_PATH way (to build the examples) works!

Setting -DBUILD_SHARED_LIBS=ON probably requires you to clean your previous build (I would just rm -rf build/default before the commands you listed above).

Yes, I did that. I also deleted the .h and the .a files from the linux include and lib folders before I rebuilt the SDK… it didn’t work.

You’re right, my mistake. That’s a bug, I reported it here: https://github.com/Dronecode/DronecodeSDK/issues/758.

I will fix it there ASAP! Thanks for testing and reporting :slight_smile:.

2 Likes

Thank you @JonasVautherin and @JulianOes!

Should be fixed here, such that the following should then work:

mkdir -p build/default
cd build/default
cmake -DBUILD_SHARED_LIBS=ON …/…
make
sudo make install

Feel free to try the PR and review it if you can! :slight_smile:

Yes, it works now.
Thank you!

Dear Jonas,

I ran into the same problem this week - thanks for the explanation!

However,
https://mavsdk.mavlink.io/main/en/cpp/guide/build_mavsdk_server.html
says explicitly to set -DBUILD_SHARED_LIBS=OFF when building mavsdk_server. Is it going to produce a problem later on if I build the server with shared libs?