Mail Archives: cygwin/2000/10/09/18:29:18
"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 <iostream>
#include <string>
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 <string>
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 <ross DOT s AT ihug DOT co DOT nz> 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
- Raw text -