microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++

Home Page:https://walbourn.github.io/directxtk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Static Compiling DirectXTK Nuget Package

Itsukan0 opened this issue · comments

Hello !

Thank you for the package, it is of great use to me !

Context :

I am using DirectXTK package as a nuget package. I tried using vcpkg to get a static version but there is an error message saying there is only a dynamic version. Thus I used the Nuget Package.
I want to use the following function : DirectX::CreateWICTextureFromFile()
Visual Studio Version : 2019
I have the include path properly set up and added the .lib to the linker entry.

Problem :

I am trying to compile statically and the linker asks for obj files.
errormessage

Question :

Is there a way to compile statically while using the Nuget Package ? Since You already provide .lib and headers only .obj files are missing, maybe there is a point in linking I didn't understand.

I know I can download the DirectXTK and fully compile it myself but I'll use it as a last resort.

Thank You for your help !

With NuGet, you should not need to add any .lib or include path explicitly as it's handled automatically. See the wiki.

The path you show isn't valid. The actual path that contains the lib is packages\directxtk_desktop_2015.2019.8.23.1\lib\x64\Debug\. You should remove whatever manual edits you made to the include/lib paths to include the NuGet and see if that helps.

Thanks for your reply !

I used another project to investigate this as for my first project I just compiled DXTK myself statically.

On this other sample project, when I set the compiling option "RunTime Library" in "Code Generation" to "MDd", it compiles just fine with the Nuget Package, but when I set it to "MTd", this error pops up :

errormessage2

This project has no manual modification regarding to lib files path and linker entry, so the automatic behavior should apply there.

Of course, between the switch, I cleaned and generated the project anew

I don't provide versions of my NuGet packages that link against the CRT statically. Generally you should always prefer to use the DLL version of the CRT. As you note, you can always build the code from source yourself if you have unusual requirements.