diff --git a/CHANGES.current b/CHANGES.current index 3e7ff5014..4432fa8a4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,11 @@ Version 1.3.18 (In progress) ============================ +02/13/2003: lenz + Updated Doc/Manual/Perl5.html to talk about C++ compile problems + configure.in now checks for PERL5_CCFLAGS + Runtime/Makefile.in and Example/Makefile.in now use PERL5_CCFLAGS + Added Lib/perl5/noembed.h which contains all the known macro conflicts + 02/12/2003: beazley Fixed [ 685410 ] C++ Explicit template instantiation causes SWIG to exit. Fixes a syntax error with declarations similar to this: diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 51152a657..a2e8e55a2 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -431,6 +431,24 @@ Solaris, you often need to add an extra library -lCrun like this: Of course, the names of the extra libraries are completely non-portable---you will probably need to do some experimentation. +

+Another possible compile problem comes from recent versions of Perl (5.8.0) and the GNU tools. +If you see errors having to do with _crypt_struct, that means _GNU_SOURCE is not defined and +it needs to be. So you should compile the wrapper like: + +

+% g++ -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE -D_GNU_SOURCE
+
+ +-D_GNU_SOURCE is also included in the Perl ccflags, which can be found by running +
+% perl -e 'use Config; print $Config{ccflags};'
+
+So you could also compile the wrapper like +
+% g++ -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE `perl -e 'use Config; print $Config{ccflags}'`
+
+

Sometimes people have suggested that it is necessary to relink the Perl interpreter using the C++ compiler to make C++ extension modules work. @@ -472,7 +490,7 @@ erratic program behavior. Also, be aware that certain C++ features, especially can behave strangely when working with multiple modules.

