Reputation: 570
Specifically, the warnings are:
4>Comctl32.lib(COMCTL32.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in d3d11.lib(d3d11.dll); second definition ignored
4>D3DCompiler.lib(D3DCOMPILER_47.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in d3d11.lib(d3d11.dll); second definition ignored
4>dwmapi.lib(dwmapi.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in d3d11.lib(d3d11.dll); second definition ignored
From what I have read online this means I have linked d3d11.lib
more than once.
What I am doing is I am linking Comctl32.lib
D3DCompiler.lib
d3d11.lib
and dwmapi.lib
to a static library, and then linking that static library (and nothing else) in another executable. The warning only occurs when building the static library and it does not occur when building the executable. I know that this would probably not affect anything, but it is good to just get rid of all warnings.
I am using Visual Studio with solutions generated by Premake. There shouldn't be anything in the Premake side of things that change things because the aforementioned libs are just listed in the Additional Dependencies field of the property pages. I have checked that I have not listed anything in the Additional Dependencies field of the executable.
I know that I probably did not include as much information as needed to definitively solve the problem, but any tips to point me to the right direction will be great. Thank you!
Upvotes: 1
Views: 677
Reputation: 111
Although Microsoft Visual Studio allows a static library to be linked to other static libraries via the Librarian property pages, LNK4006 errors are inevitable when you do this.
The correct way to do it is to first remove all Additional Dependencies from the static library's Librarian properties. Instead, add the following pragmas to your static library's "public" header file:
#pragma comment(lib,"comctl32.lib")
#pragma comment(lib,"d3d11.lib")
#pragma comment(lib,"d3dcompiler.lib")
#pragma comment(lib,"dwmapi.lib")
Compile your static library for each configuration and platform.
In your executable project properties:
C/C++ - General - Additional Include Directories
Linker - General - Additional Library Directories
Linker - Input - Additional Dependencies
You can now compile your project without LNK4006 warnings.
Note: the Linker properties must be repeated for each configuration and platform.
Upvotes: 3