delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/07/13/15:33:54

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
Date: Tue, 13 Jul 2004 12:33:36 -0700
From: Lester Ingber <ingber AT ingber DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: need -mrtd to create Excel DLL?
Message-ID: <20040713193336.GA2648@ingber.com>
Mime-Version: 1.0
User-Agent: Mutt/1.4.1i

Siegfried:

Hi. I did not use any __declspec keywords, etc. -- just vanilla C
code which runs as well under gcc or g++ under Cygwin, FreeBSD, or
SPARC/Solaris, etc.  Creating DLLs is another matter -- I've just tested
this using Cygwin/gcc under XP Pro.  As I said, I cannot get this to
work under Cygwin/g++.

I tested the application with Excel using the dlltest.xls file in
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/
but without the other modifications in his cdll.[ch] files.
To use his dlltest.xls, I named my DLL the same, and created
double dll_double_square (double d)
as one of my functions which called a series of other functions in other
files before returning.

I used the following lines in my Makefile.  No other special code changes
were required in any of my .c or .h files:

CC = gcc
MY_OBJS = \
[.o files]

DLL_OPTION=-mrtd # needed for Excel DLL
CYGWIN_OPTION=-mno-cygwin $(DLL_OPTION)
CDEBUGFLAGS = -g -O2 -Wall
CFLAGS = $(CDEBUGFLAGS) $(CYGWIN_OPTION)

dllmodule = cdll
obj_libs = $(MY_OBJS)
dependency_libs = -lm

# no need for run.exe when creating DLLs -- without a main()
compile: $(MY_OBJS)
	@$(CC) -o run.exe $(MY_OBJS) ${dependency_libs}

cdll:
	make -i compile
	$(CC) $(CFLAGS) -shared -o ${dllmodule}.dll \
	-Wl,--out-implib=${dllmodule}.lib \
	-Wl,--compat-implib \
	-Wl,--add-stdcall-alias \
	-Wl,--enable-stdcall-fixup \
	-Wl,--enable-auto-import \
	-Wl,--enable-auto-image-base \
	-Wl,--whole-archive ${obj_libs} \
	-Wl,--export-all-symbols \
	-Wl,--output-def=${dllmodule}.def \
	-Wl,--no-whole-archive ${dependency_libs}

Lester

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

:: I was able to create a dll from many C files, representing fairly complex
:: calculations, using the following in my Makefile, without having to add
:: any keywords like "__declspec", using info from the Cygwin docs.
:: ...
:: Lester


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