Sign in to follow this  

DLLs for Linx and Mac?

This topic is 3465 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yes I know that they are different file formats that require different methods to compile but I'm pretty sure there must be a way to make something like a DLL thats compatible cross platform. So my question is how?

Share this post


Link to post
Share on other sites
On Linux and Mac the equivalent to DLLs from Windows are .so (Shared Object) files.
DLLs are just like executable files and inherently non cross platform. You still have to compile the code for each platform separately.

Share this post


Link to post
Share on other sites
Actually, it's more typical for shared libraries to have a .dylib extension on the Mac. There's a subtle distinction between .dylibs and .sos, though.

Each platform also has its own convention about where it looks for shared libraries and how to change these search paths. You should research a little in to that, too.

MSDN and developer.apple.com will help you out for Windows and Mac OS X. For linux, it's usually something like the LD_LIBRARY_PATH environment variable (among others).

Share this post


Link to post
Share on other sites
Quote:
Original post by the_edd
For linux, it's usually something like the LD_LIBRARY_PATH environment variable (among others).


Same for Macs although they also look for the DYLD_LIBRARY_PATH as well. Generally speaking as long as you put your dylibs in standard place (/usr/lib or /usr/local/lib) then you will be okay.

Share this post


Link to post
Share on other sites
Quote:
Original post by EmptyVoid
So how does 3DS Max deal with it's plug-ins?


3D Studio Max is not available for Linux or Macs. So it does not have to worry about it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
So how does 3DS Max deal with it's plug-ins?


3D Studio Max is not available for Linux or Macs. So it does not have to worry about it.


That answered my question very well. Thanks lol

One thing though why on earth would you want a Mac or Linux in that case?...

Share this post


Link to post
Share on other sites
Quote:
Original post by EmptyVoid
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
So how does 3DS Max deal with it's plug-ins?


3D Studio Max is not available for Linux or Macs. So it does not have to worry about it.


That answered my question very well. Thanks lol

One thing though why on earth would you want a Mac or Linux in that case?...


Because there are just as good if not better 3D packages available for the Mac? Maya, Houdini, Blender, Lightwave etc.

Share this post


Link to post
Share on other sites
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
So how does 3DS Max deal with it's plug-ins?


3D Studio Max is not available for Linux or Macs. So it does not have to worry about it.


That answered my question very well. Thanks lol

One thing though why on earth would you want a Mac or Linux in that case?...


Because there are just as good if not better 3D packages available for the Mac? Maya, Houdini, Blender, Lightwave etc.


I've worked with all of them there not as good for video games.

Share this post


Link to post
Share on other sites
Quote:
Original post by EmptyVoid
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
So how does 3DS Max deal with it's plug-ins?


3D Studio Max is not available for Linux or Macs. So it does not have to worry about it.


That answered my question very well. Thanks lol

One thing though why on earth would you want a Mac or Linux in that case?...

Because there is superior 3D software like Maya that does run on Macs and Linux;)

Share this post


Link to post
Share on other sites
Quote:
Original post by daviangel
Quote:
Original post by EmptyVoid
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
So how does 3DS Max deal with it's plug-ins?


3D Studio Max is not available for Linux or Macs. So it does not have to worry about it.


That answered my question very well. Thanks lol

One thing though why on earth would you want a Mac or Linux in that case?...

Because there is superior 3D software like Maya that does run on Macs and Linux;)


Maya is not superior you can't write exporter plug-ins as far as I know.

Share this post


Link to post
Share on other sites
Quote:
Original post by EmptyVoid
Quote:
Original post by daviangel
Quote:
Original post by EmptyVoid
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
So how does 3DS Max deal with it's plug-ins?


3D Studio Max is not available for Linux or Macs. So it does not have to worry about it.


That answered my question very well. Thanks lol

One thing though why on earth would you want a Mac or Linux in that case?...

Because there is superior 3D software like Maya that does run on Macs and Linux;)


Maya is not superior you can't write exporter plug-ins as far as I know.


Of course you can. There is a whole Maya API that you can use.

Share this post


Link to post
Share on other sites
Quote:
Original post by Cromulent
Of course you can. There is a whole Maya API that you can use.


