LNK2001: using unmanangedC++ in manC++  
Author Message
unsigned int





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

Hi,

i'm writing a new user-interface for a small software-company. The old interface should be replaced by the new one, the "inner core" should stay.
The old program was written in unmanaged C++, but now I'm writing the user-interface in C#, so I have to use class wrappers.
While building the managed C++-project (in a solution with the unman. C++-projects) there a some errors.
For example:
Error error LNK2001: unresolved external symbol ___argv nafxcwd.lib
and
Error error LNK2001: unresolved external symbol ___argc nafxcwd.lib
Another one:
Error error LNK2001: unresolved external symbol __pgmptr db.lib
[db is one of the old unmanaged C++-projects]


The settings are the following:

Linker->Input->Add. Depencies: nafxcwd.lib odbc32.lib odbccp32.lib msvcrtd.lib
Linker->Input->Ignore sp. lib: nafxcwd.lib;Ws2_32.lib;libcmtd.lib

In Common Properties->References I reference to the used projects.

Thanks in advance!



Visual C++13  
 
 
unsigned int





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

Hi,

after some changes I'm getting now these errors:




Additional Depencies: nafxcwd.lib libcmtd.lib msvcrtd.lib
Ignore Specific Library: nafxcwd.lib;libcmtd.lib;msvcrtd.lib

Please help me,
thank you very much!


 
 
Mike Danes





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

Hmm... why do you have these libs in Additional Dependencies and Ignore Specifi Library The usage of these libraries is controled through other options like

Use of MFC in ConfigurationProperties\General

Common Language Runtime Support in ConfigurationProperties\General

Runtime Library in ConfigurationProperties\General\C/C++\Code Generation

In addition nafxcwd.lib is the static version of MFC and it does not work with the dynamic version of CRT and with /clr.


 
 
unsigned int





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

Hi,

thanks for your help.
I'm not familiar with these settings and with this - I admit - basic knowledge, but I hope you're patient with me.
I tried it again without these Additional Depencies und the Ignore Specific Library Settings just to see what happens.
There are some (about 20) errors like:
error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj) libcmtd.lib


error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup libcmtd.lib

I know that you probably don't like to explain these errors, but I hope you help me finding the right configuration for my project.
Thank you very much!


 
 
Mike Danes





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

What setting you have in Project Properties,Configuration Properties, General, Use of MFC

If it's "Use MFC in a Static Library" then change it to "Use MFC in a Shared DLL".

Same thing for Configuration Properties, C/C++, Code Generation, Runtime Library:

For a Debug build it should be set to Multi-Threaded Debug DLL (/MDd)

For a Release build it should be set to Multi-Threaded DLL (/MD).


 
 
unsigned int





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

My Settings are:
Use of MFC: Use Standard Windows Libraries
Runtime Lrary: Multi-threaded (Debug) DLL
(Config. Type: .dll; /clr)



 
 
Mike Danes





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

Hmm... it seems that you are not using MFC after all...

Are you including any MFC headers (their names start with afx usually)


 
 
unsigned int





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

I'm not including MFC-Headers directly,
but some of the projects I'm referencing to are including afx.h, so think I would need to use MFC.


 
 
Mike Danes





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

Try setting Use of MFC to Use MFC in a Shared DLL and see what happens.
 
 
unsigned int





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

I get 27 errors - independed whether I choose "Use MFC in a Shared DLL" or "Use Standard Windows Libraries".
"Use MFC in a Static Library" is as you probably know incompatible.


 
 
Mike Danes





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

What errors
 
 
unsigned int





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

I admire your patience and I'm thankful ;-)

Here is a complete list of the errors:

error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __i64toa already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __malloc_dbg already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __free_dbg already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj) libcmtd.lib
error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj) libcmtd.lib
error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj) libcmtd.lib
error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj) libcmtd.lib

error LNK2005: ___CppXcptFilter already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __encoded_null already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __crt_de****_hook already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: _sprintf already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib
error LNK2005: _vsprintf already defined in MSVCRTD.lib(MSVCR80D.dll) libcmtd.lib




error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup libcmtd.lib
fatal error LNK1120: 1 unresolved externals D:\project\Debug\manDb.dll 1



 
 
Mike Danes





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

Do a search in your project files for "#pragma" string (without quotes). See if you find something like

#pragma comment(lib, "nafxcwd")

somewhere


 
 
unsigned int





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

There are no #pragma-comments.
But some of the projects I'm referencing to have these settings:
Ignore sp. Lib.: nafxcwd.lib libcmtd.lib
or /NODEFAULTLIB

Additional Depencies or #pragma-comments aren't present.


 
 
Mike Danes





PostPosted: Visual C++ Language, LNK2001: using unmanangedC++ in manC++ Top

Hey, why did you mark all my posts as "Answer" . Does it work now or what