help on win32

Daan Leijen daan at cs.uu.nl
Tue Apr 19 16:04:56 EDT 2005


James Mitchell wrote:

>I'm writing an interface to Berkeley DB, and, while I
>can link to my wrapper library fine from C, I can't
>seem to do it successfully from GHC.
>  
>
I think you are trying to link agains an Microsoft Visual C++ library.
You need to convert it first to a mingw compatible library and you can
do that using a special utitility called. "reimp.exe". You can get it by
downloading the wxHaskell sources -- it is in the "bin" directory.

when you do "reimp foo.lib", it will create "libfoo.a" and "foo.def"
that can be linked with ghc stuff.

I hope this helps,
-- Daan Leijen

>My first attempt was:
>D:\src\dm>ghc -fffi test.hs db.lib libdb43.lib
>compilation IS NOT required
>Warning: .drectve `/DEFAULTLIB:"libcp"
>/DEFAULTLIB:"LIBC" /DEFAULTLIB:"OLDNAMES"
>/EXPORT:_db_info_status_pos,DATA /EXPOR
>T:_db_info_struct_size,DATA /EXPORT:_db_open at 4
>/EXPORT:_db_close at 4 /EXPORT:_db_read at 4
>/EXPORT:_db_write at 4 /EXPORT:_db_re
>move at 4 /EXPORT:_db_info_mode_pos,DATA
>/EXPORT:_db_info_out_data_pos,DATA
>/EXPORT:_db_info_in_data_length_pos,DATA /EXPOR
>T:_db_info_pathname_pos,DATA
>/EXPORT:_db_info_error_pos,DATA
>/EXPORT:_db_info_in_data_pos,DATA
>/EXPORT:_db_info_key_leng
>th_pos,DATA /EXPORT:_db_info_key_pos,DATA
>/EXPORT:_db_info_out_data_length_pos,DATA
>/EXPORT:_db_info_db_name_pos,DATA '
>unrecognized
>db.lib(Release/berk_db.obj)(.text+0xd):berk_db.cpp:
>undefined reference to `??2 at YAPAXI@Z'
>db.lib(Release/berk_db.obj)(.text+0xc):berk_db.cpp:
>undefined reference to `_except_list'
>db.lib(Release/berk_db.obj)(.text+0x14):berk_db.cpp:
>undefined reference to `_except_list'
>db.lib(Release/berk_db.obj)(.text+0x5d):berk_db.cpp:
>undefined reference to `??_V at YAXPAX@Z'
>db.lib(Release/berk_db.obj)(.text+0x7e):berk_db.cpp:
>undefined reference to `_except_list'
>db.lib(Release/berk_db.obj)(.text+0x6c):berk_db.cpp:
>undefined reference to `??_V at YAXPAX@Z'
>db.lib(Release/berk_db.obj)(.text+0x78):berk_db.cpp:
>undefined reference to `??_U at YAPAXI@Z'
>
>... where db.lib is my wrapper library.  Taking a hint
>from the compiler defaultlib directives, I then did
>the following:
>
>D:\src\dm>ghc -fffi test.hs db.lib libdb43.lib
>libc.lib libcp.lib oldnames.lib
>compilation IS NOT required
>libc.lib(build/intel/st_obj/crt0.obj)(.text+0x0): In
>function `mainCRTStartup':
>f:\vs70builds\9466: multiple definition of
>`mainCRTStartup'
>D:/GHC/GHC-6.2.2/gcc-lib/crt2.o(.text+0x240):crt1.c:
>first defined here
>Warning: .drectve `/DEFAULTLIB:"libcp"
>/DEFAULTLIB:"LIBC" /DEFAULTLIB:"OLDNAMES"
>/EXPORT:_db_info_status_pos,DATA /EXPOR
>T:_db_info_struct_size,DATA /EXPORT:_db_open at 4
>/EXPORT:_db_close at 4 /EXPORT:_db_read at 4
>/EXPORT:_db_write at 4 /EXPORT:_db_re
>move at 4 /EXPORT:_db_info_mode_pos,DATA
>/EXPORT:_db_info_out_data_pos,DATA
>/EXPORT:_db_info_in_data_length_pos,DATA /EXPOR
>T:_db_info_pathname_pos,DATA
>/EXPORT:_db_info_error_pos,DATA
>/EXPORT:_db_info_in_data_pos,DATA
>/EXPORT:_db_info_key_leng
>th_pos,DATA /EXPORT:_db_info_key_pos,DATA
>/EXPORT:_db_info_out_data_length_pos,DATA
>/EXPORT:_db_info_db_name_pos,DATA '
>unrecognized
>Warning: .drectve `/merge:.CRT=.data
>/defaultlib:kernel32.lib /disallowlib:libcd.lib
>/disallowlib:libcmt.lib /disallowli
>b:libcmtd.lib /disallowlib:msvcrt.lib
>/disallowlib:msvcrtd.lib ' unrecognized
>Warning: .drectve `/MERGE:.rtc=.rdata ' unrecognized
>
>I assume that the warnings are no problem, but I can't
>figure out how to get rid of the duplicate
>"mainCRTStartup" symbol.
>
>This's really vexing me, as there are a number of
>things such as gdb support that would go a long way
>towards making Haskell more useable for general
>purpose applications (instead of the "hard"
>calculations at which it excels), but I just can't
>seem to make it work.
>
>thanks in advance,
>
>James
>
>
>
>|-----------------------------------------------|
>|   James Mitchell     | http://www.jimdesu.us  |
>|-----------------------------------------------|
>|When the shoe fits, the foot is forgotten; when|
>|the belt fits, the belly is forgotten; when the|
>|heart is right, "for" and "against" are        |
>|forgotten. -- Chuang Tzu                       |
>|-----------------------------------------------|
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Yahoo! Small Business - Try our new resources site!
>http://smallbusiness.yahoo.com/resources/ 
>_______________________________________________
>FFI mailing list
>FFI at haskell.org
>http://www.haskell.org/mailman/listinfo/ffi
>  
>



More information about the FFI mailing list