Building DLL

Maarten Boekhold boekhold@emirates.net.ae
Mon Jul 12 15:54:00 GMT 2004


Hi all,

Sorry to keep going on about this, I really want to get this working.

I've made *some* progress in how to build "plugin libraries". I have 
attached my test case to this mail in case somebody is willing to have a 
look at it. Let me describe it first.

I did some reading on the libtool documentation, and according to that, 
libtool 1.5.6 has specific support for dlopen'ed libraries (which is 
what glib/gmodule uses under the hood if I'm not mistaken). The trick is 
an extra macro to your configure.ac (AC_LIBTOOL_DLOPEN) and two 
additional flags to libtool: -module and -export-dynamic. Now, I'm not 
sure if that support is supposed to work on cygwin. But together with a 
"plugin.def" file that defines to the library that a symbol is exported 
by the executable, I can now get things to compile.

Caveat: I cannot get the 'plugin.def' file passed to the gcc command 
line when linking:

/bin/bash ./libtool --mode=link gcc  -g -O2   -o libplugin.la -rpath 
/usr/local/lib -no-undefined -module plugin.def libplugin_la-plugin.lo 
-lgobject-2.0 -lglib-2.0 -lintl -liconv
gcc -shared  .libs/libplugin_la-plugin.o  -L/usr/lib 
/usr/lib/libgobject-2.0.dll.a /usr/lib/libglib-2.0.dll.a 
/usr/lib/libintl.dll.a /usr/lib/libiconv.dll.a  -o .libs/cygplugin-0.dll 
-Wl,--image-base=0x10000000 -Wl,--out-implib,.libs/libplugin.dll.a

So instead I editted the generated 'libtool' (after running autogen.sh) 
and added it manually:

# Commands used to build and install a shared archive.
archive_cmds="\$CC -shared \$libobjs \$deplibs \$compiler_flags -o 
\$output_objdir/\$soname \${wl}--image-base=0x10000000 
\${wl}--out-implib,\$lib plugin.def"

Note the "plugin.def" at the end. Now 'make' succeeds. If anybody knows 
how I can pass the "plugin.def" to the GCC command line, I'd be very 
interested to know.

Run 'make install', and then:
	/usr/local/bin/plugintest /usr/local/lib/libplugin.la

This now gives:

$ /usr/local/bin/plugintest.exe /usr/local/lib/libplugin.la

** ERROR **:  1627507512s not a valid Win32 application.
aborting...
Aborted (core dumped)

Is this expected, and is there a way to fix this? Has anybody seen this 
before? (note: for people not familiar with gmodule, the g_module_open() 
function explicitly tests whether this is a libtool library, and if so 
retrieves the actual DLL name from the libplugin.la file).

Kind regards,

Maarten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plugintest.tar.gz
Type: application/x-gzip
Size: 1416 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040712/f9316a89/attachment.bin>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list