开发者

Compiling a C++ library both as a static lib and dynamic dll with VS

I need to compile an existing C++ library both as a lib and a dll, and then use the static a开发者_运维技巧nd dynamic libraries in different applications. I use VS2010.

What I can't do is to edit all the header files in order to add __declspec(dllexport) instructions to export, as the library must be kept as it is.

Under Mac I was able to compile and use a dylib without problems, but I know that VS is lacking in this regard.

In VS is it feasible to compile a static lib first and then a dll in order to have functions "exported" (i.e. linkable from an application at compilation time)? In other words, can I use the static lib as if was the export lib generated with __declspec(dllexport)? Are there better workarounds?


I need to compile an existing C++ library both as a lib and a dll, and then use the static and dynamic libraries in different applications. I use VS2010.

Create configurations for that. For example Release LIB, Release DLL, etc.

What I can't do is to edit all the header files in order to add __declspec(dllexport) instructions to export, as the library must be kept as it is.

Simply add module definition file (*.def) with a list of exported functions.

In other words, can I use the static lib as if was the export lib generated with __declspec(dllexport)?

No, those libs are different. When you build a DLL you get a binary and a lib files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