MFC: static library problem

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.
tantormediaAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
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
 
jkrCommented:
>>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
 
tantormediaAuthor Commented:
But I am using only static libraries.
0
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.

 
jkrCommented:
"MSVCRT.lib(MSVCR90.dll)" indicates that you are using the DLL version of the CRT, though.
0
 
tantormediaAuthor Commented:
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
 
jkrCommented:
Ah, forgot about MFC - in "Configuration Properties|General" set "Use MFC" to "Use MFC in a static library" also.
0
 
tantormediaAuthor Commented:
This is what I have now.
0
 
jkrCommented:
OK - what was your "Code Generation" setting in the beginning?
0
 
tantormediaAuthor Commented:
Multi-threaded (/MT)
0
 
tantormediaAuthor Commented:
I tried it, and get thousands of errors like this:
Error      2608      error LNK2001: unresolved external symbol _write      CORE_RL_magick_.lib
0
 
jkrCommented:
Have you removed the 'Ignore Specific Library' setting also? BTW, any chance that you can rebuild the library in question?
0
 
tantormediaAuthor Commented:
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
 
jkrCommented:
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
 
tantormediaAuthor Commented:
Thank you very much.
0
 
jkrCommented:
You're welcome ;o)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.