开发者

Creating Windows DLL from C++ source files

I have multiple source files in C++ using which i want to create a Dynamic link library.

I see this happening in linux with gcc -shared and ln

however for Windows i suppose i w开发者_JS百科ould have to modify source files to generate a DLL.

Is there a way to generate DLL (a file similar to *.so in linux) with provided source files. Please correct me if i m wrong, i think *so is dll for linux.

The reason for needing this is to use SWIG for calling C++ functions in python in Windows Platfrom. I am stuck at the step that requires me to generate a dll in windows.


The exact approach depends on which compiler you are using, but the procedure is probably documented. For example, if you want to create a DLL using Visual Studio, a walkthrough is available here.


DLL functions that are callable from outside the DLL have special macro keywords

__declspec(dllexport) void __cdecl SomeFunction(int a, int b);


What compiler are you using? For Visual C++ the command line that creates a dynamic library from the given object files looks like this:

link -nologo -dll -out:mylib.dll -implib:mylib.lib myobj1.obj myobj2.obj ...

Also while compiling your source files into object files you will need to use the -D option to define any macros necessary to ensure that your dynamic library's symbols will be exported.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