Solved

MFC: static library problem

Posted on 2011-03-08
15
1,069 Views
Last Modified: 2012-05-11
Dear experts,

I have an MFC application, and I want to add a static library to it. I get several errors like this:
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _memmove already defined in libcmt.lib(memmove.obj)
I tried to exclude libcmt.lib from my project (in Ignore Specific Library), but then I get many unresolved externals:
1>libogg_static.lib(framing.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
1>CORE_RL_png_.lib(pngerror.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_png_.lib(pngrutil.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_png_.lib(pngwutil.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(draw.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(segment.obj) : error LNK2001: unresolved external symbol __iob
1>IM_MOD_RL_pict_.lib(pict.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_jpeg_.lib(jerror.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(color.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(animate.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(xwindow.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(display.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(magic.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(module.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(type.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(delegate.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(magick.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(image.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(error.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(blob.obj) : error LNK2001: unresolved external symbol __iob
1>CORE_RL_magick_.lib(display.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(draw.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(utility.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(attribute.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(animate.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(xwindow.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(magick.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(cache.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(magic.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(color.obj) : error LNK2001: unresolved external symbol __pctype
1>CORE_RL_magick_.lib(display.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
1>CORE_RL_magick_.lib(draw.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
1>CORE_RL_magick_.lib(utility.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
1>CORE_RL_magick_.lib(attribute.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
1>CORE_RL_magick_.lib(animate.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
1>CORE_RL_magick_.lib(xwindow.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
1>CORE_RL_magick_.lib(magick.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
1>CORE_RL_magick_.lib(cache.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
1>CORE_RL_magick_.lib(magic.obj) : error LNK2001: unresolved external symbol ___mb_cur_max
1>CORE_RL_magick_.lib(color.obj) : error LNK2001: unresolved external symbol ___mb_cur_max

Could you please help me with this?
Thanks.
0
Comment
Question by:tantormedia
  • 8
  • 7
15 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 35071031
>>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _memmove already defined in
>>libcmt.lib(memmove.obj)

This sounds that your project is using a CRT version that is not compatible to the one the static lib was built with (i.e. /MD vs. /MT) - try changing your settings. Open your project's properties (ALT+F7), go to "Configuration Properties|C++|Code Generation" and change "Runtime Library" from "Multi-threaded DLL (/MT)" to "Multi-threaded (/MD)" (or from "Multi-threaded Debug DLL (/MTd)" to "Multi-threaded Debug(/MDd)" for the debug build respectively).
0
 

Author Comment

by:tantormedia
ID: 35071084
But I am using only static libraries.
0
 
LVL 86

Expert Comment

by:jkr
ID: 35071146
"MSVCRT.lib(MSVCR90.dll)" indicates that you are using the DLL version of the CRT, though.
0
 

Author Comment

by:tantormedia
ID: 35071213
I don't understand, how that can be. I am really confused.
When I made the change you suggested, I got
1>c:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afx.h(24) : fatal error C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d].

Thank you very much for your help.
0
 
LVL 86

Expert Comment

by:jkr
ID: 35071282
Ah, forgot about MFC - in "Configuration Properties|General" set "Use MFC" to "Use MFC in a static library" also.
0
 

Author Comment

by:tantormedia
ID: 35071299
This is what I have now.
0
 
LVL 86

Expert Comment

by:jkr
ID: 35071356
OK - what was your "Code Generation" setting in the beginning?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:tantormedia
ID: 35071427
Multi-threaded (/MT)
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 35071556
Ah, sorry, then it seems to conflict exactly the other way round - the new static lib apparently was set to use "Multithreaded DLL"... anything that prevents you from changing your project to also use that one?
0
 

Author Comment

by:tantormedia
ID: 35072090
I tried it, and get thousands of errors like this:
Error      2608      error LNK2001: unresolved external symbol _write      CORE_RL_magick_.lib
0
 
LVL 86

Expert Comment

by:jkr
ID: 35072232
Have you removed the 'Ignore Specific Library' setting also? BTW, any chance that you can rebuild the library in question?
0
 

Author Comment

by:tantormedia
ID: 35072512
I removed the Ignore Specific Library setting, and could build the solution!
Just not sure if this line
12>libogg_static.lib(framing.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve
is OK.
0
 
LVL 86

Expert Comment

by:jkr
ID: 35072692
That should not be an issue, see the docs on '/GL' and '/LTGC':

http://msdn.microsoft.com/en-us/library/0zza0de8%28VS.80%29.aspx ("/GL (Whole Program Optimization)")
http://msdn.microsoft.com/en-us/library/xbf3tbeh%28VS.85%29.aspx ("/LTCG (Link-time Code Generation)")
0
 

Author Closing Comment

by:tantormedia
ID: 35072702
Thank you very much.
0
 
LVL 86

Expert Comment

by:jkr
ID: 35072779
You're welcome ;o)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now