i'm trying to switch from a large Visual Studio-based project (with static, dynamic libraries, executables) to CMake. It would work well, but as many of the static libraries have export libraries (without the need of linking the library to the project), i need a way to include project's interfaces only without linking the static library.
Situation:
CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(Test)
add_subdirectory(Projekt_B)
add_subdirectory(Projekt_A)
Projekt_A/CMakeLists.txt
add_library(Projekt_A
libraryContent.cpp
libHeader.h
libInterfaceOnly.h)
target_include_directories(Projekt_A PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
# could be **INTERFACE** as well
Projekt_B/CMakeLists.txt
add_library(Projekt_B_Public SHARED
libraryContentB.cpp
libHeaderB.h
)
add_library(Projekt_B_Private SHARED
libraryContentB.cpp
libHeaderB.h
)
add_library(Projekt_B_Interface SHARED
libraryContentB.cpp
libHeaderB.h
)
## this Line works but links Projekt_A
target_link_libraries(Projekt_B_Public PUBLIC Projekt_A)
## this Line works too, but links Projekt_A to it without passing them on
target_link_libraries(Projekt_B_Private PRIVATE Projekt_A)
## this Line works **only** if no interface of A is used in B
target_link_libraries(Projekt_B_Interface INTERFACE Projekt_A)
So, all targets compile when no interface of Projekt_A was used in Projekt_B_. When I include a header (which has been exported via traget_include_directories), Projekt_B_Interface won't link anymore.
MsBuild tells for Projekt_B_Interface:
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\CL.exe
/c /Zi /nologo /W3 /WX- /Od /Ob0 /D WIN32 /D _WINDOWS /D _DEBUG /D
"CMAKE_INTDIR=\"Debug\"" /D Projekt_B_Interface_EXPORTS /D _WINDLL /D
_MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope
/Fo"Projekt_B_Interface.dir\Debug\\"
/Fd"Projekt_B_Interface.dir\Debug\vc120.pdb" /Gd /TC /errorReport:queue
D:\Develop\CMake\TEST\Projekt_B\libr.c
libr.c
D:\Develop\CMake\TEST\Projekt_B\libr.c(2): fatal error C1083: Cannot open include file:
'libinc.h': No such file or directory
[D:\Develop\CMake\TEST\build\Projekt_B\Projekt_B_Interface.vcxproj]
Within the other Projekt_B_* projects it's successfull:
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\CL.exe
/c /ID:\Develop\CMake\TEST\Projekt_A /Zi /nologo /W3 /WX- /Od /Ob0 /D
WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR=\"Debug\""
/D Projekt_B_Public_EXPORTS /D _WINDLL /D _MBCS /Gm- /RTC1 /MDd /GS
/fp:precise /Zc:wchar_t /Zc:forScope /Fo"Projekt_B_Public.dir\Debug\\"
/Fd"Projekt_B_Public.dir\Debug\vc120.pdb" /Gd /TC /errorReport:queue
D:\Develop\CMake\TEST\Projekt_B\libr.c
libr.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\link.exe
/ERRORREPORT:QUEUE /OUT:"D:\Develop\CMake\TEST\build\
Projekt_B\Debug\Projekt_B_Public.dll" /INCREMENTAL /NOLOGO
kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
..\Projekt_A\Debug\Projekt_A.lib /MANIFEST
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG
/PDB:"D:/Develop/CMake/TEST/build/Projekt_B/Debug/Projekt_B_Public.pdb"
/SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT
/IMPLIB:"D:/Develop/CMake/TEST/build/Projekt_B/Debug/Projekt_B_Public.lib"
/MACHINE:X64 /machine:x64 /debug /DLL Projekt_B_Public.dir\Debug\libr.obj
Projekt_B_Public.vcxproj -> D:\Develop\CMake\TEST\build\Projekt_B\Debug\
Projekt_B_Public.dll
Any ideas how I could get something like:
target_compile_libraries(Projekt_B HEADERS Projekt_A)
(something that target_include_directoies would sound like...)
I think I've found a solution for this situation (without the need of settings vars in CMake):
Projekt_A/CMakeLists.txt:
...
# create a interface
add_library(IProjekt_A INTERFACE)
# add *export* headers to interface
target_include_directories(IProjekt_A INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
# bind interface to project itself (just in case)
target_link_libraries(Projekt_A INTERFACE IProjekt_A)
Projekt_B/CMakeLists.txt
...
# this will add includes *only* and reexports them within Projekt_B
target_link_libraries(Projekt_B PUBLIC IProjekt_A)
# this will add includes and library for link and reexport
target_link_libraries(Projekt_B PUBLIC Projekt_A)
# this will only add the includes for *this* project
target_link_libraries(Projekt_B PRIVATE IProjekt_A)
This makes it possible to export the headers in the build environment. Very usefull in large projects.
I'll hope it helps someone else either!
Cheers.
Related
I'm trying to compile the following DLL code:
int* ptr;
DLLExport int add(int a, int b)
{
ptr = (int*)malloc(10 * sizeof(int));
free(ptr);
return (a + b + 6);
}
This DLL works fine when compiled with Visual Studio, but crashes on the malloc() call when compiled with mingw/gcc.
However the following code works with both compilers:
DLLExport int add(int a, int b)
{
int* ptr;
ptr = (int*)malloc(10 * sizeof(int));
free(ptr);
return (a + b + 6);
}
It also works with both compilers when I define the var as static, however that var needs to be extern and used in multiple files, so it can't be static. I tried setting it to volatile, but it didn't help.
I'm loading the DLL with Unity and it crashes with the following error:
Received signal SIGSEGV
Stack trace:
RtlLookupFunctionEntry returned NULL function. Aborting stack walk.
0x0000020f7d1669b0 (cygwin1) lfind
0x0000020f7d1c5c6b (cygwin1) acl_get_perm
<Missing stacktrace information>
cygwin1.dll is a dependency that I need to also add for the mingw DLL to be loaded (but I don't need to add any other DLLs when compiling with VC).
This is the Makefile I use for mingw:
all:
g++ -c -o dll.o dll.cpp -O0
g++ -c -o pch.o pch.cpp
g++ -shared -o dll.dll ./dll3.o ./pch.o
My guess is that I'm missing some g++ flags, but I can't figure out which ones (I tried many).
And these are some of the command lines that the VC compiler uses:
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\CL.exe /c /ZI /JMC /nologo /W3 /WX- /diagnostics:column /sdl /Od /D _DEBUG /D DLL2_EXPORTS /D _WINDOWS /D _USRDLL /D _WINDLL /D _UNICODE /D UNICODE /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /permissive- /Zc:wchar_t /Zc:forScope /Zc:inline /Yc"pch.h" /Fp"x64\Debug\Dll2.pch" /Fo"x64\Debug\\" /Fd"x64\Debug\vc142.pdb" /external:W3 /Gd /TP /FC /errorReport:prompt pch.cpp
...
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Tracker.exe /d "C:\Program Files (x86)\MSBuild\15.0\FileTracker\FileTracker32.dll" /i ...\Dll2\x64\Debug\Dll2.tlog /r ...\DLL2\PCH.CPP /b MSBuildConsole_CancelEvent806a58ad24214fb9a0f508edf8dd6bea /c "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\CL.exe" /c /ZI /JMC /nologo /W3 /WX- /diagnostics:column /sdl /Od /D _DEBUG /D DLL2_EXPORTS /D _WINDOWS /D _USRDLL /D _WINDLL /D _UNICODE /D UNICODE /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /permissive- /Zc:wchar_t /Zc:forScope /Zc:inline /Yc"pch.h" /Fp"x64\Debug\Dll2.pch" /Fo"x64\Debug\\" /Fd"x64\Debug\vc142.pdb" /external:W3 /Gd /TP /FC /errorReport:prompt pch.cpp
...
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\link.exe /ERRORREPORT:PROMPT /OUT:"...\Dll2\x64\Debug\Dll2.dll" /INCREMENTAL /ILK:"x64\Debug\Dll2.ilk" /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:NO /manifest:embed /DEBUG /PDB:"...\Dll2\x64\Debug\Dll2.pdb" /SUBSYSTEM:WINDOWS /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"...\Dll2\x64\Debug\Dll2.lib" /MACHINE:X64 /DLL x64\Debug\dllmain.obj
Many thanks in advance for any tips!
I'm trying to generate a DLL based on existing software pieces compiled in a static library (.lib) file. I'm using Visual Studio 2019, and the target is purely Windows.
The existing project (P1) have the following function :
int runLocal();
It's compiled to P1.lib.
In my new DLL project (P2), I have the following code :
#include "..\path\to\P1.h" // declaration of "int runLocal()"
extern "C" __declspec(dllexport) int __stdcall DLLMain() {
int res = runLocal();
std::cout << res << std::endl;
}
Project P2 (DLL) have following linker options :
Additional dependencies: D:\path\to\P1.lib;%(AdditionalDependencies)
However the linker "refuse" to see or use the lib file, and I get this error :
LNK2001 unresolved external symbol "int __stdcall runLocal(void)" (?runLocal##YGHXZ).
In fact, I get excatly the same error if I didn't tell the linker to use P1.lib file.
I have control over all the project sources, so I can change stuffs where it's necessary.
Note 1: The P2 project is used by a debug application (a third project compiled separately) that use LoadLibrary() to run the exported DLLMain function.
Note 2: I already succeeded in compiling an exe file against the same .lib file using the same method. So the difference seems to be in the DLL generation.
Note 3: I tried (without success) to play with many options in Visual project properties, in both compiler & linker section, at least the options that are not beyond my understanding.
So, what should I do to link correctly the .lib file and create my dll ?
Edit 1: I add the compiler & linker options:
P1 compiler options:
/permissive- /GS /TP /GL /analyze- /W3 /Gy /Zc:wchar_t
/I"C:\_tools\boost_1_68_0\" /I"C:\_tools\cryptopp_8_2_0\"
/Qspectre /guard:cf /Zi /Gm- /O2 /sdl /Fd"tmp_Win32_Release\p1.pdb" /Zc:inline
/fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_WARNINGS"
/D "_UNICODE" /D "UNICODE" /D "_AFXDLL"
/errorReport:prompt /WX- /Zc:forScope /Gd /Oy /Oi /MD /std:c++17 /FC
/Fa"tmp_Win32_Release\" /EHsc /nologo
/Fo"tmp_Win32_Release\" /Ot /Fp"tmp_Win32_Release\p1.pch" /diagnostics:column
P1 librarian options:
/OUT:"D:\Projets\XL4DLL\Common\p1.lib" /LTCG /MACHINE:X86 /SUBSYSTEM:WINDOWS /NOLOGO
Checked with dumpbin.exe as suggested, and the symbol "?runLocal##YGHXZ" exists in p1.lib
P2 compiler options:
/permissive- /MP /GS /TP /GL /analyze- /W3 /Gy /Zc:wchar_t
/I"C:\_tools\boost_1_68_0\" /I"C:\_tools\cryptopp_8_2_0\"
/Qspectre /guard:cf /Zi /Gm- /O2 /sdl /Fd"tmp_Win32_Release\vc142.pdb"
/Zc:inline /fp:precise /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL"
/D "_WINDLL" /D "_UNICODE" /D "UNICODE"
/errorReport:prompt /WX- /Zc:forScope /Gz /Oy /Oi /MD /std:c++17 /FC
/Fa"tmp_Win32_Release\" /EHsc /nologo /Fo"tmp_Win32_Release\" /Ot
/Fp"tmp_Win32_Release\XL4DLL32.pch" /diagnostics:column
P2 linker options:
/OUT:"D:\Projets\XL4DLL\Release\XL4DLL32.dll" /MANIFEST /LTCG:incremental
/NXCOMPAT /PDB:"D:\Projets\XL4DLL\Release\XL4DLL32.pdb" /DYNAMICBASE
"D:\Projets\XL4DLL\Common\p1.lib" "D:\Projets\XL4DLL\Common\SharedToolsLib32.lib"
"kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib"
"advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib"
"odbc32.lib" "odbccp32.lib"
/IMPLIB:"D:\Projets\XL4DLL\Release\XL4DLL32.lib" /DLL /MACHINE:X86
/OPT:REF /SAFESEH /INCREMENTAL:NO /PGD:"D:\Projets\XL4DLL\Release\XL4DLL32.pgd"
/SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"tmp_Win32_Release\XL4DLL32.dll.intermediate.manifest"
/OPT:ICF /ERRORREPORT:PROMPT /NOLOGO
/LIBPATH:"C:\_tools\boost_1_68_0\stage\lib" /TLBID:1
There is another difference between P1 and P2 projects configuration:
P1 is configured to use "Use MFC in a Shared DLL"
P2 is configured to use "Use Standard Windows Libraries", because it requires the use of Windows.h header and uses symbols not defined with MFC usage.
I need to compile a program automatically with different platform toolsets. The compilation is done using cl.exe and link.exe like so:
cl.exe file.c /GS- /PlatformToolset=vc140xp /analyze- /W3 /Gy /Zc:wchar_t /Gm- /Od /Zc:inline /fp:precise /D \"WIN32\" /D \"_WINDOWS\" /D \"_UNICODE\" /D \"UNICODE\" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /Fa\"\" /EHsc /nologo /Fo\"\" /Fp\"\" /diagnostics:classic /link %link_additional% /ENTRY:wWinMain /SUBSYSTEM:WINDOWS /MANIFEST:EMBED /NXCOMPAT /DYNAMICBASE \"kernel32.lib\" \"user32.lib\" \"gdi32.lib\" \"winspool.lib\" \"comdlg32.lib\" \"advapi32.lib\" \"shell32.lib\" \"ole32.lib\" \"oleaut32.lib\" \"uuid.lib\" \"odbc32.lib\" \"odbccp32.lib\" /DEBUG:NONE /MACHINE:%arch% /OPT:REF /SAFESEH /INCREMENTAL:NO /SUBSYSTEM:WINDOWS /MANIFESTUAC:\"level = 'asInvoker' uiAccess = 'false'\" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1\
I'm using the switch /PlatformToolset=vc140xp but, the cl.exe doesn't seem to reconginze it, i get an error:
Unknown Option: /PlatformToolset
Is there a way you can change toolset using cl.exe, without msbuild and vcproj ?
Just incase someone need it, i was able to solve this isuue. i added this option to cl.exe:
/D \"_USING_V110_SDK71_\"
And also i modified this option:
/SUBSYSTEM:WINDOWS
to
/SUBSYSTEM:WINDOWS,5.01
After the application runs succesfully on windows xp. You might encounter some problems if you are heavily useing crt in your exe, in my exe i only needed CRT to define Tls callbacks, they do not work without CRT, so i guess maybe this is why this worked for me
I have an MFC solution with 17 sub-projects. I just recently added another dll project and cannot get the executable to link to the renamed version of the library. In the settings for the dll projects in the solution, debug builds all have a 'D' appended to the output name to signify that it's the debug version. In some cases, we do that by changing the TargetName to $(ProjectName)D, and in other cases a post build event copies it from the build directory to the lib directory and renames it appending the 'D'. For this project, when I compile the dll I get the two files as expected: MultiLangD.lib and MultiLangD.dll. This is the linker command line for the dll project:
/OUT:".\Debug\MultiLangD.dll" /NOLOGO /DLL /MANIFEST
/ManifestFile:".\Debug\MultiLangD.dll.intermediate.manifest" /ALLOWISOLATION
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG
/PDB:"C:\WorkSpaces\WorkSpace_CFFT_II_i18n\CFFT_i18n_MBCS\CFFT\MultiLang\Debug\MultiLangD.pdb"
/PGD:"C:\WorkSpaces\WorkSpace_CFFT_II_i18n\CFFT_i18n_MBCS\CFFT\MultiLang\Debug\MultiLangD.pgd"
/TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\Debug\MultiLangD.lib" /MACHINE:X86
/ERRORREPORT:QUEUE
This is the compiler command line for the dll project:
/ZI /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_AFXEXT" /D
"_MULTILANGDLL" /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL" /D "_MBCS" /D "_AFXDLL" /Gm
/EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR- /Yu"StdAfx.h"
/Fp".\Debug\MultiLangD.pch" /Fa".\Debug\" /Fo".\Debug\" /Fd".\Debug\vc100.pdb" /Gd
/analyze- /errorReport:queue
In the executable project I list MultiLangD.lib as an additional dependency to the linker, set "Link Library Dependencies" to no, and "Use Library Dependency Inputs" to yes. The MultiLang dll project is not set as a project dependency to the executable. Nevertheless, in the debug build, I get an error because the linker cannot find MultiLang.lib. This is the linker command line of the executable project:
/OUT:".\Debug\WinGFApp.exe" /INCREMENTAL /NOLOGO /LIBPATH:"..\Lib"
/LIBPATH:"..\Student\lib" /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (March 2009)\Lib\x86"
"MultiLangD.lib" "datastored.lib" "shlwapi.lib" "ws2_32.lib" "MdxReadd.lib" "winmm.lib"
"dxguid.lib" "dxerr9.lib" "dinput8.lib" "Messagingd.lib" "dtccd.lib" "Version.lib"
"SerialTCIMD.lib" "geosrvdll.lib" "NetworkUIDMD.lib" "amp2.lib" "idmmib.lib"
"vmfr2.lib" "d3dx9.lib" "comsuppwd.lib" "vmf_net_db.lib" "jvmfd.lib"
/NODEFAULTLIB:"libc" /NODEFAULTLIB:"libcd" /NODEFAULTLIB:"libci" /MANIFEST
/ManifestFile:".\Debug\WinGFApp.exe.intermediate.manifest" /ALLOWISOLATION
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:".\Debug/CFFTInstrD.pdb"
/SUBSYSTEM:WINDOWS
/PGD:"C:\WorkSpaces\WorkSpace_CFFT_II_i18n\CFFT_i18n_MBCS\CFFT\Instructor\Debug\WinGFApp.pg
d" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
This is the compiler command line:
/I"." /I"..\Instructor\csw" /I"..\Instructor\CFFTInstr" /I"..\Student\common"
/I"..\Student\Messaging" /I"..\Student\geotrans" /I"..\SerialTcim" /I"..\AudioServer"
/I"..\NetworkUIDM\UIDM_Include" /I"..\NetworkUIDM\UIDM_JVMF" /I"..\NetworkUIDM"
/I"..\Instructor\cas" /I"..\Jvmf" /I"..\Instructor\JvmfGui" /I"..\Instructor\JvmfCff"
/I"..\NLOS" /I"C:\Program Files (x86)\Microsoft DirectX SDK (March 2009)\Include" /Zi
/nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "NO_MSGS" /D
"INSTRUCTOR" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES"
/D "_CRT_NONSTDC_NO_DEPRECATE" /D "_VC80_UPGRADE=0x0600" /D "_MBCS" /Gm- /EHsc /RTC1
/MTd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yu"stdafx.h" /Fp".\Debug/WinGFApp.pch"
/Fa".\Debug/" /Fo".\Debug/" /Fd".\Debug/" /FR".\Debug\" /Gd /analyze-/errorReport:queue
When I open the .vcxproj file in np++ and search for MultiLang.lib it only appears as a dependency in the release build, while in the debug build settings MultiLangD.lib is listed. This is the debug settings ItemDefinitionGroup node from the .vcxproj file:
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>true</MkTypLibCompatible>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetEnvironment>Win32</TargetEnvironment>
<TypeLibraryName>.\Debug/WinGFApp.tlb</TypeLibraryName>
<HeaderFileName>
</HeaderFileName>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\Instructor\csw;..\Instructor\CFFTInstr;..\Student\common;..\Student\Messaging;..\Student\geotrans;..\SerialTcim;..\AudioServer;..\NetworkUIDM\UIDM_Include;..\NetworkUIDM\UIDM_JVMF;..\NetworkUIDM;..\Instructor\cas;..\Jvmf;..\Instructor\JvmfGui;..\Instructor\JvmfCff;..\NLOS;C:\Program Files %28x86%29\Microsoft DirectX SDK %28March 2009%29\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;NO_MSGS;INSTRUCTOR;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\Debug/WinGFApp.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
<ObjectFileName>.\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
<BrowseInformation>true</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>MultiLangD.lib;datastored.lib;shlwapi.lib;ws2_32.lib;MdxReadd.lib;winmm.lib;dxguid.lib;dxerr9.lib;dinput8.lib;Messagingd.lib;dtccd.lib;Version.lib;SerialTCIMD.lib;geosrvdll.lib;NetworkUIDMD.lib;amp2.lib;idmmib.lib;vmfr2.lib;d3dx9.lib;comsuppwd.lib;vmf_net_db.lib;jvmfd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\Lib;..\Student\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28March 2009%29\Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;libcd;libci;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\Debug/CFFTInstrD.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>Debug/CFFTInstrD.bsc</OutputFile>
</Bscmake>
<PostBuildEvent>
<Message>Copy Executable</Message>
<Command>if not exist ..\exec mkdir ..\exec
copy debug\WinGFApp.exe ..\exec\CFFTInstrD.exe
</Command>
</PostBuildEvent>
<ProjectReference />
<ProjectReference>
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
Unfortunately, all the executables and dlls generated are copied to a single directory as post build events, so I have to follow the "append D" naming convention to avoid overwriting artifacts from other builds. I'm not sure why none of the other dll projects in the build have this problem. I am obviously missing something here but cannot figure out what it is. Can someone please enlighten me on what I'm doing wrong and how to accomplish this. Thanks.
EDIT
I forgot to mention that I have also tried adding a reference to the project in Common Properties->Framework and References.
Also, while the compilation is under way I see Automatically linking with MultiLang.lib scroll by.
Ok, I got it working. I removed the reference and set Linker->General->Ignore Import Library to Yes. I left everything else the same and now it compiles and links just fine.
I'm new to Visual Studio and Windows as a development platform, and I'm having troubles linking a static library from one 'Project' into an executable in another. The library builds without error, but linking bails after finding several STL template instantiations defined in the library.
For the purpose of this question, Project A builds a static library, which I then attempt to link with in Project B.
I'm hoping someone can point out what I'm missing here.
The build command line for Project A:
/Od <includes> /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32_WINNT=0x0501" /D "DEBUG" /D "WS4_WIN32" /D "AF" /D "_VC80_UPGRADE=0x0710" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /Wp64 /ZI /TP /wd4290 /errorReport:prompt
The build and link command lines for Project B:
/Od <includes> /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /wd4290 /errorReport:prompt
/OUT:<exe name> /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"<exe name>.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:<pdb name> /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib <Project A Lib file>
When the linker runs, I get a ton of errors of the following form:
msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "<some STL template instantiation>" (<mangled name>) already defined in <Project A>.lib(<some Project A object>.obj)
I think this is telling me that an STL instantiation defined in an object of my library is also defined in msvcprtd.lib. What's not clear to me is if I'm not building my static library correctly, or if my linker settings are wrong. I would appreciate any guidance on this.
You have mismatching runtime libraries specified.
It is set to /MTd for project A and /MDd for project B.
/MTd - Multithreaded Debug
/MDd - Multithreaded Debug DLL