This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Symbol in DLL begin with _


Hm,

I've managed it now. Documentation and the FAQ is a little unclear to me
(and not up to date either). Here's a bash script to do the job (for JNI
only, 
comment out the grep stuff for the more general case.

Kind regards,

Thomas

-----------------------------------
#!/bin/bash

# mkdll.sh LIBNAME OBJECTFILES
# LIBNAME: without extensions
# OBJECTFILES: *.o (with extensions)

if test $# -lt 2; then 
  echo "usage: mkdll.sh LIBNAME OBJECTS*"
  exit -1
fi
	
# additional libs to link with: here we are doing C++ stuff
export LIBS=-lstdc++
export LIBNAME=$1
shift

# based on a tip of Dmitry Timoshkov 
# zero, remove old dll
rm $LIBNAME.a $LIBNAME.dll $LIBNAME.def $LIBNAME.tmp 2>/dev/null
# first, get a EXPORT list
dlltool --add-stdcall-alias --export-all-symbols --output-def $LIBNAME.tmp
$*
# (JNI only): second, only let the 'Java_' symbols in
echo EXPORTS >$LIBNAME.def
grep "Java_" $LIBNAME.tmp >>$LIBNAME.def
# third, create the .dll
dllwrap -o $LIBNAME.dll $* $LIBS -k --def $LIBNAME.def \
    -Wl,--kill-at,--enable-stdcall-fixup
# forth, reorganize the .a lib
dlltool --kill-at --input-def $LIBNAME.def --output-lib lib$LIBNAME.a
# fifth, echo something helpful about the dependencies of the dll
cygcheck -rv $LIBNAME.dll


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]