【发布时间】:2014-07-29 00:03:17
【问题描述】:
我正在尝试使用包含其他静态库的静态库。
有两个项目:Engine、MyGame
'Engine' 将生成 Engine.lib
“MyGame”在链接时将使用 Engine.lib。
以下是我从 Visual Studio 2012 收到的构建消息:
1>------ Rebuild All started: Project: Engine, Configuration: Debug Win32 ------
2>------ Rebuild All started: Project: MyGame, Configuration: Debug Win32 ------
1> Precompiled.cpp
2> Main.cpp
2>LINK : fatal error LNK1104: cannot open file 'D:\klee\Engine\Debug\Engine.lib'
1> RenderGame.cpp
1> RenderDebug.cpp
1> MsgHandler.cpp
1> Main.cpp
1> Log.cpp
1> Input.cpp
1> Interface.cpp
1> Helper.cpp
1> GameObject.cpp
1> Framework.cpp
1> Engine.cpp
1> Config.cpp
1> Component.cpp
1> Generating Code...
1> Guicon.cpp
1>glu32.lib(GLU32.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in glew32.lib(glew32.dll); second definition ignored
1>glu32.lib(GLU32.dll) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1>opengl32.lib(OPENGL32.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in glew32.lib(glew32.dll); second definition ignored
1>opengl32.lib(OPENGL32.dll) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1>SDL2.lib(SDL2.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in glew32.lib(glew32.dll); second definition ignored
1>SDL2.lib(SDL2.dll) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1> Engine.vcxproj -> D:\klee\Engine\Debug\Engine.lib
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
起初,“MyGame”似乎无法找到 Engine.lib,但该项目确实生成了运行良好的可执行文件。
其次,“引擎”包含其他库(SDL2、OpenGL、GLEW)以生成其新库,但它说符号是重复的。
“符号”到底是什么意思?
链接时符号“公开”是什么意思?
如果这些警告很严重,为什么会这样?我该如何解决?
如何配置项目之间的构建顺序?
在我的项目中使用外部库的任何最佳做法?
两个项目共享一些 dll(SDL2.dll、glew.dll)。如果其他用户要使用这个 Engine.lib,我该如何提供这些 dll?
谢谢。
【问题讨论】:
标签: c++ visual-studio-2012 dll linker static-libraries