If that is the case then how did they make the plug-in system cross platform?

Share this post


Link to post
Share on other sites
Quote:
Original post by EmptyVoid
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
Quote:
Original post by daviangel
Quote:
Original post by EmptyVoid
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
So how does 3DS Max deal with it's plug-ins?


3D Studio Max is not available for Linux or Macs. So it does not have to worry about it.


That answered my question very well. Thanks lol

One thing though why on earth would you want a Mac or Linux in that case?...

Because there is superior 3D software like Maya that does run on Macs and Linux;)


Maya is not superior you can't write exporter plug-ins as far as I know.


Of course you can. There is a whole Maya API that you can use.


If that is the case then how did they make the plug-in system cross platform?


Write cross platform compatible code and the just install it in the proper place for that operating system. Obviously it will need to be recompiled but that is the same with any C/C++ code.

Share this post


Link to post
Share on other sites
Java JAR's and CLR DLL's (For the "Any" CPU) are cross platform. Just that they need the runtime to JIT them to the target CPU/OS at runtime.

Share this post


Link to post
Share on other sites
Quote:
Original post by Cromulent
Quote:
Original post by EmptyVoid
But how does maya do it? What header files is it using?


Same way as any other SDK works. It is nothing magic really.


Ok how do I make a SDK?

Share this post


Link to post
Share on other sites
Quote:
Original post by EmptyVoid
Ok how do I make a SDK?

Wow. That's a huge question.

An SDK - a software development kit - is a collection of tools, utilities, dynamic libraries, static import libraries and source code to assist and/or enable developers to create solutions that target a specific platform. That platform can be an operating system (eg, Windows SDK), a set of interfaces that abstract access to resources like hardware (eg, DirectX SDK), or even a single application (eg, Maya SDK). An SDK is authored the same way you author any collection of code and applications - that is not your problem. Your problem is that you don't fundamentally know what you are doing.

Let's start at the beginning. What do you want to accomplish? From your posts, it appears you want to create an extension mechanism for an application (eg, your game) that works across platforms - Windows, OS X, Linux. The first thing you need to realize is that these are three separate products - three separate applications compiled specifically to those operating system platforms, and a similar/identical extension mechanism across all three.

The following assumes you're writing your game in either C or C++.

Let's say you've written a game for Windows, using an abstraction toolkit like SDL so that your game builds under Linux simply by recompiling. You now want to add to your game the ability to load new functionality from a dynamic library or shared object present in a specific folder. For Windows, you need to call LoadLibrary to open the dynamic library, then GetProcAddress to obtain the address of a particular function implemented in it; for Linux and OS X (after 10.3), you need to call dlopen to load the shared object, then dlsym to obtain the address of a symbol defined in the library. C and C++ support the notion of conditional compilation via the preprocessor: you can check for the existence of platform-specific symbols and cause different branches of code to be compiled as a consequence.

#ifdef _WIN_VER    // Windows
LoadLibrary(...);
...
GetProcAddress(...);
...
#elseif __APPLE__ // Mac OS
dlopen(...);
...
dlsym(...);
...
#elseif __linux__ // take a wild guess
dlopen(...);
...
dlsym(...);
...
// despite calling the same function, the parameters for Linux may differ
// from Mac OS X, so we separate those platforms as well
#else
// you can disable the application from loading plugins, or whatever
#endif


But what if you don't want to mess about with platform-specific dynamic library techniques? Well, then you actually have to do more upfront work to simplify things on the end. Say you want to create something comparable to the Maya Embedded Language; then you need to create the plugin language (or pick one - there are dozens of extension and embeddable languages), build/select the compiler, integrate it into the toolchain used by your developers (including your end users if you allow them to develop plugin and extensions), and then embed an interpreter or other mechanism to parse the compiled object files within your application.


As you can see, there is a lot you need to do. Get busy, and good luck!

Share this post


Link to post
Share on other sites
There is nothing magic about cross platform stuff. The code isn't built once and it works for every platform. It has to be built on the target plaform to be compiled into whatever format that platform uses. Except for Java but I don't think he is talking about that. So if you wanted to create a Maya plugin you would have to write specific code for each platform and have preprocessor settings to compile the correct code for the platform you are trying to target.

