delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/01/22/18:36:28

From: ert AT cit DOT org DOT by (Andrew Lipnitsky)
Subject: Re: Usage of dll created in cygwin in VC++
22 Jan 1999 18:36:28 -0800 :
Message-ID: <36A8A8DA.F56928A5.cygnus.gnu-win32@cit.org.by>
References: <000f01bc05f0$2fee7d60$11247aa3 AT sdf5_l1117 DOT tatainfotech DOT co DOT in>
Mime-Version: 1.0
To: "S. Krishnaprasad" <s DOT krishnaprasad AT tatainfotech DOT com>,
gnu-win32 AT cygnus DOT com

This is a multi-part message in MIME format.
--------------2D9B1EB428533349D97B8589
Content-Type: multipart/alternative;
 boundary="------------5F9685F673F044173EEED2FC"


--------------5F9685F673F044173EEED2FC
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit



"S. Krishnaprasad" wrote:

>  I have useddllwrap --export-all mdll.dll mylib.a -L. -lgmp I get the
> DLL file.But when I try to use it in a Visual C++ application it gives
> me a undefined reference to the functionnames defined in this DLL.I
> created a export .DEF file which is as follows LIBRARY
> <dllname>EXPORTS     function1    function2 etc..Then I created a
> import file  .lib using dllwrap --dllname <name.dll> --output-lib
> <libname.lib> This created a .lib file
>
>  This when linked into a Visual C++ application it compiles and links
> properly but whenI try to run this application it just terminates at
> the function call. Can anybody help me.

Yes. In order to link dll you have to get library file. But you have to
use
LIB.exe program from VisualStudio like that
d:\DevStudio\VC\bin\LIB.EXE /DEF:foo.def
After that you will get foo.lib file.

>This when linked into a Visual C++ application it compiles and links
properly but when
>I try to run this application it just terminates at the function call.

Due to program (as well dll) compiled with cygwin using cygwin1.dll
you can not link it with Visual C++ . In order to get rid  cygwin1.dll
you must compile your files with -mno-cygwin option, for example:
gcc -mno-cygwin -c foo.c -o foo.o
gcc -mno-cygwin -c dllinit.c -o dllinit.o
And you must create dll with --target option, for example
dllwrap --target i386-mingw32 -mno-cygwin --dllname foo.dll foo.o
dllinit.o
After that you will get foo.dll file and so you can going to VC.
Note:
At first, you  must have something like dllinit.c file (see attachment).

At second, the algorithm described above is suitable only for C, not for
C++
language.

--------------5F9685F673F044173EEED2FC
Content-Type: text/html; charset=koi8-r
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
&nbsp;
<p>"S. Krishnaprasad" wrote:
<blockquote TYPE=CITE>&nbsp;<font color="#000000"><font size=-1>I have
useddllwrap --export-all mdll.dll mylib.a -L. -lgmp</font></font> <font color="#000000"><font size=-1>I
get the DLL file.But when I try to use it in a Visual C++ application it
gives me a undefined reference to the functionnames defined in this DLL.I
created a export .DEF file which is as follows</font></font> <font color="#000000"><font size=-1>LIBRARY
&lt;dllname>EXPORTS</font></font>&nbsp;<font color="#000000"><font size=-1>&nbsp;&nbsp;&nbsp;
function1&nbsp;&nbsp;&nbsp; function2</font></font> <font color="#000000"><font size=-1>etc..Then
I created a import file&nbsp; .lib using</font></font> <font color="#000000"><font size=-1>dllwrap
--dllname &lt;name.dll> --output-lib &lt;libname.lib></font></font> <font color="#000000"><font size=-1>This
created a .lib file</font></font>
<p>&nbsp;<font color="#000000"><font size=-1>This when linked into a Visual
C++ application it compiles and links properly but whenI try to run this
application it just terminates at the function call.</font></font> 
<font color="#000000"><font size=-1>Can
anybody help me.</font></font></blockquote>
Yes. In order to link dll you have to get library file. But you have to
use
<br>LIB.exe program from VisualStudio like that
<br>d:\DevStudio\VC\bin\LIB.EXE /DEF:foo.def
<br>After that you will get foo.lib file.
<p><font color="#000000"><font size=-1>>This when linked into a Visual
C++ application it compiles and links properly but when</font></font>
<br><font color="#000000"><font size=-1>>I try to run this application
it just terminates at the function call.</font></font>
<p>Due to program (as well dll) compiled with cygwin using cygwin1.dll
<br>you can not link it with Visual C++ . In order to get rid&nbsp; cygwin1.dll
<br>you must compile your files with -mno-cygwin option, for example:
<br>gcc -mno-cygwin -c foo.c -o foo.o
<br>gcc -mno-cygwin -c dllinit.c -o dllinit.o
<br>And you must create dll with --target option, for example
<br>dllwrap --target i386-mingw32 -mno-cygwin --dllname foo.dll foo.o dllinit.o
<br>After that you will get foo.dll file and so you can going to VC.
<br>Note:
<br>At first, you&nbsp; must have something like dllinit.c file (see attachment).
<br>At second, the algorithm described above is suitable only for C, not
for C++
<br>language.
</body>
</html>

--------------5F9685F673F044173EEED2FC--

--------------2D9B1EB428533349D97B8589
Content-Type: application/x-unknown-content-type-cfile;
 name="dllinit.c"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="dllinit.c"

LyogZGxsaW5pdC5jIC0tIFBvcnRhYmxlIERMTCBpbml0aWFsaXphdGlvbi4gCiAgIENvcHly
aWdodCAoQykgMTk5OCBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb24sIEluYy4KICAgQ29udHJp
YnV0ZWQgYnkgTXVtaXQgS2hhbiAoa2hhbkB4cmF5bGl0aC53aXNjLmVkdSkuCgogICBJJ3Zl
IHVzZWQgRGxsTWFpbiBhcyB0aGUgRExMICJtYWluIiBzaW5jZSB0aGF0J3MgdGhlIG1vc3Qg
Y29tbW9uIAogICB1c2FnZS4gTVNWQyBhbmQgTWluZ3czMiBib3RoIGRlZmF1bHQgdG8gRGxs
TWFpbiBhcyB0aGUgc3RhbmRhcmQKICAgY2FsbGJhY2sgZnJvbSB0aGUgbGlua2VyIGVudHJ5
IHBvaW50LiBDeWd3aW4zMiBiMTkrIHVzZXMgZXNzZW50aWFsbHkgCiAgIHRoZSBzYW1lLCBh
bGJlaXQgc2xpZ2h0bHkgZGlmZmVyZW50bHkgaW1wbGVtZW50ZWQsIHNjaGVtZS4gUGxlYXNl
CiAgIHNlZSBERUNMQVJFX0NZR1dJTl9ETEwgbWFjcm8gaW4gPGN5Z3dpbjMyL2N5Z3dpbl9k
bGwuaD4gZm9yIG1vcmUgCiAgIGluZm8gb24gaG93IEN5Z3dpbjMyIHVzZXMgdGhlIGNhbGxi
YWNrIGZ1bmN0aW9uLgoKICAgVGhlIHJlYWwgZW50cnkgcG9pbnQgaXMgdHl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hSRUFEX0RFVEFDSDoK
ICAgICAgYnJlYWs7CiAgICB9CiAgcmV0dXJuIFRSVUU7Cn0KCg==
--------------2D9B1EB428533349D97B8589--

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019