Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Creating a static library from an MFC DLL Project

Posted on 2001-06-05
12
Medium Priority
?
1,584 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 400 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

610 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