Having Trouble Installing MAVSDK for Windows

Having trouble building the library onto my windows computer. I have cloned the repository and installed Visual Studio 2019 C++ build tools and Cmake but when I execute
cmake -G “Visual Studio 15 2017” -DBUILD_SHARED_LIBS=ON -Bbuild/default -H.
I get the error:

CMake Error at CMakeLists.txt:3 (project):
Generator

Visual Studio 15 2017

could not find any instance of Visual Studio.

– Configuring incomplete, errors occurred!

I have tried downloading further workloads from Visual Studio (such as MSVC v141 - VS 2017 C++ x64/x86 build tools (v14.16)), uninstalling and reinstalling everything, and restarting my computer but keep getting the error.

I think for older VS versions you need to add the architecture, e.g.

cmake -G “Visual Studio 15 2017 Win64” -DBUILD_SHARED_LIBS=ON -Bbuild/default -H.

Thank you for the response. However, that command introduced its own error: “Does not match the generator used previously, Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory”. After removing the txt file and directory, I received the original error “could not find any instance of Visual Studio”. See picture below.

Any help would be much appreciated.

Never mind, I just had to install Visual Studio 2017 rather than 2019 and it worked. However, I am now having trouble locally installing the SDK. I am trying to call this command:
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=install -Bbuild/default -H.
in order to install this into my install folder but I get the following error saying it failed to build:

Someone had the same issue here: https://github.com/mavlink/MAVSDK/issues/800

They resolved it but unfortunately did not say how :frowning:.

Thanks for the link, I actually followed some steps in the thread and got farther than I was. However, I am running into an issue with CURL. This is the code I have run so far:

git clone https://github.com/mavlink/MAVSDK.git
cd MAVSDK
git checkout develop
git submodule update --init --recursive
cmake -G "Visual Studio 15 2017" -A x64 -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=install -Bbuild/default -H.)
cmake --build build/default --target install

At first, the cmake -G command produced the error: Could not find a configuration file for package “CURL” that is compatible with requested version " ". So I edited the CMakeLists.txt file and changed find_package(CURL REQUIRED CONFIG) to find_package(CURL REQUIRED Config) and the code ran without error. However, now the final cmake command is producing a large error with curl wrapper objects. I could not snip all of it but I will add a picture below. Any help would be great.


I don’t think that your change (CONFIG -> Config) fixed the error, but just allowed you to go further before the crash.

Can you try a clean build (remove build/default) with the same commands as you mentioned, but with -DBUILD_SHARED_LIBS=OFF?

Having similar problems. Any update on solution?

@Siamak_Samie What are similar problems? Can you paste your output? What have you tried?

Hi, I have similar problems
I tried to clean, rebuild but stil having this :
error: patch failed: CMakeLists.txt:148
error: CMakeLists.txt: patch does not apply
error: patch failed: src/lib_json/CMakeLists.txt:69
error: src/lib_json/CMakeLists.txt: patch does not apply
CMakeFiles\jsoncpp.dir\build.make:118: recipe for target ‘jsoncpp/src/jsoncpp-stamp/jsoncpp-patch’ failed.
I don’t know what to try anymore, some ideas ?

Do you remember what settings you chose when installing git on Windows?

image

I don’t remember, but I chose the default one, if you know which one it is, it could help me.

I fear that if you checkout Windows-style, then the patch might not apply. If you checkout as-is then it will.

It doesn’t work even changing git parameters…

Here is what I get…
– Preparing external project “jsoncpp” with args:
– -- -DBUILD_SHARED_LIBS=ON
– -- -DCMAKE_BUILD_TYPE=Release
– -- -DCMAKE_INSTALL_PREFIX=install
– -- -DCMAKE_RC_COMPILER_WORKS=1
– -- -DPC_JSONCPP_CFLAGS=
– -- -DPC_JSONCPP_CFLAGS_I=
– -- -DPC_JSONCPP_CFLAGS_OTHER=
– -- -DPC_JSONCPP_FOUND=
– -- -DPC_JSONCPP_INCLUDEDIR=
– -- -DPC_JSONCPP_LIBDIR=
– -- -DPC_JSONCPP_LIBS=
– -- -DPC_JSONCPP_LIBS_L=
– -- -DPC_JSONCPP_LIBS_OTHER=
– -- -DPC_JSONCPP_LIBS_PATHS=
– -- -DPC_JSONCPP_MODULE_NAME=
– -- -DPC_JSONCPP_PREFIX=
– -- -DPC_JSONCPP_STATIC_CFLAGS=
– -- -DPC_JSONCPP_STATIC_CFLAGS_I=
– -- -DPC_JSONCPP_STATIC_CFLAGS_OTHER=
– -- -DPC_JSONCPP_STATIC_LIBDIR=
– -- -DPC_JSONCPP_STATIC_LIBS=
– -- -DPC_JSONCPP_STATIC_LIBS_L=
– -- -DPC_JSONCPP_STATIC_LIBS_OTHER=
– -- -DPC_JSONCPP_STATIC_LIBS_PATHS=
– -- -DPC_JSONCPP_VERSION=
CUSTOMBUILD : error : patch failed: CMakeLists.txt:148 [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\third_party\jsoncpp\jsoncpp.vcxproj]
CUSTOMBUILD : error : CMakeLists.txt: patch does not apply [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\third_party\jsoncpp\jsoncpp.vcxproj]
CUSTOMBUILD : error : patch failed: src/lib_json/CMakeLists.txt:69 [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\third_party\jsoncpp\jsoncpp.vcxproj]
CUSTOMBUILD : error : src/lib_json/CMakeLists.txt: patch does not apply [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\third_party\jsoncpp\jsoncpp.vcxproj]
CMake Error at third_party/cmake/build_target.cmake:48 (message):
C:/Users/rlan-douds-pontarlie/MAVSDK/build/default/third_party/jsoncpp
failed to build!
Call Stack (most recent call first):
third_party/CMakeLists.txt:10 (build_target)

