From: Luke D. <cod...@ho...> - 2003-08-19 02:00:18
|
----- Original Message ----- From: "Shaun Kelly" <sh...@is...> To: "mingw" <min...@li...> Sent: Monday, August 18, 2003 3:47 PM Subject: [Mingw-msys] dllwrap versus a2dll > Good Day All, > > I am having major problems with dll's that I am creating! I am a linux > programmer who is trying > to port c code to windows using mingw/msys. I am needing to create DLL's that > both c exe's and > Java jar's can access via the jni interface. (My priority is Java access thou. > I must add that the code > is working under linux using so shared libraries. ) > I am running msys-1.0.9 and mingw3.0 on winXP PC. > > My errors are : > java.lang.UnsatisfiedLinkError: > C:\msys\1.0.9\local\bin\iss\libstdj_JniEventReader2.dll: Invalid access to > memory location The problem may be specific to Java, like using the wrong calling conventions, so if nobody on this list can help you with that then you may need to search for information about how to use JNI with MinGW. In fact, search anyway... > > What is the best way of creating DLL's unders Mingw/Msys? I am using dllwrap as > follows : > (I pass a library name and list of objects and a list of libraries to this > script) > ---------- > .... > AR_EXT=a > DLL_EXT=dll > DEF_EXT=def > TARGET=${ARG1}.${DLL_EXT} > ARCH=${ARG1}.${AR_EXT} > ARCHIVE=${ISSLIB}/${ARCH} > DLLNAME=${ARG1}.${DLL_EXT} > DEFNAME=${ARG1}.${DEF_EXT} > NEWDEF=new_${DEFNAME} > > dllwrap --export-all \ > --enable-stdcall-fixup \ > --add-stdcall-alias \ > --output-def ${DEFNAME}2 \ > -L${ISSLIB} \ > -o ${TARGET} $* -lm > > impdef ${DLLNAME} > ${NEWDEF} > > dllwrap --export-all \ > --enable-stdcall-fixup \ > --add-stdcall-alias \ > --def ${NEWDEF} \ > --output-def ${DEFNAME} \ > --implib ${ARCH} \ > -L${ISSLIB} \ > -o ${TARGET} $* > ... > --------- > I have put ' __declspec(dllexport)' infront of every function that I export. (I > actually don't know when to use > dllimport, and wether or not to use it for global variables that I want to > access from outside?) > > If I don't use the impdef on the dll I create and use the generated .def file to > create the final dll I cannot link > against the dll. > > Can you help ? > > Regards > Shaun. > -- I really don't know why you want to use .def files at all if it is just an intermediate step for creating a DLL, because it is unnecessary (and because impdef is not part of MinGW). Perhaps you should try the recommended method of creating a DLL: gcc -shared -o ${TARGET} $* -Wl,--out-implib,${ARCHIVE} It will be simpler if you don't use options like "--enable-stdcall-fixup" unless you know why you need to. Luke |