PDA

View Full Version : How Do I Create a DLL?



Ubuntist
April 17th, 2012, 07:33 AM
I know how to compile source files and link the resulting objects with libraries to produce an executable. In order to use compiled code in certain environments (e.g., within the statistical package R), however, I need to create a DLL. Could anyone give me a pointer on how to do that?

Ubuntist
February 18th, 2013, 01:21 PM
I finally found out how to do this. I'll post it, on the off chance somebody else is looking for the same information.

It's simple: with the GNU compilers, just use the -shared option. For example, to create a DLL named func.dll from the C source file func.c, do


gcc func.c -shared -o func.dllThat's all there is to it!

Tony Flury
February 18th, 2013, 02:34 PM
I finally found out how to do this. I'll post it, on the off chance somebody else is looking for the same information.

It's simple: with the GNU compilers, just use the -shared option. For example, to create a DLL named func.dll from the C source file func.c, do


gcc func.c -shared -o func.dllThat's all there is to it!

Bear in mind this is not a Windows DLL (Dynamic Link Library), and any "dll" you create like this cannot be used on a windows machine.

What you have actually created is a "shared" object library which are normally labelled as a ".so" file - but as you have seen, under linux you can call them anything you want.

Although the naming convention is simply that (a convention) I would recommend that to avoid confusion you don't create ".dll" files for linux.