Problems converting DLL to unix SO with winelib
list at vmn.com.br
list at vmn.com.br
Thu Jun 6 14:17:42 CDT 2002
Hello All At Wine-Devel!
I am trying to convert a win32 DLL to a unix SO.
The dll named if32dt is basically a wrapper over the serial port,
interfacing some custom hardware. It is therefore a driver
to the custom hw.
This is part of a project to port a windows sales app to linux.
There are about 6 DLLs with similar structure and my aim is to
show my superiors that using winelib is much better than simply
rewriting the DLL to use unix system calls.
1) I have sucessfully copied my project over to unix and built the so file
The project is basicaly a couple of headers and the c file ifdt32.cpp
bash# cd ifdt32/
bash# mv ifdt32.cpp ifdt32.c
#the file is plain C , cpp was confusing gcc
bash# winemaker --nomfc -imsvcrt.dll -I/usr/local/include/wine/msvcrt --dll .
bash# ./configure
bash# make
bash# make install
The DLL uses msvcrt so I added it. => I read some issues between msvcrt and crt
in winehq.com
After changing a couple lines of ifdt.c I was able to build
libifdt.so .
I had a lot of warnings like
ifdt32.c:176: warning: comparison between pointer and integer
My ifdt32.spec file is unchanged from what winemaker created
name ifdt32
type win32
mode dll
init DllMain
import msvcrt.dll
import advapi32.dll
import comdlg32.dll
import gdi32.dll
import kernel32.dll
import ntdll.dll
import odbc32.dll
import ole32.dll
import oleaut32.dll
import shell32.dll
import user32.dll
import winspool.drv
ifdt32.c only uses msvcrt.dll, ntdll.dll , kernel32.dll, user32.dll
I added simple printf calls to DllMain to see if it was being called when the SO
is loaded
make install correctly put libifdt.so in /usr/local/lib
I ran ldconfig in /usr/local/lib with
bash# ldconfig -v -n .
libifdt32.so -> libifdt32.so
libwine_unicode.so -> libwine_unicode.so.1.0
libwine_tsx11.so -> libwine_tsx11.so.1.0
libwine.so -> libwine.so.1.0
2) I created a trivial program to test libifdt.so
bash# cat test.c
#include "windows.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "io.h"
#include "conio.h"
#include "fcntl.h"
#include "direct.h"
#include "time.h"
#include "IFfunc32.h"
printf("before start");
int main(void)
{
printf("before start");
if( IF_IFDT32_OPEN("COM2") == 0 ) {
printf("We are working") ;
} else {
printf("Oh no!");
}
}
bash# make
gcc -g -c test.c -I/usr/local/include/wine -I/usr/local/include/wine/msvcrt
-I/home/nwine/ifdt32/ifdt32
gcc -o test test.o -lifdt32 -L/usr/local/lib
This program seg faults.
I have not been able to debug it with winedbg, it simply hangs with message
"Starting with pid 0"
bash# gdb test
(gdb) b 1
Breakpoint 1 at 0x8048556: file test.c, line 1.
(gdb) r
Starting program: /home/nwine/ifdt32/test/test
Breakpoint 1, main () at test.c:15
15 printf("before start");
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
0x400387cb in dllname () from /usr/local/lib/libifdt32.so
(gdb) bt
#0 0x400387cb in dllname () from /usr/local/lib/libifdt32.so
#1 0x8048563 in main () at test.c:15
#2 0x40057f9b in __libc_start_main () from /lib/libc.so.6
(gdb) p dllname
$1 = "ifdt32"
In this trace, it seems that a function named dllname is causing a segfault
There is a string named dllname and it's contents are correct
I think the winelib initialisation code has not been correctly called
For example: the Dllmain function to start the DLL has not been called
I have tried a great many things to work around this problem with no success.
It is hard to debug because the seg fault happens very early and I havent been
able to get winedbg to work.
I have tried this on wine-20020509 and wine-20020122 with exactly the same
problem.
Thanks a lot for any help or pointers.
Miguel Feitosa
Sao Paulo - Brasil
P.S> output of
bash# ldd ifdt.dll
libwine.so => /usr/local/lib/libwine.so (0x40010000)
libwine_unicode.so => /usr/local/lib/libwine_unicode.so (0x40026000)
libm.so.6 => /lib/libm.so.6 (0x40103000)
libc.so.6 => /lib/libc.so.6 (0x40125000)
libdl.so.2 => /lib/libdl.so.2 (0x40245000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x2aaaa000)
-------------------------------------------------
This mail sent through IMP: webmail.vmn.com.br
More information about the wine-devel
mailing list