Calling ghc dll's with MSVC++ code
Simon Peyton-Jones
simonpj@microsoft.com
Thu, 12 Dec 2002 08:58:43 -0000
This is a multi-part message in MIME format.
--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C2A1BC.AC6B31A8"
------_=_NextPart_001_01C2A1BC.AC6B31A8
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I don't know if you got a reply to his message. (You should send =
GHC-specific mail to glasgow-haskell-users, not the main Haskell list, =
incidentally.)
=20
I'm not confident that creating Haskell DLLs is working at the moment. =
Has anyone else done it? =20
=20
Trouble is, there isn't yet a critical mass of DLL users to be sure that =
it works and stays working. Which is a bit of a chicken and egg =
problem. Windows programmers unite!
=20
Simon
=20
-----Original Message-----
From: Mauricio Carvalho [mailto:m.decarvalho@telia.com]=20
Sent: 03 December 2002 14:13
To: haskell@haskell.org
Subject: Calling ghc dll's with MSVC++ code
=20
Hey!
I need to call haskell DLL's from a c++ program, and this C++ is written =
in Microsoft's Visual C++ 6.0
I created the DLL sing the directives given at ghc user's guide (11.3 =
and 11.4) and created the dll. To create a .lib import file, I linked =
with the option=20
-optdll--output-lib -optdllMyDll.lib
I can compile and link my C++ problem, but when I run it, it crashes.
I tried even to create a DLL from a C source I'm sure it works (as I =
created the DLL before with MSVC++ environment, and I could make it work =
out), and even this DLL crashes whe its functions are accessed.
I'm using GHC 5.0.4.1
Is there some special command lines that must be used to create DLLs to =
be used with windows? Or is there some known difficulty doing it?
Someone that succeded can please tell me exactly how was it done?
If more info is needed, I can send the sources and command lines I used =
to compile.
ps: I'm not using cygwin (i don't have it installed in my computer =
actually), but as far as I understood, it shouldn't be a problem
=B4Thanks for help!
Mauricio
------_=_NextPart_001_01C2A1BC.AC6B31A8
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle18
{font-family:Arial;
color:navy;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body bgcolor=3Dwhite lang=3DEN-GB link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I don’t know if you got a =
reply to
his message. (You should send GHC-specific mail to =
glasgow-haskell-users, not
the main Haskell list, incidentally.)</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I’m not confident that =
creating
Haskell DLLs is working at the moment. =A0Has anyone else done it?=A0 =
</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Trouble is, there isn’t yet a
critical mass of DLL users to be sure that it works and stays =
working.=A0 Which
is a bit of a chicken and egg problem.=A0 Windows programmers =
unite!</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Simon</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<div style=3D'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm =
0cm 4.0pt'>
<p class=3DMsoNormal><font size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> </span></font><font =
size=3D2
face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>Mauricio</span></font><font=
size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>
</span></font><font size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;
font-family:Tahoma'>Carvalho</span></font><font size=3D2 =
face=3DTahoma><span
lang=3DEN-US style=3D'font-size:10.0pt;font-family:Tahoma'>
[mailto:m.decarvalho@telia.com] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> </span></font><font =
size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>03
December 2002</span></font><font size=3D2 face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma'> </span></font><font
size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>14:13</span></font><font
size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'><br>
<b><span style=3D'font-weight:bold'>To:</span></b> =
haskell@haskell.org<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Calling ghc =
dll's with
MSVC++ code</span></font></p>
<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'> </span></font></p>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Hey!</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>I need to call haskell DLL's from a c++ program, and =
this
C++ is written in Microsoft's Visual C++ 6.0</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>I created the DLL sing the directives given at ghc
user's guide (11.3 and 11.4) and created the dll. To create a .lib =
import
file, I linked with the option </span></font></p>
</div>
<div>
<p class=3DMsoNormal><em><i><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>-optdll--output-lib =
-optdllMyDll.lib</span></font></i></em></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>I can compile and link my C++ problem, but when I run =
it, it
crashes.</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>I tried even to create a DLL from a C source I'm =
sure
it works (as I created the DLL before with MSVC++ environment, and I =
could make
it work out), and even this DLL crashes whe its functions are =
accessed.</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>I'm using GHC 5.0.4.1</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Is there some special command lines that must be used =
to
create DLLs to be used with windows? Or is there some known difficulty =
doing
it?</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Someone that succeded can please tell me exactly how =
was it
done?</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>If more info is needed, I can send the sources and =
command
lines I used to compile.</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>ps: I'm not using cygwin (i don't have it installed =
in my
computer actually), but as far as I understood, it shouldn't be a =
problem</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>=B4Thanks for help!</span></font></p>
</div>
<div>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Mauricio</span></font></p>
</div>
</div>
</div>
</body>
</html>
------_=_NextPart_001_01C2A1BC.AC6B31A8--
--------------InterScan_NT_MIME_Boundary--