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!
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
#find_package(DronecodeSDK REQUIRED)
include_directories(/usr/local/include/dronecode_sdk/)
link_directories(/usr/local/lib)
Haha please don’t do that
. 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).
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
.
Should be fixed here, such that the following should then work:
mkdir -p build/default
cd build/default
cmake -DBUILD_SHARED_LIBS=ON …/…
sudo make install
Feel free to try the PR and review it if you can! 
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?