简体   繁体   English

在 Visual Studio 2010 中链接到 static 库

[英]Linking to static libraries in Visual Studio 2010

Things to know:要知道的事情:

  • I'm quite sure that I'm using the right static libraries (with dllexport and all)我很确定我使用的是正确的 static 库(带有 dllexport 和所有)
  • The.lib files generated are HUGE (3M, 8M, etc).生成的.lib 文件非常大(3M、8M 等)。 Shared ones are around 300K-1M.共享的在 300K-1M 左右。 So I'm quite sure the.lib files are static所以我很确定.lib 文件是 static
  • I want to link to these static library files in a separate solution我想在单独的解决方案中链接到这些 static 库文件
  • This is an unmanaged C/C++ project这是一个非托管 C/C++ 项目

I've read that I need to use the new UI (Common properties > Add New Reference thingy).我已经读到我需要使用新的 UI(通用属性 > 添加新参考)。 But for this to work, I need to add the entire project to my solution.但要使其正常工作,我需要将整个项目添加到我的解决方案中。 Is there a way to just link my project to the static library (without adding its source code).有没有办法将我的项目链接到 static 库(不添加其源代码)。

The 'Add New Reference' thingy is a .NET option, used to add an assembly reference. “添加新参考”是一个 .NET 选项,用于添加装配参考。 You can't create static link libraries in .NET, assemblies are always dynamically loaded.您不能在 .NET 中创建 static 链接库,程序集始终是动态加载的。 Suspending disbelief and actually answering the question: you use the Browse tab in the dialog to avoid having to add the project to the solution.暂停怀疑并实际回答问题:您使用对话框中的“浏览”选项卡以避免将项目添加到解决方案中。

Native projects that use a static link library must use the Linker, Input, Additional Dependencies setting instead.使用 static 链接库的本机项目必须改用 Linker、输入、附加依赖项设置。 No need to add the project that generated the.lib either.也不需要添加生成.lib 的项目。 If you don't specify the full path of the.lib then you can use Linker, General, Additional Linker Directories to tell the linker where to look for the.lib如果不指定.lib 的完整路径,则可以使用 Linker、General、Additional Linker 目录来告诉 linker 在哪里寻找 lib。

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

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