Is It possible to Linking static library into dynamic library in Visual Studio?

I am try to link a static library in a dynamic library tmxParser.lib in Visual Studio 2010 express. I have the static library set as a dependency of the dynamic library. When VS build the static library builds fine and creates tmxParser.lib. When VS builds the dynamic library I am getting linker errors. I tried to match the Runtime Library under property page -> Configuration properties -> C/C++ -> Code Generation It doesn't help. Anyone have any idea?

2>LIBCMTD.lib(fopen.obj) : error LNK2005: _fopen already defined in s3e_d.lib(iwcrt_stdio.obj)
2>LIBCMTD.lib(open.obj) : error LNK2005: __open already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(open.obj) : error LNK2005: __sopen already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(chsize.obj) : error LNK2005: __chsize already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(read.obj) : error LNK2005: __read already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(close.obj) : error LNK2005: __close already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(lseek.obj) : error LNK2005: __lseek already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(setmode.obj) : error LNK2005: __setmode already defined in s3e_d.lib(iwcrt_win32.obj)

当你说你把它设置为一个依赖项时,你的意思是你将它设置为项目依赖项,或者在“附加依赖项”下

Project Properties -> Librarian->General -> Additional Dependencies


Generally, yes.

The problem you have seems to be that the library (is it the marmalade library?) implements some of the methods from the C++ runtime library. Probably, this lib is supposed to be used without linking the standard runtime library.

Possible solutions:

  • do not link c++ runtime in your DLL. That should be possible if you write just a thin wrapper
  • Ask the guys making the lib how they thought this is supposed to work
  • use the lib.exe or dumpbin.exe to:
  • extract all .obj files of the lib
  • remove the conflicting symbols from the .obj files
  • recreate the lib
  • The latter is obviously an ugly hack, and should be reserved for cases where neither source nor original developer are available anymore.

    链接地址: http://www.djcxy.com/p/64372.html

    上一篇: 在MinGW中静态链接库

    下一篇: 是否有可能将静态库链接到Visual Studio中的动态库?