Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using both .so and .dll on Windows

I am writing a program in windows in C++ in which users will be able to compile extensions in the form of dynamic-link libraries (windows), or shared object files (linux).

On windows, you use the LoadLibrary function to load a dll. Is it possible to do the same for .so files on windows and vice versa, load .dlls on linux?

like image 351
Langley Avatar asked Jul 13 '10 02:07

Langley


People also ask

Can .so file run in Windows?

However, you might be able to read the SO file as a text file by opening it in a text editor like Leafpad, gedit, KWrite, or Geany if you're on Linux, or Notepad++ on Windows. It's unlikely, though, that the text will be in a human-readable format.

What's the purpose of a DLL in Windows?

The use of DLLs helps promote modularization of code, code reuse, efficient memory usage, and reduced disk space. So, the operating system and the programs load faster, run faster, and take less disk space on the computer. When a program uses a DLL, an issue that is called dependency may cause the program not to run.

What do dynamic link library DLL files do?

A dynamic link library (DLL) is a collection of small programs that larger programs can load when needed to complete specific tasks. The small program, called a DLL file, contains instructions that help the larger program handle what may not be a core function of the original program.


1 Answers

The short answer is "No"

That is not about loading but about internal format of dynamic library like expected entry points. Each operating system support it's own format. Hence it won't work.

  • DLL is a PE executable (as are exe on windows)
  • .so is usually an ELF format (like most modern executables on Linux/Unix).

However on Linux there is some support for PE executable through Wine, and Wine program can use DLL. But that's probably not what you are looking for.

On Windows there is also some support of ELF format through cygwin, and there is also some compilers that can load coff format (the one used on Unix before ELF). I used DJGPP for this a long time ago.

like image 150
kriss Avatar answered Sep 20 '22 01:09

kriss