Mailinglist Archive: opensuse (3337 mails)

< Previous Next >
Re: [SLE] DLL problem
  • From: Jerry Feldman <gerald.feldman@xxxxxx>
  • Date: Thu, 6 Apr 2006 14:57:24 -0400
  • Message-id: <200604061457.24988.gerald.feldman@xxxxxx>
On Wednesday 05 April 2006 5:40 am, vince@xxxxxxxxxxxxxxx wrote:

> There is a program which might run under Linux and incorporates C, C++
> routins using their DLL. I don't know much about this. How to make DLL
> in Linux? If it is not posible, how to do it in Windows?
The general questions I thing were addressed by Anders and Kai.
In general, C and C++ are very easy.
To create a Linux shared object (eg .so), compile forst to a .o using the
-fpic option of the gcc (and g++) compiler.
gcc foo.c -c -fpic
This creates an object with position independent code (-fpic is not
necessary in 32-bit, but is in 64-bit and on IA64 and other boxes).
Then, to create the .so,
gcc -shared -o libfoo.so foo.o

To use that library, you can either link with it:
gcc prog.c -o prog -L . -l foo
Or, in your program you can use the dlopen(2) and dlsym(2) system calls.
These are relatively standard in Linux and Unix.

--
Jerry Feldman <gerald.feldman@xxxxxx>
Linux Expertise Center (PTAC-MA/TX)
Hewlett-Packard Co.
200 Forest Street MRO1-3/K12
Marlborough, MA 01752-3081

508-467-4315 (http://www.testdrive.hp.com)

< Previous Next >
References