Bug reported by Ross Ridge to mingw users list When building libgcj for windows targets, libtool puts -DDLL_EXPORT in compiler flag:
mingw* | cygwin* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; However that -D is a preprocessor flag (not a proper compiler switch) gcj gives -D a different meaning: from jvspec.c:lang_specific_driver if (saw_D && ! main_class_name) fatal ("can't specify '-D' without '--main'\n"); As a result, libtool build of shared libgcj fails with: bin/bash ./libtool --tag=GCJ --mode=compile /src/gcc/obj/gcc/gcj -B/src/gcc/obj/mingw32/libjava/ -B/src/gcc/obj/gcc/ -ffloat-store -fomit-frame-pointer -Usun -fno-omit-frame-pointer -fclasspath= -fbootclasspath=../../../gcc/libjava/classpath/lib --encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -c -o java/lang/Object.lo -fsource-filename=../../../gcc/libjava/java/lang/Object.java ../../../gcc/libjava/classpath/lib/java/lang/Object.class libtool: compile: /src/gcc/obj/gcc/gcj -B/src/gcc/obj/mingw32/libjava/ -B/src/gcc/obj/gcc/ -ffloat-store -fomit-frame-pointer -Usun -fno-omit-frame-pointer -fclasspath= -fbootclasspath=../../../gcc/libjava/classpath/lib --encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -c -fsource-filename=../../../gcc/libjava/java/lang/Object.java ../../../gcc/libjava/classpath/lib/java/lang/Object.class -DDLL_EXPORT -o java/lang/.libs/Object.o gcj.exe: can't specify '-D' without '--main' -- Summary: liblt_prog_compiler_pic_GCJ='-DDLL_EXPORT' is wrong Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgcj AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dannysmith at users dot sourceforge dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33085