Share this post


Link to post
Share on other sites
Basically you use a scripting language MEL(Maya Embedded Language ) or python. If you need to write a C plugin then you have to recompile to support multiple platforms.

Share this post


Link to post
Share on other sites
Quote:
Original post by Oluseyi
Quote:
Original post by EmptyVoid
Ok how do I make a SDK?

Wow. That's a huge question.

An SDK - a software development kit - is a collection of tools, utilities, dynamic libraries, static import libraries and source code to assist and/or enable developers to create solutions that target a specific platform. That platform can be an operating system (eg, Windows SDK), a set of interfaces that abstract access to resources like hardware (eg, DirectX SDK), or even a single application (eg, Maya SDK). An SDK is authored the same way you author any collection of code and applications - that is not your problem. Your problem is that you don't fundamentally know what you are doing.

Let's start at the beginning. What do you want to accomplish? From your posts, it appears you want to create an extension mechanism for an application (eg, your game) that works across platforms - Windows, OS X, Linux. The first thing you need to realize is that these are three separate products - three separate applications compiled specifically to those operating system platforms, and a similar/identical extension mechanism across all three.

The following assumes you're writing your game in either C or C++.

Let's say you've written a game for Windows, using an abstraction toolkit like SDL so that your game builds under Linux simply by recompiling. You now want to add to your game the ability to load new functionality from a dynamic library or shared object present in a specific folder. For Windows, you need to call LoadLibrary to open the dynamic library, then GetProcAddress to obtain the address of a particular function implemented in it; for Linux and OS X (after 10.3), you need to call dlopen to load the shared object, then dlsym to obtain the address of a symbol defined in the library. C and C++ support the notion of conditional compilation via the preprocessor: you can check for the existence of platform-specific symbols and cause different branches of code to be compiled as a consequence.

#ifdef _WIN_VER    // Windows
LoadLibrary(...);
...
GetProcAddress(...);
...
#elseif __APPLE__ // Mac OS
dlopen(...);
...
dlsym(...);
...
#elseif __linux__ // take a wild guess
dlopen(...);
...
dlsym(...);
...
// despite calling the same function, the parameters for Linux may differ
// from Mac OS X, so we separate those platforms as well
#else
// you can disable the application from loading plugins, or whatever
#endif


But what if you don't want to mess about with platform-specific dynamic library techniques? Well, then you actually have to do more upfront work to simplify things on the end. Say you want to create something comparable to the Maya Embedded Language; then you need to create the plugin language (or pick one - there are dozens of extension and embeddable languages), build/select the compiler, integrate it into the toolchain used by your developers (including your end users if you allow them to develop plugin and extensions), and then embed an interpreter or other mechanism to parse the compiled object files within your application.


As you can see, there is a lot you need to do. Get busy, and good luck!



Yeah I can see that this will add three times as much work so I should just make it for windows...

Share this post


Link to post
Share on other sites
Quote:
Original post by stonemetal
Basically you use a scripting language MEL(Maya Embedded Language ) or python. If you need to write a C plugin then you have to recompile to support multiple platforms.

Yeah I just noticed by looking at all the new versions of the 3D software that they all seem to support some sort of Python scripting now like Blender-LOL!
It's cool to see that Python is finally starting to take over from all these proprietary scripting languages each 3D package used to use.

Share this post


Link to post
Share on other sites
Quote:
Original post by daviangel
Quote:
Original post by stonemetal
Basically you use a scripting language MEL(Maya Embedded Language ) or python. If you need to write a C plugin then you have to recompile to support multiple platforms.

Yeah I just noticed by looking at all the new versions of the 3D software that they all seem to support some sort of Python scripting now like Blender-LOL!
It's cool to see that Python is finally starting to take over from all these proprietary scripting languages each 3D package used to use.


Python really does seem to be the up and coming scripting language. I really, really must sit down at some point and give it a whirl but I keep getting put off by the whole tab based syntax.

Share this post


Link to post
Share on other sites

This topic is 3465 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this