Link to home
Start Free TrialLog in
Avatar of Dak_Programmer
Dak_Programmer

asked on

Creating a static library from an MFC DLL Project

Is there an easy way to convert an (MFC) Dynamic Link Library into a Static LIB Library???

I have a DLL Project that I need to convert into a Static Link Library...

Avatar of Shay050799
Shay050799

just add the CPP and H file to an empty static library project

Shay
Create a static project and compare the project's setting (code generation, linking ect..) between them. so you'll know what to change.
Dani
Do the same thing what KaplanDani sad, but You must change include files from that static projrct to Your project.
See the difference in "stdafx.h" file.
Hi!
you must remove CWinApp derived objects from your sources to make static library
Avatar of Dak_Programmer

ASKER

msvcrtd.lib(MSVCRTD.dll) : error LNK2005: _strncpy already defined in libcmtd.lib(strncpy.obj)
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: __setmbcp already defined in libcmtd.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "mfc42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcs42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfco42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcd42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcn42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library

I am getting these errors when I try to compile my test app... any ideas???
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: _strncpy already defined in libcmtd.lib(strncpy.obj)
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: __setmbcp already defined in libcmtd.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "mfc42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcs42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfco42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcd42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcn42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library

I am getting these errors when I try to compile my test app... any ideas???
Hi!
you must sets same option for using MFC (first tab in tne lib project settings window) as you use in the project where you want use your lib. Note runtime library settings also must be same (dynamic or static, single/multi threaded)
Ok I did that -- but I still get the following warning...


LINK : warning LNK4098: defaultlib "libcd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
Ok I did that -- but I still get the following warning...


LINK : warning LNK4098: defaultlib "libcd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
ASKER CERTIFIED SOLUTION
Avatar of migel
migel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok I got it working -- but when ever I new an object within the static library -- it seems to give me invalid memory
Can there be something wrong with doing a new inside a static library