1
votes

I got the c++/cli dll to link to a vc++ dll, but when trying it with the static version of the vc++ lib there are a bunch of linker errors. I want to use static so I dont have to copy all of the other vc++ dll files into my main c# project, which uses the c++/cli dll.

The vc++ library has the following properties:
*built in vs2008
*Static library
*uses MFC in a static library
*No common language runtime support

the c++/cli library has these properties:
*built in vs2010
*Dynamic Library
*Use of MFC in a shared DLL
*Common Language Runtime Support
*linker->input contains the vc++ lib file

I tried linking the vc++ lib it after building it in vs2010 but that didn't help.

So I get like 90 LNK2005 errors like these from nafxcwd.lib:

1>nafxcwd.lib(dlgprop.obj) : error LNK2005: "public: struct _PROPSHEETPAGEA & __thiscall CPropertyPage::GetPSP(void)" (?GetPSP@CPropertyPage@@QAEAAU_PROPSHEETPAGEA@@XZ) already defined in mfc100d.lib(mfc100d.dll)

then like 30 or so of these: 1>libcmtd.lib(sprintf.obj) : error LNK2005: _sprintf already defined in msvcrtd.lib(MSVCR100D.dll)

then three LNK4098 warnings:

LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library 1>LINK : warning LNK4098: defaultlib 'nafxcwd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library 1>LINK : warning LNK4098: defaultlib 'libcmtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

then I get this last error: libcmtd.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup

I looked up the LNK4098 warning on msdn and the solution was to add the conflicting libraries to the IgnoreSpecific Default libraries entry in the linker input settings, but this did not help.

Thanks,
alex

1
try this: stackoverflow.com/questions/5127522/… in your's that would be 'libcmtd.lib'fazo
ok, i added libcmtd.lib and nafxcwd.lib to the ignore specific default libraries and those linker errors go away, but then i get these ones having to do with the vc++ lib, like this: 1>GuiD.lib(TreePropSheet.obj) : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CPropertySheet::classCPropertySheet" (?classCPropertySheet@CPropertySheet@@2UCRuntimeClass@@B)Alex

1 Answers

2
votes

You can't link (C++) libraries build with different version of the VS compiler (sometimes it may accidentally seem to work but you'll usually get hard to diagnose crashes later on). Additionally, your errors seem to be typical of selecting different CRT configurations (single/multi-threaded, debug/release etc).