View Full Version : howto export functions in *.so libraries
January 12th, 2010, 09:30 PM
I am trying to convert one windows program to Linux.
The question is:
what is linux equivalent for
extern "C" int (__declspec(dllexport))someFunction(char* someparam)
Thanks in advance.
January 16th, 2010, 12:11 PM
In Linux (as usual) it's easy and you have 3+ ways to do it.
If you just declare them
Or you can create an export/mapfile fo feed the linker with telling it exactly which symbols to export/hide. http://publib.boulder.ibm.com/infocenter/tpfhelp/current/topic/com.ibm.ztpf-ztpfdf.doc_put.cur/gtpl2/cre8expfl.html#cre8expfl (you can create the file by hand). Another link is http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html , section -Wl or -Map. Another link: http://people.redhat.com/drepper/dsohowto.pdf (section 2.2.5).
Or you can used the gcc flag
Is just a mere macro to usually force the compiler to produce stdcall calling convention. In Linux AFAIK we only use cdecl ( http://en.wikipedia.org/wiki/X86_calling_conventions ).
January 16th, 2010, 12:56 PM
January 21st, 2010, 09:14 AM
to be precise, the calling convention applies to i386 arch.
For x86-64 Windows and Linux follow 2 slightly different conventions: Linux follows AMD ABI calling convention, instead, as usual, M$ way is to slightly diverge from it from no apparent reason...sigh...
Anyway, given more registers in x86-64, a lot of variables are passed into them, instead of being put onto the stack then read (as happens with i386 convention). So even just for this reason (and believe me there are many more) x86-64 is faster than i386.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.