delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/01/15/16:17:47

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: <4.3.1.2.20030115160210.036f2680@pop.rcn.com>
X-Sender: lhall AT pop DOT rcn DOT com
Date: Wed, 15 Jan 2003 16:15:21 -0500
To: Jim Kleckner <jek-cygwin AT kleckner DOT net>, cygwin AT cygwin DOT com
From: "Larry Hall (RFK Partners, Inc)" <lhall AT rfk DOT com>
Subject: Re: Using gcc to build a DLL discovered and linked at runtime
In-Reply-To: <3E25A7EE.7050109@kleckner.net>
Mime-Version: 1.0

At 01:26 PM 1/15/2003, Jim Kleckner wrote:
>  I'm using a program called TradeStation that allows
>specifying a path name to a DLL, specifying the
>signature of a function to call, and then
>loading/calling that function.  The documentation is
>very sparse for how to do this and probably built in
>some way that depends in an obscure way on having a
>Microsoft compiler such as VisualC++ or VisualBasic to
>work properly.  I am trying to use GCC under cygwin to
>create a DLL that will dynamically open and running
>into roadblocks.
>
>A simple test file test.cpp:
>  #include "windef.h"
>  extern int __stdcall PPI(int);
>
>  __declspec(dllexport) int __stdcall PPI(int notused)
>  {
>      return 1;
>  }
>
>commands used:
>  gcc -shared -mno-cygwin -Wl,--export-dynamic -Wl,--export-all-symbols  
>-c vmi.cpp
>  dlltool -e exports.o vmi.o -l vmi.lib
>  gcc -shared -mno-cygwin -Wl,--export-dynamic -Wl,--export-all-symbols  
>-shared exports.o vmi.o -o vmi.dll
>
>The program just says "can't load user function".
>
>I have tried various combinations of commands but am
>wondering if there is something I'm missing.  I'm
>hoping to avoid getting out the ancient copy of VC5
>from my shelf...
>
>I will append cyg
>
>Thanks - Jim
>
>
>Resources for future travelers down this path:
>
>I have looked at a variety of sources describing
>using cygwin/gcc tools to build DLLs.
>
>The manual is here:
>  http://www.cygwin.com/cygwin-ug-net/dll.html
>
>This message contains a bug report with a complex
>example that is interesting to examine:
>  http://www.cygwin.com/ml/cygwin/2000-05/msg00663.html
>
>This one describes a "ld/dlltool/ld/dlltool/ld trick":
>  http://www.cygwin.com/ml/cygwin/2002-08/msg01002.html
>It suggests that what I am trying to do should be
>possible by just using the -shared flag.
>
>Christopher Faylor indicates that the cygwin dll
>cannot be linked at runtime because it is broken:
>  http://www.cygwin.com/ml/cygwin/2002-08/msg01042.html
>
>The dllhelpers stuff is also useful:
>  http://www.neuro.gatech.edu/users/cwilson/cygutils/dll-stuff/index.html


I assume the reason you're using the -mno-cygwin flag is because of 
Chris's comment.  Clearly what you're trying to do won't work if you 
link against the Cygwin DLL.  Using -mno-cygwin should remove cygwin1.dll
from the equation but just substituting MSCVRT.DLL for cygwin1.dll doesn't
mean that MSCVRT.DLL will load dynamically either.  I dunno but judging
by the fact that you're still having troubles, the assumption is suspect.  
However, since you're no longer linking against cygwin1.dll (which isn't 
going to work), you're really just using the mingw pseudo cross compiler of 
Cygwin's gcc (the -mno-cygwin switch) to produce a straight Win32 DLL.  In 
this context, it's really not a Cygwin question anymore (you could use 
mingw's gcc and presumably see the same problem... if not, then maybe that's 
your solution).  I'd recommend following up on this at mingw-users AT mingw DOT org 
if the mingw site doesn't have a solution for this problem.

Good luck,


Larry Hall                              lhall AT rfk DOT com
RFK Partners, Inc.                      http://www.rfk.com
838 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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