How do i write a static ansi-c library using visual studio 2010

心已入冬 提交于 2019-12-05 19:39:22

Try to omit the __declspec(dllexport), this shall be used for DLLs only. If you compile your files just like

#ifndef __STACKOVERFLOW_EXAMPLE_
#define __STACKOVERFLOW_EXAMPLE_

int test(int magic);

#endif // __STACKOVERFLOW_EXAMPLE_

everything should be fine. See here for an example.

Without even knowing what kind of options you used to compile this it's hard to even try to give an answer.

But, no matter what you are trying, VS offers really poor support for the C language, some features or versions of the C language are not available at all inside VS, VS is well know to not be a really good place for C.

I suggest to switch to MinGW and stick to it.

In 2013, with Visual Studio 2010, I'm getting non-empty static libraries created, but neither dumpbin nor lib produce any output whatsoever, whether I say /all, -all or /disasm, one of which should say something.

File says "current ar archive" on Windows, and on linux, $ ar tvf MathFuncsLib.lib rw-rw-rw- 100666/100666 16252 Jan 13 15:29 2014 Debug/MathFuncsLib.obj

And yes, this is the trivial math library Microsoft uses for their walk-through example (:-))

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!