delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/07/13/14:58:25

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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
From: "Siegfried Heintze" <siegfried AT heintze DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: need -mrtd to create Excel DLL?
Date: Tue, 13 Jul 2004 12:57:55 -0600
MIME-Version: 1.0
In-Reply-To: <20040713173933.GA2492@ingber.com>
Message-Id: <200407131259156.SM01156@fasolt>
X-IsSubscribed: yes

Lester,
 It works! Thank you. Assuming these will be archived, maybe this can help
someone else.

Since I'm wondering if Excel was caching something, I decided to use C# and
it works!
 Thanks,
    Siegfried

Here is the example of calling cygwin C from C#:
------begin here ------

//  Begin commands to execute this file using MS.NET with bash
//  cat <<EOF >cdll.h
//  #ifndef cdll_h_included

//  #define cdll_h_included

//

//  /*

//   * When building the DLL code, you should define BUILDING_DLL so that

//   * the variables/functions are exported correctly. When using the DLL,

//   * do NOT define BUILDING_DLL, and then the variables/functions will

//   * be imported correctly.

//   *

//   * You need to be using egcs-1.1.1 or newer.

//   *

//   * Building the DLL:

//   *  - define BUILDING_DLL, which defines DLLIMPORT
__attribute__((dllexport))

//   * Building the client code:

//   *  - DO NOT define BUILDING_DLL, which defines DLLIMPORT to be one

//   *    __attribute__((dllimport))

//   */

//

//  #if BUILDING_DLL

//  # define DLLIMPORT __declspec (dllexport)

//  #else /* Not BUILDING_DLL */

//  # define DLLIMPORT __declspec (dllimport)

//  #endif /* Not BUILDING_DLL */

//

//  DLLIMPORT double dll_double_square (double);

//  #endif /* cdll_h_included */

//  EOF
//  cat <<EOF >cdll.c
//  #include "cdll.h"                     
//  DLLIMPORT double                      
//  dll_double_square (double d)          
//  {                                     
//    return d * d;                       
//  }                                     
//  EOF
//  gcc cdll.c -DBUILDING_DLL=1 -mrtd -g -O2 -Wall -mno-cygwin -mrtd -shared
-o cdll.dll -Wl,--out-implib=cdll.lib -Wl,--compat-implib
-Wl,--add-stdcall-alias -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import
-Wl,--enable-auto-image-base  -Wl,--export-all-symbols
-Wl,--output-def=cdll.def -Wl,--no-whole-archive 
//  c:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/csc  /checked /incr /debug
/out:test.exe test.cs
//  ./test 4 2 10 2.3 4.23
//  rm test.exe
//  rm test.exe.incr
//  rm test.pdb
//  End commands to execute this file using MS.NET with bash


class test {
  [System.Runtime.InteropServices.DllImport ("cdll.dll",
CallingConvention=System.Runtime.InteropServices.CallingConvention.Cdecl)]
       public static extern double dll_double_square(double d);
  static public void Main(string[] args){
    System.Console.WriteLine("hello");
    for(int ii = 0; ii<args.Length; ii++) 
      System.Console.WriteLine("args["+ii+"]="+double.Parse(args[ii]) + "
Square = " + dll_double_square(double.Parse(args[ii])));
  }
}

----- end of file -----

Here is an example of calling g77 from from C#:
--------------------begin file here----
/**
 * Begin commands to execute this file using MS.NET with bash
 * cat <<EOF >f77dll.f
 *          function dll_double_square_f77 (value)
 *          double precision dll_double_square_f77, value
 *          print*, '  dll_double_square_f77 value=', value
 *          dll_double_square_f77 = value**2
 *          return
 *          end
 * EOF
 * g77 f77dll.f -DBUILDING_DLL=1 -mrtd -g -O2 -Wall -mno-cygwin -mrtd
-shared -o f77dll.dll -Wl,--out-implib=f77dll.lib -Wl,--compat-implib
-Wl,--add-stdcall-alias -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import
-Wl,--enable-auto-image-base  -Wl,--export-all-symbols
-Wl,--output-def=f77dll.def -Wl,--no-whole-archive 
 * c:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/csc  /checked /incr /debug
/out:test.exe test.cs
 * ./test 4 2 10 2.3 4.23
 * rm test.exe
 * rm test.exe.incr
 * rm test.pdb
 * End commands to execute this file using MS.NET with bash
 */

class test {
  [System.Runtime.InteropServices.DllImport ("f77dll.dll",
CallingConvention=System.Runtime.InteropServices.CallingConvention.Cdecl)]
       public static extern double dll_double_square_f77__(ref double d);
  static public void Main(string[] args){
    System.Console.WriteLine("hello");
    for(int ii = 0; ii<args.Length; ii++) {
      double x = double.Parse(args[ii]);
      System.Console.WriteLine("args["+ii+"]="+x + " Square = " +
dll_double_square_f77__(ref x));
    }
  }
}
--------------------end file here-------------



--
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