views:

251

answers:

4

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 would 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.

+3  A: 

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.

David Seiler
The process of creating a DLL depends on which EDITOR you use? Huh?
swillden
Durr, compiler. Fixed.
David Seiler
+1  A: 

Here the step-by-step for you Create Your First Test Project

lsalamon
+1  A: 

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

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

iterationx
Either that, or you have to create a `.def` file with export definitions.
Thomas
A: 

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.

grigy