Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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: <3E2753C9.4040008@kleckner.net> Date: Thu, 16 Jan 2003 16:52:25 -0800 From: Jim Kleckner User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3 X-Accept-Language: en-us MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: RESOLVED: Using gcc to build a DLL discovered and linked at runtime References: <3E25A7EE DOT 7050109 AT kleckner DOT net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit After carefully inspecting the symbols from generated dlls and dlls provided by TradeStation, I found that symbols occurred with and without the @decorations. e.g. PPI AT 4 and PPI. Adding -Wl,--add-stdcall-alias to the gcc line, all worked fine. Could this generally be a requirement for dlls that are opened at runtime in a fashion similar to dlopen? If so, then some FAQ annotation would be in order here: http://www.cygwin.com/cygwin-ug-net/dll.html Jim 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 > > > [snip] -- 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/