help on win32

James Mitchell jimdesu at yahoo.com
Sun Apr 10 20:25:06 EDT 2005


Hey y'all,

(I haven't seen any traffic on this list--I hope it's
ok to ask help questions here.)

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.

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/ 


More information about the FFI mailing list