-2

I have a build a lib in windows. My client has an application in linux. He wants to use my library but I don't want to build it in linux. My it is not possible to use it. Is there any workaround?

user966379
  • 2,823
  • 3
  • 24
  • 30

2 Answers2

3

Because Linux and Windows have different ABIs (see x86-64 ABI) & calling conventions, set of system calls, standard C library, standard C++ library, standard version of C++ (e.g. conformance to C++11), shared library format (Linux use ELF, Windows is rumored to use PE), and even notion of what a symbol (in the linker sense) is or does (on Linux, read about symbol visibility; on Windows you are rumored to need dllexport things). Levine's book on linkers and loaders explain the difference. In C++, the name mangling is also different.

I'm not even sure the set of system calls on Windows is documented. For Linux, see syscalls(2) and the kernel source code

The best way would be to publish your source code as free software. Your client (or someone else) could then compile the source code and adapt it to his needs.

BTW, it is probable that you won't be able to compile easily your library on Linux. Unless you crafted very carefully your library (and know a bit Linux or POSIX), you'll certainly meet portability issues (I don't know which). Perhaps your program might have somewhere some undefined behavior which behave very differently on Linux and on Windows.

Designing, coding and building your own library above some multi-system framework like Qt or Poco should help portability.

If you are unfamiliar with Linux you should read Advanced Linux Programming.

PS. I never used or coded on any Microsoft OS since the 1980s. I'm using Unix since 1985 and Linux since 1993

Community
  • 1
  • 1
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
0

You can make it a header-only library.

Cross-compilers possibly exist, but I wouldn't even try to go that way.

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331