-Finally, it should be noted that you may get alot of error messages +It should be noted that you may get alot of error messages about the `bool' datatype when compiling a C++ Perl module. If you experience this problem, you can try the following :

@@ -482,6 +500,26 @@ you experience this problem, you can try the following :

  • Or use -Dbool=char when compiling. +

    +Finally, recent versions of Perl (5.8.0) have namespace conflict problems. Perl defines a bunch +of short macros to make the Perl API function names shorter. For example, in +/usr/lib/perl/5.8.0/CORE/embed.h there is a line: + +

    +#define do_open Perl_do_open
    +
    + +The problem is, in the <iostream> header from GNU libstdc++v3 there is a private +function named do_open. If <iostream> is included after the perl headers, then +the Perl macro causes the iostream do_open to be renamed, which causes compile errors. +Hopefully in the future Perl will support a PERL_NO_SHORT_NAMES flag, but for now the +only solution is to undef the macros that conflict. Lib/perl5/noembed.h in the SWIG +source has a list of macros that are known to conflict with either standard headers or +other headers. But if you get macro type conflicts from other macros not included +in Lib/perl5/noembed.h while compiling the wrapper, you will +have to find the macro that conflicts and add an #undef into the .i file. Please report +any conflicting macros you find to swig@cs.uchicago.edu. +

    17.2.7 Compiling for 64-bit platforms

    @@ -2460,6 +2498,6 @@ not even sure if it really works).


    -
    SWIG 1.3 - Last Modified : June 2, 2002
    +
    SWIG 1.3 - Last Modified : Feb 13, 2003
    - \ No newline at end of file + diff --git a/Examples/Makefile.in b/Examples/Makefile.in index cd0dcb336..e182c5986 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -178,13 +178,15 @@ PERL5_INCLUDE= @PERL5EXT@ # Extra Perl specific dynamic linking options PERL5_DLNK = @PERL5DYNAMICLINKING@ +PERL5_CCFLAGS = @PERL5CCFLAGS@ + # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C) # ---------------------------------------------------------------- perl5: $(SRCS) $(SWIG) -perl5 $(SWIGOPT) $(INTERFACE) - $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) + $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(LDSHARED) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) -o $(TARGET)$(SO) # ---------------------------------------------------------------- @@ -193,7 +195,7 @@ perl5: $(SRCS) perl5_cpp: $(SRCS) $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACE) - $(CXX) -c $(CCSHARED) $(CFLAGS) -Dexplicit= $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) + $(CXX) -c $(CCSHARED) $(CFLAGS) -Dexplicit= $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(CXXSHARED) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO) # ---------------------------------------------------------------- @@ -204,12 +206,12 @@ PERL5_RUNTIME=-L$(RUNTIMEDIR) -lswigpl@release_suffix@ perl5_multi: $(SRCS) $(SWIG) -c -perl5 $(SWIGOPT) $(INTERFACE) - $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) + $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(LDSHARED) $(OBJS) $(IOBJS) $(PERL5_RUNTIME) $(PERL5_DLNK) $(LIBS) -o $(TARGET)$(SO) perl5_multi_cpp: $(SRCS) $(SWIG) -c -perl5 -c++ $(SWIGOPT) $(INTERFACE) - $(CXX) -c $(CCSHARED) $(CFLAGS) -Dexplicit= $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) + $(CXX) -c $(CCSHARED) $(CFLAGS) -Dexplicit= $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(CXXSHARED) $(OBJS) $(IOBJS) $(PERL5_RUNTIME) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO) # ---------------------------------------------------------------- diff --git a/Lib/perl5/extra-install.list b/Lib/perl5/extra-install.list index d49f4150a..db93830aa 100644 --- a/Lib/perl5/extra-install.list +++ b/Lib/perl5/extra-install.list @@ -1,2 +1,2 @@ # see top-level Makefile.in -Makefile.pl +Makefile.pl noembed.h diff --git a/Lib/perl5/noembed.h b/Lib/perl5/noembed.h new file mode 100644 index 000000000..742c6eb0b --- /dev/null +++ b/Lib/perl5/noembed.h @@ -0,0 +1,51 @@ +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif diff --git a/Lib/perl5/perl5.swg b/Lib/perl5/perl5.swg index 3ac25646c..2293b6312 100644 --- a/Lib/perl5/perl5.swg +++ b/Lib/perl5/perl5.swg @@ -6,6 +6,7 @@ %runtime "common.swg" // common type checking code %runtime "perlrun.swg" // Perl runtime functions +%runtime "noembed.h" // undefine Perl5 macros /* Typemaps for input parameters */ diff --git a/Runtime/Makefile.in b/Runtime/Makefile.in index b5001d4b6..11a719e6d 100644 --- a/Runtime/Makefile.in +++ b/Runtime/Makefile.in @@ -101,6 +101,7 @@ libswigpy$(RELEASESUFFIX).la: PERL5_INCLUDE = -I@PERL5EXT@ PERL5_RUNTIME = $(SWIGLIB)/perl5/perlrun.swg +PERL5_CCFLAGS = @PERL5CCFLAGS@ # Perl shared @@ -110,7 +111,7 @@ libswigpl$(RELEASESUFFIX).la: $(srcdir)/$(SWIG_TYPECHECK) $(srcdir)/$(PERL5_RUNT @rm -f libperl.c # cat $(srcdir)/perlrun.h >> libperl.c cat $(srcdir)/$(SWIG_TYPECHECK) $(srcdir)/$(PERL5_RUNTIME) >> libperl.c - $(LIBTOOL) $(CC) -c $(PERL5_INCLUDE) -DSWIG_GLOBAL -Dbool=char -Dexplicit= libperl.c + $(LIBTOOL) $(CC) -c $(PERL5_INCLUDE) -DSWIG_GLOBAL -Dbool=char -Dexplicit= $(PERL5_CCFLAGS) libperl.c $(LIBTOOL) $(CC) -o libswigpl$(RELEASESUFFIX).la libperl.lo -rpath $(LIB_DIR) -avoid-version # ---------------------------------------------------------------------- diff --git a/configure.in b/configure.in index e9556cf5c..d3228b245 100644 --- a/configure.in +++ b/configure.in @@ -588,6 +588,13 @@ if test -n "$PERL"; then else AC_MSG_RESULT($PERL5LIB) fi + AC_MSG_CHECKING(for Perl5 compiler options) + PERL5CCFLAGS=`($PERL -e 'use Config; print $Config{ccflags}') 2>/dev/null` + if test "$PERL5CCFLAGS" = "" ; then + AC_MSG_RESULT(not found) + else + AC_MSG_RESULT($PERL5CCFLAGS) + fi else AC_MSG_RESULT(unable to determine perl5 configuration) PERL5EXT=$PERL5DIR @@ -606,6 +613,7 @@ esac AC_SUBST(PERL5EXT) AC_SUBST(PERL5DYNAMICLINKING) AC_SUBST(PERL5LIB) +AC_SUBST(PERL5CCFLAGS) # kludges to ease naming conventions conformance. ( cd Examples ;