Solved

Creating a static library from an MFC DLL Project

Posted on 2001-06-05
12
1,558 Views
Last Modified: 2013-11-20
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...

0
Comment
Question by:Dak_Programmer
12 Comments
 
LVL 3

Expert Comment

by:Shay050799
ID: 6157814
just add the CPP and H file to an empty static library project

Shay
0
 
LVL 2

Expert Comment

by:KaplanDani
ID: 6157913
Create a static project and compare the project's setting (code generation, linking ect..) between them. so you'll know what to change.
Dani
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6158676
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.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 12

Expert Comment

by:migel
ID: 6158800
Hi!
you must remove CWinApp derived objects from your sources to make static library
0
 

Author Comment

by:Dak_Programmer
ID: 6160175
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???
0
 

Author Comment

by:Dak_Programmer
ID: 6160300
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???
0
 
LVL 12

Expert Comment

by:migel
ID: 6161055
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)
0
 

Author Comment

by:Dak_Programmer
ID: 6161147
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
0
 

Author Comment

by:Dak_Programmer
ID: 6161231
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
0
 
LVL 12

Accepted Solution

by:
migel earned 100 total points
ID: 6162688
Hi!
It seems that compiler Runtime library settings aren`t equal for projects.
0
 

Author Comment

by:Dak_Programmer
ID: 6164097
Ok I got it working -- but when ever I new an object within the static library -- it seems to give me invalid memory
0
 

Author Comment

by:Dak_Programmer
ID: 6165112
Can there be something wrong with doing a new inside a static library
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question