Here is the result of the previous command, I do not see errors so it might be ok : Completed ‘curl’
Building Custom Rule C:/Users/rlan-douds-pontarlie/MAVSDK/third_party/curl/CMakeLists.txt
– Looking for pthread.h
– Looking for pthread.h - not found
– Found Threads: TRUE
– Found curl via config file: C:/Users/rlan-douds-pontarlie/MAVSDK/build/default/third_party/install/lib/cmake/CURL
– Found tinyxml2 via config file: C:/Users/rlan-douds-pontarlie/MAVSDK/build/default/third_party/install/lib/cmake/tinyxml2
– Version: 0.28.0-4-g8e2a5815
– Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
– Found JsonCpp: C:/Users/rlan-douds-pontarlie/MAVSDK/build/default/third_party/install/lib/jsoncpp.lib
– Found PythonInterp: C:/Users/rlan-douds-pontarlie/AppData/Local/Programs/Python/Python38-32/python.exe (found version “3.8.3”)
– Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
– BUILD_BACKEND not set: not building grpc backend
– Configuring done
– Generating done
– Build files have been written to: C:/Users/rlan-douds-pontarlie/MAVSDK/build/default
PS C:\Users\rlan-douds-pontarlie\MAVSDK> cmake --build build/default --config Debug

btw, my commands are :
cmake -G “Visual Studio 16 2019” -D BUILD_SHARED_LIBS=OFF -B build/default
then cmake --build build/default --config Debug
and finally cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -D CMAKE_INSTALL_PREFIX=install -B build/default
I do not use -H. because windows don’t recognize it.
Tried same in cmd using -H. but still getting same errors.

Ok, and you tried a clean build where you remove the build dir and try again?

I tried to clean but I don’t know the exact command to do it…
C:\Users\rlan-douds-pontarlie\MAVSDK>git rm -rf build/default
fatal: pathspec ‘build/default’ did not match any files

You either just go to the folder and delete it manually, or you do:

rd /s /q build

C:\Users\rlan-douds-pontarlie\MAVSDK>rd /s /q build
Le répertoire n’est pas vide.

(The repertory is not empty)

And I deleted and reinstalled it like 10times manually…

[EDIT] Ok, it compiled totally so it’s better but i got a lot of errors during the procedure…

jsoncpp.lib(json_value.obj) : error LNK2038: discordance détectée pour ‘_ITERATOR_DEBUG_LEVEL’ : la valeur ‘0’ ne corre
spond pas à la valeur ‘2’ in mission.obj [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\src\plugins\mission\mavsdk
_mission.vcxproj]
jsoncpp.lib(json_value.obj) : error LNK2038: discordance détectée pour ‘RuntimeLibrary’ : la valeur ‘MD_DynamicRelease’
ne correspond pas à la valeur ‘MDd_DynamicDebug’ in mission.obj [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\sr
c\plugins\mission\mavsdk_mission.vcxproj]
jsoncpp.lib(json_reader.obj) : error LNK2038: discordance détectée pour ‘_ITERATOR_DEBUG_LEVEL’ : la valeur ‘0’ ne corr
espond pas à la valeur ‘2’ in mission.obj [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\src\plugins\mission\mavsd
k_mission.vcxproj]
jsoncpp.lib(json_reader.obj) : error LNK2038: discordance détectée pour ‘RuntimeLibrary’ : la valeur 'MD_DynamicRelease
’ ne correspond pas à la valeur ‘MDd_DynamicDebug’ in mission.obj [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\s
rc\plugins\mission\mavsdk_mission.vcxproj]
jsoncpp.lib(json_writer.obj) : error LNK2038: discordance détectée pour ‘_ITERATOR_DEBUG_LEVEL’ : la valeur ‘0’ ne corr
espond pas à la valeur ‘2’ in mission.obj [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\src\plugins\mission\mavsd
k_mission.vcxproj]
jsoncpp.lib(json_writer.obj) : error LNK2038: discordance détectée pour ‘RuntimeLibrary’ : la valeur 'MD_DynamicRelease
’ ne correspond pas à la valeur ‘MDd_DynamicDebug’ in mission.obj [C:\Users\rlan-douds-pontarlie\MAVSDK\build\default\s
rc\plugins\mission\mavsdk_mission.vcxproj]

[EDIT] I think it’s working, thanks for all