delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/06/04/20:21:14

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <20030605002104.54882.qmail@web21401.mail.yahoo.com>
Date: Thu, 5 Jun 2003 10:21:04 +1000 (EST)
From: =?iso-8859-1?q?Danny=20Smith?= <danny_r_smith_2001 AT yahoo DOT co DOT nz>
Subject: Re: Calling gcc built DLL from .NET (Visual Basic)
To: thoban AT verbalogic DOT com
Cc: cygwin AT cygwin DOT com
MIME-Version: 1.0

From: "Thomas X. Hoban" <thoban at verbalogic dot com> 
--------------------------------------------------------------------------------

> Does anyone have a good example that shows how to create a DLL using
> cygwin/gcc and call it using VB .NET?   I am specifically interested in an
> example that shows how to pass a String variable.  In the example that I
> show below, I am able to call a C function.  I can successfully pass a long
> integer.  But the string that I pass shows garbage in the called function.
> 
> My dll code looks like...
> 
> 
> (test.c)
> 
> #include <stdio.h>
> #include <wtypes.h>
> 
> define EXPORT __declspec(dllexport)
> 
> EXPORT int myTest(char *s1, long i1) {
> 
>     printf("Here is the string %s, here is the integer %ld.\n",s1, i1);
> 
> }
> 
> 

I think VB wants stdcall symbols.  Add WINAPI to above..


> 
> I then compile as follows:
> 
> $ gcc -c test.c
> $ gcc -shared -o test.dll test.o


and -Wl,--add-stdcall-alias when building dll to get undecorated symbol too. 

I don't have a clue about char* -> STRING marshalling. I would have just used
BSTR. 

Danny

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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