Hi,
Yes, it is possible. For example my
WASimClient project can be built as a static or dynamic library, or used by simply including/building the code itself as part of another project.
There are probably a number of ways to go about this, and there may certainly be several "gotcha's" which are hard to predict w/out understanding your full project/solution configuration/setup.
You're building your project (the one that uses SimConnect) as a library?
And related, do you mean if you statically link to that library from a client program it works (the lib is built into the exe), but not if linking dynamically?
Or do you mean if you just build the exe including the lib's code directly (not building a library at all)?
Can you post an example of what you've already tried?
Personally I like building my library using the SimConnect static lib -- that way SimConnect.dll isn't required at runtime (it's built into the exe/lib which uses SimConnect). This is somewhat besides the point, but my examples below use this method, so it may vary if linking to SimConnect dynamically.
Note that Ws2_32 and Shlwapi libraries are required for SimConnect to work properly. So either the dynamic versions need to be in the runtime path, or the static versions need to be linked in at build time (as in the examples below).
Here are some possibly-relevant entries for building a DLL from the WASimClient project file. These are specifically for a "Release DLL" configuration I have set up for the project. See above link for the full file.
XML:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-DLL|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<!-- etc ... -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-DLL|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir);$(MSFS_SDK)\SimConnect SDK\include;$(IncludePath)</IncludePath>
<LibraryPath>$(MSFS_SDK)\SimConnect SDK\lib\static;$(LibraryPath)</LibraryPath>
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
<CopyLocalProjectReference>true</CopyLocalProjectReference>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-DLL|x64'">
<ClCompile>
<!-- this is all pretty much standard config stuff, not unique to DLL vs. static -->
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE_DEBUG;_WINDOWS;_USRDLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<CallingConvention>StdCall</CallingConvention>
</ClCompile>
<Link>
<SubSystem>NotSet</SubSystem> <!-- not "Windows" -->
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>SimConnect.lib;Ws2_32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<!-- dllmain is only required for a DLL build -->
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release-DLL|x64'">false</ExcludedFromBuild>
</ClCompile>
</ItemGroup>
Cheers,
-Max