PDA

View Full Version : dlls - declspec/dllexport


-Vormav-
08-15-2006, 04:50 AM
This has always bugged me. I've always been able to get dll delcarations working in all of my programs just by mimicking the approach used in others, but I've never had a completely clear idea of why they need to be setup the way they are.
In particular, what's the difference between this...

DLLEXPORT void somefunction() {}

and this...

void __declspec(dllexport) somefunction() {}


?

MasterZap
08-15-2006, 09:13 AM
If you look up, say, shader.h for mental ray you will find

#define DLLEXPORT __declspec(dllexport)


I.e. "no difference whatsoever".... on Windows

It's put in a preprocessore #define so that it is platform independent, and on non-windows platorm, DLLEXPORT is #defined to ... nothing.

/Z

-Vormav-
08-15-2006, 10:48 AM
Ahh... Wasn't aware that the MR headers were doing that. But I guess that makes sense. Thanks.

But how are link points established in Linux then? Just compiler statements?

Robert Bateman
08-17-2006, 12:11 PM
But how are link points established in Linux then? Just compiler statements?

Use the -shared flag in gcc, ie :

g++ -shared -o myThingy.so someCfile.cpp

then you need to modify your LD_LIBRARY_PATH env variable to include the path to the *.so

CGTalk Moderation
08-17-2006, 12:11 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.