Reputation: 1950
Is there a way to compile a cross platform library to work on all platforms with the single file?
So what I mainly (only?) see is that Windows uses DLL and other platforms each use a different file.
Why are these not standardised? Is there a standard format that can be used instead? If not can this be faked?
Sorry about multiple questions but answering one should invalidate the others.
Upvotes: 0
Views: 183
Reputation: 1977
Libraries contain compiled code, which is actually specific to the architecture of the platform. Since there is no standard agreement between big players on machine architecture, the unfortunate result is that the libraries are not portable across platforms.
The best way is to open source the code and let the users compile the code on the platform they want.
The second best option is to go Java way. Distribute your library in form of jar file containing the class files. And let the users install the right JRE for their platform.
I am not aware of any other options unfortunately.
Upvotes: 1
Reputation: 423
IDK why object files aren standartized (although you can use GCC for crosscompilation afaik), but the only viable guaranteed crossplatform solution as for right now is source (as far as i know). For example CImg ships as single header file (40kb), but it has some dependencies, it needs backend image processing library/toolchain. Although im not quite sure, maybe there are cross-platform static object formats.
Upvotes: 0