On 30/07/2009 08:43, Martine Carannante wrote:
I try to port on CYGWIN an open source which runs correctly on Linux.
In this open source, a shared module (linked with option -shared) is
created and after it's loaded by the main program with lt_dlopen()
function.
On CYGWIN, I have a problem when I create the module (gcc option
-shared). I have always some undefined references to functions which
belongs to the main program. On Linux it's not a problem, there are no
errors.
As was already pointed out, unlike ELF shared objects, PE/COFF DLLs must
have all symbols resolved at link time. In this situation, where
plugins depend on symbols in an executable, there are a few workarounds:
1) Make everything in the main executable except for main() a shared
library, then link both the program's main() and the plugins against that;
2) Build the main program first with these additional LDFLAGS:
'-Wl,--export-all-symbols,--out-implib,libfoo.a'. Then build the
plugins, adding to their LDFLAGS: '-Wl,/path/to/libfoo.a'.
3) If the package uses libtool and the number of symbols required by the
DLLs is few, an alternative is to add '-Wl,--export-all-symbols' to the
main executable LDFLAGS, and create a foo.def file with the following
syntax:
IMPORTS
foo_symbol_1 = foo.exe.foo_symbol_1
foo_symbol_2 = foo.exe.foo_symbol_2
Then add '-export-symbols /path/to/foo.def' to the plugins' LDFLAGS.
Making a patch using any of these solutions that could possibly be
accepted upstream will take some more work, but at least you should be
able to build it yourself.
HTH,
Yaakov
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple