简体   繁体   中英

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.

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 .

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. This makes the lib file look like an "export lib" file and it looks like nothing has changed. This still happens if I stop and restart 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.

设置屏幕截图

Also, check Configuration Properties - General - General - Target extension is set to .lib .

Check settings for all configurations ( Release and Debug if you use them).

Why have you changed your project type? If you need DLL, build DLL. Post exact errors received during DLL compilation. Perhaps you missed some dllexport / dllimport declspecs.

Regarding .lib : are you sure, that DLL is generated during build? Perhaps it is the output from previous (DLL) configuration? Have you tried to compile test app using this .lib ? Perhaps it is valid and compiled properly?

Another matter: have you removed all dclspecs from function signatures after project type change? When building static library, none of them are applicable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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