I need to build a standalone executable which uses MAVSDK and therefore I want to build MAVSDK as static library. But when I set the flag BUILD_SHARED_LIBS=OFF with
I finish with the following error when I build my application:
CMake Error at /usr/share/cmake-3.13/Modules/CMakeFindDependencyMacro.cmake:48 (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):
/usr/local/lib/cmake/MAVSDK/MAVSDKConfig.cmake:7 (find_dependency)
CMakeLists.txt:14 (find_package)
I finish with the same error with MAVSDK 0.33.1 and with develop branch. I saw a similar issue here but when enabling shared library.
I too have same problem. I build mavsdk as static libs and compile with my application. mavsdk static libs build fine but later when I include them into my app, during my app compilation, getting curl undefined reference errors. Should I inlcude curl lib into my makefile? I think the mavsdk static lib would have already statically linked curl lib?
now I get your point (sorry I’m discovering CMake building environment). So when I add the flags -DCMAKE_INSTALL_PREFIX=install -DDEPS_INSTALL_PATH=install and after building I have an install folder with all the dependencies and static libraries of MAVSDK. How should I integrate that into my project with CMake now ?
Because I didn’t catch your point, I started to git all dependencies in my project (jsoncpp, curl, tinyxml2) to be able to use MAVSDK as static library. What is the best practice here ?
My thought would be to integrate MAVSDK as a third party and let it integrate all the libs it requires with the flags you provide me but I’m not sure how to proceed. Any guidance would be really appreciated
I managed to compile MAVSDK and all its dependencies. I failed to build a static executable because it crahes when I try to create a Mavsdk instance. But now that everything is downloaded and compiled locally I can survivre without a static executable…
To give some hints to anyone trying the same, I have almost copy/paste what MAVSDK does for its libraries, so with a file CMakeLists.txt like below (in third_party/MAVSDK folder):
This probably isn’t best practice, but since I am modifying my version of MAVSDK this is the best way for me. To include statically I create a lib/ directory in my projects root folder structure and put my compiled mavsdk folder in it (the folder that ends up in install/)
and did you manage to run your application when you build the executable statically with something like below and with the flag -DBUILD_SHARED_LIBS=OFF ?
target_link_libraries(your_target_name -static)
On my side, adding these flags let me build the executable statically but the app crashes when I run it. The crash seems to happen when I create a Mavsdk instance in my code.