Hello Wine-devel,
I finaly got the expected results from my simple tests to get a winelib DLL and test application to work.
I am pretty sure that I am still doing something wrong in these tests !!!!!
Can somebody say if the below setup is correct and if not what would be the correct way to create a winelib "dll" and then call it from a winelib executable.
I am using wine-20020509.
=>I start with a simple DLL file called mytest.c and use winemaker to create a libmytest.so
bash#cd ~/mytest.dll bash#ls mytest.c bash#cat mytest.c
//mytest.c #include <windows.h> #include <stdio.h>
BOOL APIENTRY DllMain(HINSTANCE hinstDLL , DWORD fdwReason, LPVOID lpvReserved ) { printf("DllMain called\n"); return TRUE; }
void usefullFunction() { printf("Usefull function got called\n"); } //end of mytest.c
bash#winemaker --dll --nomfc . <output suppressed> bash#cat libmytest.spec name mytest type win32 mode dll init DllMain
import kernel32.dll import ntdll.dll
bash# ./configure <output suppressed>
bash# make && make install gcc -c -g -O2 -fPIC -D_REENTRANT -DWINELIB -I. -I/usr/local/include/wine -o mytest.o mytest.c ld -r mytest.o -o libmytest.tmp.o strip --strip-unneeded libmytest.tmp.o LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" /usr/local/bin/winebuild -fPIC -L/usr/local/lib/wine -sym libmytest.tmp.o -o libmytest.spec.c -spec ./libmytest.spec gcc -c -g -O2 -fPIC -D_REENTRANT -DWINELIB -I. -I/usr/local/include/wine -o libmytest.spec.o libmytest.spec.c gcc -shared -Wl,-rpath,/usr/local/lib -Wl,-Bsymbolic -o libmytest.so mytest.o libmytest.spec.o -lwine -lwine_unicode -lwine_uuid -lm _list=""; for i in $_list; do (cd $i; make install) || exit 1; done _list=" "; for i in $_list; do install $i /usr/local/bin; done _list="libmytest.so"; for i in $_list; do install $i /usr/local/lib; done
bash# #Now I have a /usr/local/lib/libmytest.so file \ #I think the next commands are wrong...
bash# cd /usr/local/lib bash# cp libmytest.so wine/mytest.dll.so bash# ln -s wine/mytest.dll.so libmytest.dll.so
bash# #This was done so that I can write \ # import mytest.dll \ # in a spec file and "register with wine" this so
=>I now create a simple winelib application to call mytest called "callmytest" =>Call my test is defined in callmytest.c
bash# cd ~/callmytest bash#ls callmytest.c bash# cat callmytest.c //start of callmytest.c #include "windows.h"
extern usefullFunction();
int WINAPI WinMain(HINSTANCE a,HINSTANCE b,LPSTR c ,int d) { usefullFunction(); }
//end of callmytest.c
bash# winemaker --guiexe -imytest.dll -lmytest.dll . <output suppressed>
bash# cat callmytest.spec name callmytest type win32 mode guiexe init WinMain
import kernel32.dll import ntdll.dll import mytest.dll
bash# ./configure <output suppressed>
bash# make gcc -c -g -O2 -fPIC -D_REENTRANT -DWINELIB -I. -I/usr/local/include/wine -o callmytest.o callmytest.c ld -r callmytest.o -o callmytest.tmp.o strip --strip-unneeded callmytest.tmp.o LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" /usr/local/bin/winebuild -fPIC -L/usr/local/lib/wine -sym callmytest.tmp.o -o callmytest.spec.c -spec ./callmytest.spec gcc -c -g -O2 -fPIC -D_REENTRANT -DWINELIB -I. -I/usr/local/include/wine -o callmytest.spec.o callmytest.spec.c gcc -shared -Wl,-rpath,/usr/local/lib -Wl,-Bsymbolic -o callmytest.so callmytest.o callmytest.spec.o -lmytest.dll -lwine -lwine_unicode -lwine_uuid -lm test -f callmytest || ln -s /usr/local/bin/wine callmytest
bash# ./callmytest DllMain called Usefull function got called DllMain called
QUESTION 1: I think that adding -imytest.dll -lmytest.dll to
winemaker --guiexe -imytest.dll -lmytest.dll .
is wrong.
QUESTION 2: Is DllMain called when the DLL is loaded and then unloaded ?
Can anyone help me on this?
Thanks, Miguel Feitosa