Solved

MFC: static library problem

Posted on 2011-03-08
15
1,088 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C Language combined operators 28 137
Embarcadero C++ builder XE10.1 Berlin TRegistry declaration 1 60
Outlook 13 100
calling back function with same name and different signature 1 43
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

751 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