[Mono-list] using dll in linux
Jonathan Pryor
jonpryor at vt.edu
Fri Jun 5 13:12:16 EDT 2009
On Fri, 2009-06-05 at 04:08 -0700, Chaiser wrote:
> But how can I generate a dll file for linux ?
At this point using clearer terminology would help, as .dll refers to
both managed code (assemblies) and native code (Dynamic Link Libraries /
Shared Libraries).
For shared libraries, you don't create .dll files, you create lib.*.so
files. If you keep the extension out of your [DllImport] declarations,
you don't need to worry about the prefix/suffix differences, e.g.
[DllImport("foo")] static extern int Frob();
This will look for FOO.DLL on Windows, and libfoo.so under Linux.
The next problem is creating the libfoo.so file. You can do this with
gcc (for C code) or g++ (for C++ code) along with the -fPIC and -shared
commands, e.g.
g++ -o libfoo.so -fPIC -shared foo.cpp bar.cpp
You might find this helpful:
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
- Jon
More information about the Mono-list
mailing list