Solved

MFC: static library problem

Posted on 2011-03-08
15
1,080 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 

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

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

830 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