简体   繁体   English

与其他库链接的静态库-LINKER警告

[英]Static library linked with other libs - LINKER warning

I'm building SDL2 static library. 我正在构建SDL2静态库。 To use it in my program, I have to link with (static) SDL2.lib, but also with winmm.lib, imm32.lib, version.lib, which I assume are stubs for some Windows DLLs. 要在我的程序中使用它,我必须链接(静态)SDL2.lib,而且还要链接winmm.lib,imm32.lib,version.lib,我认为这些链接是某些Windows DLL的存根。 My main goal is to create such a version of static SDL2, so that my program won't have to be linked with those other 3 .libs. 我的主要目标是创建这样一个静态SDL2版本,这样我的程序就不必与其他3个.lib链接。 I would like to have all the symbols needed in the static library, so that I have to link the exe only with SDL2.lib. 我想拥有静态库中所需的所有符号,以便仅将exe与SDL2.lib链接。 I'm using MS VS2012. 我正在使用MS VS2012。 I had the idea to use the Librarian when building the static SDL2.lib so I added those other 3 libs to Librarian/Additional Dependencies. 我有在构建静态SDL2.lib时使用图书馆员的想法,因此我将其他3个库添加到图书馆员/其他依赖项中。 That worked like a charm. 那就像一个魅力。 My exe has to be linked only against SDL2.lib. 我的exe只必须链接到SDL2.lib。

But when the .lib was linked, I got warnings: 但是当链接.lib时,我得到警告:

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  imm32.lib(IMM32.dll)    SDL2main
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  version.lib(VERSION.dll)    SDL2main

Now my idea is this: imm32.lib and version.lib do not define any previously undefined (in SDL2.lib) symbols. 现在我的想法是这样的:imm32.lib和version.lib没有定义任何以前未定义的(在SDL2.lib中)符号。 So they are not needed, because all of the symbols in SDL2.lib can be resolved. 因此不需要它们,因为SDL2.lib中的所有符号都可以解析。 So I removed those 2 libs from the Librarian and recompiled SDL2.lib. 因此,我从图书管理员中删除了这两个库,并重新编译了SDL2.lib。 Now when I'm linking my exe against it, I got some unresolved symbols (possibly from those 2 removed .libs). 现在,当我针对它链接我的exe时,我得到了一些未解析的符号(可能是从这两个已删除的.libs中获取的)。

Could somebody explain to me the meaning of those warnings? 有人可以向我解释这些警告的含义吗? And how to avoid them? 以及如何避免它们?

It seems those symbols aren't used in SDL2.lib, but are used in your main. 似乎这些符号未在SDL2.lib中使用,但在您的main中使用。 That's why you have to link those 3 files with your main, and not take a shortcut. 这就是为什么您必须将这3个文件与主文件链接,而不要使用快捷方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM