Fix to linking problem for Linux in examples.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10600 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2620bb218c
commit
cdd920a6ca
9 changed files with 71 additions and 34 deletions
|
|
@ -1098,15 +1098,18 @@ r_clean:
|
||||||
# Build a C dynamically loadable module
|
# Build a C dynamically loadable module
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
CLIBPREFIX = lib
|
||||||
|
|
||||||
c: $(SRCS)
|
c: $(SRCS)
|
||||||
$(SWIG) -c $(SWIGOPT) $(INTERFACE)
|
$(SWIG) -c $(SWIGOPT) $(INTERFACE)
|
||||||
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES)
|
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES)
|
||||||
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(SO)
|
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(CLIBPREFIX)$(TARGET)$(SO)
|
||||||
$(CC) $(MAIN) $(TARGET)_proxy.c -L. -l$(LIBPREFIX)_$(TARGET)
|
$(CC) $(MAIN) $(TARGET)_proxy.c -L. -l$(TARGET)
|
||||||
|
LD_LIBRARY_PATH=`pwd`:LD_LIBRARY_PATH; export LD_LIBRARY_PATH
|
||||||
|
|
||||||
c_cpp: $(SRCS)
|
c_cpp: $(SRCS)
|
||||||
$(SWIG) -c++ -c $(SWIGOPT) $(INTERFACE)
|
$(SWIG) -c++ -c $(SWIGOPT) $(INTERFACE)
|
||||||
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
|
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
|
||||||
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(SO)
|
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(CLIBPREFIX)$(TARGET)$(SO)
|
||||||
$(CC) $(MAIN) $(TARGET)_proxy.c -L. -l$(LIBPREFIX)_$(TARGET)
|
$(CC) $(MAIN) $(TARGET)_proxy.c -L. -l$(TARGET)
|
||||||
|
LD_LIBRARY_PATH=`pwd`:LD_LIBRARY_PATH; export LD_LIBRARY_PATH
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,5 @@ all::
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm *.o
|
rm -f *.o *.out *.so *.a
|
||||||
|
|
||||||
|
|
|
||||||
6
Examples/c/class/test.sh
Executable file
6
Examples/c/class/test.sh
Executable file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
./a.out
|
||||||
|
|
||||||
|
|
@ -10,5 +10,5 @@ all::
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm *.o
|
rm -f *.o *.so *.out *.a *~
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ int main(int argc, char **argv) {
|
||||||
printf("Foo is %f\n", Foo);
|
printf("Foo is %f\n", Foo);
|
||||||
printf("Foo by ptr is \%f\n", *Foo_ptr);
|
printf("Foo by ptr is \%f\n", *Foo_ptr);
|
||||||
printf("my_str is: %s\n", my_str);
|
printf("my_str is: %s\n", my_str);
|
||||||
printf("array_of_strs contains %s and %s\n", get_str(0), get_str(1));
|
|
||||||
printf("GCD(%d, %d)=%d\n", a, b, gcd(a, b));
|
printf("GCD(%d, %d)=%d\n", a, b, gcd(a, b));
|
||||||
|
printf("array_of_strs contains %s and %s\n", get_str(0), get_str(1));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
6
Examples/c/simple/test.sh
Executable file
6
Examples/c/simple/test.sh
Executable file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
./a.out
|
||||||
|
|
||||||
|
|
@ -69,19 +69,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void emitSwigExport(File *f) {
|
void emitSwigProtectSymbols(File *f) {
|
||||||
Printf(f, "#ifndef SWIGEXPORT\n");
|
Printf(f, "#ifndef SWIGPROTECT\n");
|
||||||
Printf(f, "# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n");
|
Printf(f, "# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n");
|
||||||
Printf(f, "# if defined(STATIC_LINKED)\n");
|
Printf(f, "# define SWIGPROTECT //\n");
|
||||||
Printf(f, "# define SWIGEXPORT\n");
|
|
||||||
Printf(f, "# else\n");
|
|
||||||
Printf(f, "# define SWIGEXPORT __declspec(dllexport)\n");
|
|
||||||
Printf(f, "# endif\n");
|
|
||||||
Printf(f, "# else\n");
|
Printf(f, "# else\n");
|
||||||
Printf(f, "# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)\n");
|
Printf(f, "# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)\n");
|
||||||
Printf(f, "# define SWIGEXPORT __attribute__ ((visibility(\"default\")))\n");
|
Printf(f, "# define SWIGPROTECT __attribute__ ((visibility(\"protected\")))\n");
|
||||||
Printf(f, "# else\n");
|
Printf(f, "# else\n");
|
||||||
Printf(f, "# define SWIGEXPORT\n");
|
Printf(f, "# define SWIGPROTECT //\n");
|
||||||
Printf(f, "# endif\n");
|
Printf(f, "# endif\n");
|
||||||
Printf(f, "# endif\n");
|
Printf(f, "# endif\n");
|
||||||
Printf(f, "#endif\n\n");
|
Printf(f, "#endif\n\n");
|
||||||
|
|
@ -121,6 +117,7 @@ public:
|
||||||
f_wrappers = NewString("");
|
f_wrappers = NewString("");
|
||||||
|
|
||||||
Swig_banner(f_runtime);
|
Swig_banner(f_runtime);
|
||||||
|
emitSwigProtectSymbols(f_header);
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
Printf(f_header, "#include <malloc.h>\n\n");
|
Printf(f_header, "#include <malloc.h>\n\n");
|
||||||
|
|
@ -238,7 +235,6 @@ public:
|
||||||
SwigType *return_type = Getattr(n, "type");
|
SwigType *return_type = Getattr(n, "type");
|
||||||
String *return_type_str = SwigType_str(return_type, 0);
|
String *return_type_str = SwigType_str(return_type, 0);
|
||||||
String *arg_names = NewString("");
|
String *arg_names = NewString("");
|
||||||
String *arg_lnames = NewString("");
|
|
||||||
ParmList *parms = Getattr(n, "parms");
|
ParmList *parms = Getattr(n, "parms");
|
||||||
|
|
||||||
// create new function wrapper object
|
// create new function wrapper object
|
||||||
|
|
@ -261,7 +257,6 @@ public:
|
||||||
SwigType *type = Getattr(p, "type");
|
SwigType *type = Getattr(p, "type");
|
||||||
Printv(wrapper->def, SwigType_str(type, 0), " ", Getattr(p, "lname"), np ? ", " : "", NIL);
|
Printv(wrapper->def, SwigType_str(type, 0), " ", Getattr(p, "lname"), np ? ", " : "", NIL);
|
||||||
Printv(arg_names, Getattr(p, "name"), np ? ", " : "", NIL);
|
Printv(arg_names, Getattr(p, "name"), np ? ", " : "", NIL);
|
||||||
Printv(arg_lnames, Getattr(p, "lname"), np ? ", " : "", NIL);
|
|
||||||
p = np;
|
p = np;
|
||||||
}
|
}
|
||||||
Printv(wrapper->def, ") {", NIL);
|
Printv(wrapper->def, ") {", NIL);
|
||||||
|
|
@ -300,7 +295,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// emit proxy functions prototypes
|
// emit proxy functions prototypes
|
||||||
Printv(f_shadow_code_init, "extern ", return_type_str, " _wrap_", name, "(", proto, ");\n", NIL);
|
Printv(f_shadow_code_init, "extern ", return_type_str, " ", wname, "(", proto, ");\n", NIL);
|
||||||
Printv(f_shadow_code_body, return_type_str, " ", name, "(", proto, ") {\n", NIL);
|
Printv(f_shadow_code_body, return_type_str, " ", name, "(", proto, ") {\n", NIL);
|
||||||
|
|
||||||
// handle 'prepend' feature
|
// handle 'prepend' feature
|
||||||
|
|
@ -334,8 +329,13 @@ public:
|
||||||
Printv(f_shadow_header, return_type_str, " ", name, "(", proto, ");\n");
|
Printv(f_shadow_header, return_type_str, " ", name, "(", proto, ");\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add visibility hint for the compiler
|
||||||
|
String* vis_hint = NewString("");
|
||||||
|
Printv(vis_hint, "SWIGPROTECT ", return_type_str, " ", name, "(", ParmList_str(parms), ");\n", NIL);
|
||||||
|
Printv(f_init, vis_hint, NIL);
|
||||||
|
Delete(vis_hint);
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
Delete(arg_lnames);
|
|
||||||
Delete(arg_names);
|
Delete(arg_names);
|
||||||
Delete(wname);
|
Delete(wname);
|
||||||
DelWrapper(wrapper);
|
DelWrapper(wrapper);
|
||||||
|
|
|
||||||
24
Tools/config/config.guess
vendored
24
Tools/config/config.guess
vendored
|
|
@ -4,7 +4,7 @@
|
||||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||||
# Inc.
|
# Inc.
|
||||||
|
|
||||||
timestamp='2006-07-02'
|
timestamp='2007-03-06'
|
||||||
|
|
||||||
# This file is free software; you can redistribute it and/or modify it
|
# This file is free software; you can redistribute it and/or modify it
|
||||||
# under the terms of the GNU General Public License as published by
|
# under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -161,6 +161,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||||
arm*) machine=arm-unknown ;;
|
arm*) machine=arm-unknown ;;
|
||||||
sh3el) machine=shl-unknown ;;
|
sh3el) machine=shl-unknown ;;
|
||||||
sh3eb) machine=sh-unknown ;;
|
sh3eb) machine=sh-unknown ;;
|
||||||
|
sh5el) machine=sh5le-unknown ;;
|
||||||
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
|
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
|
||||||
esac
|
esac
|
||||||
# The Operating System including object format, if it has switched
|
# The Operating System including object format, if it has switched
|
||||||
|
|
@ -780,7 +781,7 @@ EOF
|
||||||
i*:CYGWIN*:*)
|
i*:CYGWIN*:*)
|
||||||
echo ${UNAME_MACHINE}-pc-cygwin
|
echo ${UNAME_MACHINE}-pc-cygwin
|
||||||
exit ;;
|
exit ;;
|
||||||
i*:MINGW*:*)
|
*:MINGW*:*)
|
||||||
echo ${UNAME_MACHINE}-pc-mingw32
|
echo ${UNAME_MACHINE}-pc-mingw32
|
||||||
exit ;;
|
exit ;;
|
||||||
i*:windows32*:*)
|
i*:windows32*:*)
|
||||||
|
|
@ -790,12 +791,15 @@ EOF
|
||||||
i*:PW*:*)
|
i*:PW*:*)
|
||||||
echo ${UNAME_MACHINE}-pc-pw32
|
echo ${UNAME_MACHINE}-pc-pw32
|
||||||
exit ;;
|
exit ;;
|
||||||
x86:Interix*:[3456]*)
|
*:Interix*:[3456]*)
|
||||||
|
case ${UNAME_MACHINE} in
|
||||||
|
x86)
|
||||||
echo i586-pc-interix${UNAME_RELEASE}
|
echo i586-pc-interix${UNAME_RELEASE}
|
||||||
exit ;;
|
exit ;;
|
||||||
EM64T:Interix*:[3456]*)
|
EM64T | authenticamd)
|
||||||
echo x86_64-unknown-interix${UNAME_RELEASE}
|
echo x86_64-unknown-interix${UNAME_RELEASE}
|
||||||
exit ;;
|
exit ;;
|
||||||
|
esac ;;
|
||||||
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
|
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
|
||||||
echo i${UNAME_MACHINE}-pc-mks
|
echo i${UNAME_MACHINE}-pc-mks
|
||||||
exit ;;
|
exit ;;
|
||||||
|
|
@ -950,6 +954,9 @@ EOF
|
||||||
x86_64:Linux:*:*)
|
x86_64:Linux:*:*)
|
||||||
echo x86_64-unknown-linux-gnu
|
echo x86_64-unknown-linux-gnu
|
||||||
exit ;;
|
exit ;;
|
||||||
|
xtensa:Linux:*:*)
|
||||||
|
echo xtensa-unknown-linux-gnu
|
||||||
|
exit ;;
|
||||||
i*86:Linux:*:*)
|
i*86:Linux:*:*)
|
||||||
# The BFD linker knows what the default object file format is, so
|
# The BFD linker knows what the default object file format is, so
|
||||||
# first see if it will tell us. cd to the root directory to prevent
|
# first see if it will tell us. cd to the root directory to prevent
|
||||||
|
|
@ -1208,6 +1215,15 @@ EOF
|
||||||
SX-6:SUPER-UX:*:*)
|
SX-6:SUPER-UX:*:*)
|
||||||
echo sx6-nec-superux${UNAME_RELEASE}
|
echo sx6-nec-superux${UNAME_RELEASE}
|
||||||
exit ;;
|
exit ;;
|
||||||
|
SX-7:SUPER-UX:*:*)
|
||||||
|
echo sx7-nec-superux${UNAME_RELEASE}
|
||||||
|
exit ;;
|
||||||
|
SX-8:SUPER-UX:*:*)
|
||||||
|
echo sx8-nec-superux${UNAME_RELEASE}
|
||||||
|
exit ;;
|
||||||
|
SX-8R:SUPER-UX:*:*)
|
||||||
|
echo sx8r-nec-superux${UNAME_RELEASE}
|
||||||
|
exit ;;
|
||||||
Power*:Rhapsody:*:*)
|
Power*:Rhapsody:*:*)
|
||||||
echo powerpc-apple-rhapsody${UNAME_RELEASE}
|
echo powerpc-apple-rhapsody${UNAME_RELEASE}
|
||||||
exit ;;
|
exit ;;
|
||||||
|
|
|
||||||
16
Tools/config/config.sub
vendored
16
Tools/config/config.sub
vendored
|
|
@ -4,7 +4,7 @@
|
||||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||||
# Inc.
|
# Inc.
|
||||||
|
|
||||||
timestamp='2006-09-20'
|
timestamp='2007-01-18'
|
||||||
|
|
||||||
# This file is (in principle) common to ALL GNU software.
|
# This file is (in principle) common to ALL GNU software.
|
||||||
# The presence of a machine in this file suggests that SOME GNU software
|
# The presence of a machine in this file suggests that SOME GNU software
|
||||||
|
|
@ -245,12 +245,12 @@ case $basic_machine in
|
||||||
| bfin \
|
| bfin \
|
||||||
| c4x | clipper \
|
| c4x | clipper \
|
||||||
| d10v | d30v | dlx | dsp16xx \
|
| d10v | d30v | dlx | dsp16xx \
|
||||||
| fr30 | frv \
|
| fido | fr30 | frv \
|
||||||
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||||
| i370 | i860 | i960 | ia64 \
|
| i370 | i860 | i960 | ia64 \
|
||||||
| ip2k | iq2000 \
|
| ip2k | iq2000 \
|
||||||
| m32c | m32r | m32rle | m68000 | m68k | m88k \
|
| m32c | m32r | m32rle | m68000 | m68k | m88k \
|
||||||
| maxq | mb | microblaze | mcore \
|
| maxq | mb | microblaze | mcore | mep \
|
||||||
| mips | mipsbe | mipseb | mipsel | mipsle \
|
| mips | mipsbe | mipseb | mipsel | mipsle \
|
||||||
| mips16 \
|
| mips16 \
|
||||||
| mips64 | mips64el \
|
| mips64 | mips64el \
|
||||||
|
|
@ -324,7 +324,7 @@ case $basic_machine in
|
||||||
| clipper-* | craynv-* | cydra-* \
|
| clipper-* | craynv-* | cydra-* \
|
||||||
| d10v-* | d30v-* | dlx-* \
|
| d10v-* | d30v-* | dlx-* \
|
||||||
| elxsi-* \
|
| elxsi-* \
|
||||||
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
|
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
|
||||||
| h8300-* | h8500-* \
|
| h8300-* | h8500-* \
|
||||||
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
|
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
|
||||||
| i*86-* | i860-* | i960-* | ia64-* \
|
| i*86-* | i860-* | i960-* | ia64-* \
|
||||||
|
|
@ -925,6 +925,9 @@ case $basic_machine in
|
||||||
basic_machine=sh-hitachi
|
basic_machine=sh-hitachi
|
||||||
os=-hms
|
os=-hms
|
||||||
;;
|
;;
|
||||||
|
sh5el)
|
||||||
|
basic_machine=sh5le-unknown
|
||||||
|
;;
|
||||||
sh64)
|
sh64)
|
||||||
basic_machine=sh64-unknown
|
basic_machine=sh64-unknown
|
||||||
;;
|
;;
|
||||||
|
|
@ -1219,7 +1222,7 @@ case $os in
|
||||||
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
||||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
||||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
|
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
|
||||||
| -skyos* | -haiku* | -rdos* | -toppers*)
|
| -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
|
||||||
# Remember, each alternative MUST END IN *, to match a version number.
|
# Remember, each alternative MUST END IN *, to match a version number.
|
||||||
;;
|
;;
|
||||||
-qnx*)
|
-qnx*)
|
||||||
|
|
@ -1414,6 +1417,9 @@ case $basic_machine in
|
||||||
m68*-cisco)
|
m68*-cisco)
|
||||||
os=-aout
|
os=-aout
|
||||||
;;
|
;;
|
||||||
|
mep-*)
|
||||||
|
os=-elf
|
||||||
|
;;
|
||||||
mips*-cisco)
|
mips*-cisco)
|
||||||
os=-elf
|
os=-elf
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue