Set up additional include paths and library paths
-
Hello,
I wanted to develop a small program for Microsoft Flight Simulator (2020) with SimConnect.
In Visual Studio I could just- add an additional include path (which is $(MSFS_SDK)\SimConnect SDK\include where MSFS_SDK is a PATH var) in project settings -> C/C++
- add a library path in project settings -> Linker -> common (which is $(MSFS_SDK)\SimConnect SDK\lib)
- add additional dependencies in project settings -> Linker -> input (which are SimConnect.lib; shlwapi.lib; user32.lib; Ws2_32.lib;)
After several hours of googling and trial and error I'm still not able to include any of it. I've seen that with qmake I could add additional libraries but I would have to specify a path for each indiviual library (I only know the path for SimConnect.lib, I assume the rest are system libraries).
It shouldn't be a big difference but I tried to stick to cmake as the SDK suggests and I couldn't find any GUI solution (like in VS) to implement those additions I need.I've tried to include the path for SimConnect.h with
target_include_directories(FlyShare PRIVATE "${MSFS_SDK}/SimConnect SDK/include")
and with
include_directories("${MSFS_SDK}/SimConnect SDK/include")
but with neither I am actually able to use#include "SimConnect.h"
as it cannot be found. How to include the .libs is even more beyond my understanding.Is there a way to include above mentioned additions in an easy way like in VS I didn't find yet?
If it has to be done via file edits (CMakeLists.txt) could perhaps somebody point out for me how to do this?
I couldn't find any solution on the web how to do this properly.Link to MSFS SDK Docs that show the setup in VS: https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_SDK.htm
(scroll down to C/C++ projects)Thanks in advance,
Phil -
@Phil7789 said in Set up additional include paths and library paths:
${MSFS_SDK}
This is wrong - see the cmake documentation on how to read anvironment variables.
-
Oh I misinterpreted the part of solution I found on SO. I thought Cmake would resolve vars without the addition of ENV. Thank you.
With your hint I managed to include the header file, but only when using
include_directories()
.
When I useinclude_target_directories(myProject PRIVATE "$ENV{MSFS_SDK}\\SimConnect SDK\\include")
(which is below qt_add_executable(...)) the header file is not found again.
I've also tried to add atarget_link_directories()
just to be sure.Are shlwapi.lib; user32.lib; Ws2_32.lib; automatically included in Qt or do I have to specify the full path for them too (I assume they're all system32 libs)?
-
@Phil7789 said in Set up additional include paths and library paths:
include_target_directories
it's target_include_directories(), also please try with forward slashes
Are shlwapi.lib; user32.lib; Ws2_32.lib; automatically included in Qt or do I have to specify the full path for them too (I assume they're all system32 libs)?
Not by Qt, but the default linker search path.