简体   繁体   English

是否可以使用Visual Studio 2013 Community Edition创建静态库C ++?

[英]Is it possible to create a static library C++ with Visual Studio 2013 Community Edition?

I had a C/C++ Visual Studio 2013 Community Edition project that was defined to generate a DLL, and I'm having a lot of misery with "undefined symbols" which I wanted to use in another project, so I decided to see what it would give if I changed the project settings so that it would generate a static library instead. 我有一个C / C ++ Visual Studio 2013社区版项目,该项目被定义为生成DLL,并且我想在另一个项目中使用“未定义符号”时感到非常痛苦,所以我决定看看它是什么如果更改项目设置,它将给出一个静态库。

So in the Properties window of the project I went to 因此,在项目的“属性”窗口中,我转到了

Configuration Properties > General > Project Defaults > Configuration Type 配置属性>常规>项目默认值>配置类型

and set the Configuration Type to Static Library The target extension is .lib . 并将“配置类型”设置为“ 静态库 ”。目标扩展名为.lib

When I do a rebuild I still get a fresh dll file in my Release folder, as well as a lib, and the DLL file is much bigger than the lib file. 进行重建时,我仍在我的Release文件夹中获得一个新的dll文件以及一个lib,并且DLL文件比lib文件大得多。 This makes the lib file look like an "export lib" file and it looks like nothing has changed. 这使lib文件看起来像“导出lib”文件,并且看起来没有任何变化。 This still happens if I stop and restart Visual Studio. 如果我停止并重新启动Visual Studio,仍然会发生这种情况。

Am I missing something or does this look like a bug to you? 我是否缺少某些东西,或者这看起来像是对您的错误?

In Configuration Properties - C/C++ - Runtime Library change setting to Multi-threaded (/MT) for Release configuration and to Multi-threaded Debug (/MTd) for Debug configuration. 在“ Configuration Properties - C/C++ - Runtime LibraryRelease配置更改为Multi-threaded (/MT) ,将Debug配置Multi-threaded Debug (/MTd)Multi-threaded Debug (/MTd)

设置屏幕截图

Also, check Configuration Properties - General - General - Target extension is set to .lib . 另外,还要将“ Configuration Properties - General - General - Target extension设置为.lib

Check settings for all configurations ( Release and Debug if you use them). 检查所有配置的设置(如果使用它们,请ReleaseDebug )。

Why have you changed your project type? 为什么更改项目类型? If you need DLL, build DLL. 如果需要DLL,请构建DLL。 Post exact errors received during DLL compilation. 发布在DLL编译期间收到的确切错误。 Perhaps you missed some dllexport / dllimport declspecs. 也许您错过了一些dllexport / dllimport declspecs。

Regarding .lib : are you sure, that DLL is generated during build? 关于.lib :您确定在构建期间生成了DLL吗? Perhaps it is the output from previous (DLL) configuration? 也许这是以前(DLL)配置的输出? Have you tried to compile test app using this .lib ? 您是否尝试使用此.lib编译测试应用程序? Perhaps it is valid and compiled properly? 也许它是有效的并且经过正确编译?

Another matter: have you removed all dclspecs from function signatures after project type change? 另一件事:项目类型更改后,是否从函数签名中删除了所有dclspecs? When building static library, none of them are applicable. 在构建静态库时,它们都不适用。

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

相关问题 如何在Visual Studio Community Edition中将pthread库添加到C ++项目? - How to add pthread library to C++ project in Visual Studio Community Edition? 使用Visual Studio 2015社区版在C ++中#include excel错误 - #include excel error in C++ with Visual Studio 2015, Community edition 有没有办法在 C++ Visual Studio 2019(社区版)中允许这样做? - Is there a way to allow this in C++ Visual Studio 2019 (Community Edition)? 带有C ++ Visual Studio Community 2013的Arduino程序 - Arduino program with C++ Visual studio Community 2013 Visual Studio 2013 C ++链接静态库glew,虚拟机上的glfw - Visual Studio 2013 C++ link static library glew, glfw on virtual machine 在C ++ Visual Studio中链接静态库 - link static library in c++ visual studio 如何从Visual Studio 2017社区版C ++项目中导出DLL? - How to export a DLL from Visual Studio 2017 Community Edition C++ Project? Visual Studio 2013中可能的C / C ++编译器错误 - Possible C/C++ compiler bug in Visual Studio 2013 编译Sqlite C ++库时Visual Studio 2013崩溃 - Visual Studio 2013 crashes when compiling Sqlite C++ library 链接到Boost库时遇到问题(Visual Studio 2013中的C ++) - Having issues with linking to boost library (C++ in Visual Studio 2013)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM