Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-Authentication-Warning: smtp4.ihug.co.nz: Host animal.ihug.co.nz [203.29.161.168] claimed to be ihug.co.nz Message-ID: <39E2468B.BFDD3AB7@ihug.co.nz> Date: Tue, 10 Oct 2000 11:28:27 +1300 From: Ross Smith Organization: Ihug X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: cygwin AT sourceware DOT cygnus DOT com Subject: Re: AW: Linking Dynamic Libraries References: <004501c031f0$10478ad0$0d33028b AT zapperlot DOT materna DOT de> <39E1CC08 DOT F475851F AT ece DOT gatech DOT edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit "Charles S. Wilson" wrote: > > There's an easier way -- one command! 'gcc -shared' will create a dll > for you. Just do: > > $(BASE)=foo > > gcc -shared -o cyg$(BASE).dll -Wl,--out-implib=lib$(BASE).dll.a \ > -Wl,--export-all -Wl,--enable-auto-image-base \ > -Wl,--output-def=cyg$(BASE).def $(OBJS) I can't get this to work. Whenever I link with the import lib produced this way, the resulting program crashes with a STATUS_ACCESS_VIOLATION. (See attached code.) I don't even need to call any of the DLL functions to trigger it -- just linking with -lfoo makes it unworkable. What am I doing wrong? And where is all this stuff documented anyway? The ld docs mention --export-all-symbols (not --export-all), but not any of the others. -------------------- cut here -------------------- // demo.cpp #include "foo.hpp" #include #include int main() { std::string thing("thing"); std::cout << thing << std::endl; // std::cout << global_mangle(thing) << std::endl; return 0; } -------------------- cut here -------------------- // foo.hpp #ifndef FOO_HEADER #define FOO_HEADER #include extern std::string global_mangle(const std::string& source); #endif -------------------- cut here -------------------- // foo.cpp #include "foo.hpp" std::string global_mangle(const std::string& source) { return source + "_global"; } -------------------- cut here -------------------- // Makefile DLLNAME = foo DLLOBJ = foo.o EXENAME = demo EXEOBJ = demo.o CPLUS = g++ -W -Wall -Werror LINKDLL = g++ -shared -Wl,--export-all -Wl,--enable-auto-image-base LINKEXE = g++ -L. .DELETE_ON_ERROR: .PHONY: all clean all: $(DLLNAME).dll $(EXENAME) clean: rm -f $(DLLOBJ) $(DLLNAME).dll lib$(DLLNAME).a $(EXEOBJ) $(EXENAME).exe %.o: %.cpp $(CPLUS) -c $< -o $@ $(DLLNAME).dll: $(DLLOBJ) $(LINKDLL) $(DLLOBJ) -o $(DLLNAME).dll -Wl,--out-implib=lib$(DLLNAME).a $(EXENAME): $(EXEOBJ) $(DLLNAME).dll $(LINKEXE) $(EXEOBJ) -l$(DLLNAME) -o $(EXENAME) demo.o: demo.cpp foo.hpp foo.o: foo.cpp foo.hpp -------------------- cut here -------------------- -- Ross Smith The Internet Group, Auckland, New Zealand ======================================================================== "C++ is to programming as sex is to reproduction. Better ways might technically exist but they're not nearly as much fun." -- Nikolai Irgens -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com