Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MFC: static library problem

Posted on 2011-03-08
15
Medium Priority
?
1,102 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

718 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