linkning linux static libraries in windows with cy

2019-08-04 01:48发布

问题:

I'm having a binary static library libfoo.a compiled for 32 bit linux machine. I wish to compile it against my win32 project compiled with cygwin.

Is that possible? It seems to be possible, as all the object files in the archive should be in the standard ELF format.

However I keep recieving linking errors about functions that nm finds in the libfoo.a. When I created a stub libfoo.a with some empty functions with the same names of those in libfoo.a, I didn't recieve linking errors about those functions any longer.

Is that even possible or am I missing something? At any rate, how can I troubleshoot this problem?

回答1:

Even if you succeed in linking you won't avoid incompatibility of code built on different platforms. For example headers (glibc and others) are different there. To ensure compatibility additional mechanisms similar to mangling seem to be used on symbols exported by object files.

I've met a problem similar to yours when tried to link together object files compiled for different processor architecture - nm showed all needed functions are present, but linker didn't believe that.