From: jwilson <jwi...@gm...> - 2013-02-25 01:57:24
|
Greetings SWIG Community, I've got a SWIG project that generates a Ruby C API wrapper for a C++ static archive library. I don't have any problems generating and compiling the code under 64-bit Linux (tested under Fedora and Debian). Unfortunately, the OS X version of the archive is 32-bit only. I built a 32 bit version of SWIG in OS X: / $file /usr/local/bin/swig /usr/local/bin/swig: Mach-O executable i386/ I've also built a 32 bit version of Ruby on OS X in order to generate, compile, and link the shared object that will be used as the Ruby C Native Extension: / $ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [i386-darwin11]/ All objects are compiled with the -m32 flag: / $ g++ -m32 -Wall -g -c -fPIC -rdynamic ../src/CPPExampleWrapper.cpp ../src/CPPExampleException.cpp ../src/CPPExampleObject.cpp ../src/CPPExampleCallbackFunctor.cpp -I../include/ -I../lib/include// and linked accordingly: /g++ -m32 -shared -fPIC -o ../lib/cppexample.so ./bin/CPPExampleWrapper.o ../qa_cpp_utils/bin/CPPExampleObject.o ../qa_cpp_utils/bin/CPPExampleCallbackFunctor.o ../qa_cpp_utils/lib/libcppexamplearchive.a -framework CoreFoundation -lpthread/ On linking, I receive an error indicating that symbols referenced in CPPExampleWrapper.o are undefined for architecture i386: /Undefined symbols for architecture i386: "_rb_big2long", referenced from: SWIG_AUX_NUM2LONG(unsigned long*)in CPPExampleWrapper.o "_rb_big2ulong", referenced from: SWIG_AUX_NUM2ULONG(unsigned long*)in CPPExampleWrapper.o "_rb_cFalseClass", referenced from: _rb_class_of in CPPExampleWrapper.o "_rb_cFixnum", referenced from: _rb_class_of in CPPExampleWrapper.o "_rb_cNilClass", referenced from: _rb_class_of in CPPExampleWrapper.o "_rb_cObject", referenced from: _Init_CPPExample in CPPExampleWrapper.o _SWIG_Ruby_SetModule in CPPExampleWrapper.o _SWIG_Ruby_define_class in CPPExampleWrapper.o "_rb_cSymbol", referenced from: _rb_class_of in CPPExampleWrapper.o "_rb_cTrueClass", referenced from: _rb_class_of in CPPExampleWrapper.o "_rb_check_type", referenced from: _SWIG_Ruby_GetModule in CPPExampleWrapper.o _SWIG_Ruby_ConvertPtrAndOwn in CPPExampleWrapper.o "_rb_const_get", referenced from: _SWIG_Ruby_NewPointerObj in CPPExampleWrapper.o "_rb_data_object_alloc", referenced from: _SWIG_Ruby_SetModule in CPPExampleWrapper.o _SWIG_Ruby_NewClassInstance in CPPExampleWrapper.o _SWIG_Ruby_NewPointerObj in CPPExampleWrapper.o "_rb_define_alloc_func", referenced from: _Init_CPPExample in CPPExampleWrapper.o "_rb_define_class", referenced from: getNullReferenceError() in CPPExampleWrapper.o getObjectPreviouslyDeletedError() in CPPExampleWrapper.o _SWIG_Ruby_SetModule in CPPExampleWrapper.o "_rb_define_class_under", referenced from: _Init_CPPExample in CPPExampleWrapper.o _SWIG_Ruby_define_class in CPPExampleWrapper.o "_rb_define_const", referenced from: _Init_CPPExample in CPPExampleWrapper.o "_rb_define_method", referenced from: _Init_CPPExample in CPPExampleWrapper.o "_rb_define_module", referenced from: _Init_CPPExample in CPPExampleWrapper.o _SWIG_Ruby_InitRuntime in CPPExampleWrapper.o "_rb_define_module_function", referenced from: _Init_CPPExample in CPPExampleWrapper.o "_rb_define_readonly_variable", referenced from: _SWIG_Ruby_SetModule in CPPExampleWrapper.o "_rb_define_singleton_method", referenced from: _Init_CPPExample in CPPExampleWrapper.o "_rb_eArgError", referenced from: SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o _wrap_new_JobOrder(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_src_location_set(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_src_location_get(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_dst_location_set(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_dst_location_get(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_xfer_params_set(int, unsigned long*, unsigned long)in CPPExampleWrapper.o ... "_rb_eFatal", referenced from: SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o "_rb_eIOError", referenced from: SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o "_rb_eIndexError", referenced from: SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o "_rb_eNoMemError", referenced from: SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o "_rb_eRangeError", referenced from: SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o "_rb_eRuntimeError", referenced from: getNullReferenceError() in CPPExampleWrapper.o getObjectPreviouslyDeletedError() in CPPExampleWrapper.o SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o "_rb_eSyntaxError", referenced from: SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o "_rb_eTypeError", referenced from: SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o "_rb_eZeroDivError", referenced from: SWIG_Ruby_ErrorType(int) in CPPExampleWrapper.o "_rb_funcall", referenced from: _SWIG_RubyRemoveTracking in CPPExampleWrapper.o "_rb_gv_get", referenced from: _SWIG_Ruby_GetModule in CPPExampleWrapper.o _SWIG_RubyInitializeTrackings in CPPExampleWrapper.o "_rb_gv_set", referenced from: _SWIG_Ruby_GetModule in CPPExampleWrapper.o _SWIG_RubyInitializeTrackings in CPPExampleWrapper.o "_rb_hash_aref", referenced from: _SWIG_RubyInstanceFor in CPPExampleWrapper.o "_rb_hash_aset", referenced from: _SWIG_RubyAddTracking in CPPExampleWrapper.o "_rb_hash_new", referenced from: _SWIG_RubyInitializeTrackings in CPPExampleWrapper.o "_rb_inspect", referenced from: Ruby_Format_TypeError(char const*, char const*, char const*, int, unsigned long)in CPPExampleWrapper.o "_rb_int2big", referenced from: _SWIG_RubyPtrToReference in CPPExampleWrapper.o _SWIG_RubyObjectToReference in CPPExampleWrapper.o SWIG_From_int(int) in CPPExampleWrapper.o "_rb_intern", referenced from: _SWIG_Ruby_InitRuntime in CPPExampleWrapper.o _SWIG_RubyInitializeTrackings in CPPExampleWrapper.o _SWIG_Ruby_NewPointerObj in CPPExampleWrapper.o "_rb_iv_get", referenced from: _SWIG_Ruby_NewPointerObj in CPPExampleWrapper.o _SWIG_Ruby_MangleStr in CPPExampleWrapper.o "_rb_iv_set", referenced from: _SWIG_Ruby_NewClassInstance in CPPExampleWrapper.o _SWIG_Ruby_NewPointerObj in CPPExampleWrapper.o "_rb_ivar_get", referenced from: _SWIG_RubyInitializeTrackings in CPPExampleWrapper.o "_rb_ivar_set", referenced from: _SWIG_RubyInitializeTrackings in CPPExampleWrapper.o "_rb_num2long", referenced from: _SWIG_RubyReferenceToObject in CPPExampleWrapper.o SWIG_AUX_NUM2LONG(unsigned long*)in CPPExampleWrapper.o "_rb_num2ulong", referenced from: SWIG_AUX_NUM2ULONG(unsigned long*)in CPPExampleWrapper.o "_rb_obj_classname", referenced from: Ruby_Format_TypeError(char const*, char const*, char const*, int, unsigned long)in CPPExampleWrapper.o "_rb_obj_is_kind_of", referenced from: _SWIG_Ruby_ConvertPtrAndOwn in CPPExampleWrapper.o "_rb_raise", referenced from: _wrap_new_JobOrder(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_src_location_set(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_src_location_get(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_dst_location_set(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_dst_location_get(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_xfer_params_set(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_JobOrder_xfer_params_get(int, unsigned long*, unsigned long)in CPPExampleWrapper.o ... "_rb_rescue", referenced from: SWIG_AsVal_unsigned_SS_long(unsigned long, unsigned long*)in CPPExampleWrapper.o SWIG_AsVal_long(unsigned long, long*)in CPPExampleWrapper.o "_rb_str_append", referenced from: Ruby_Format_TypeError(char const*, char const*, char const*, int, unsigned long)in CPPExampleWrapper.o "_rb_str_cat", referenced from: Ruby_Format_TypeError(char const*, char const*, char const*, int, unsigned long)in CPPExampleWrapper.o "_rb_str_cat2", referenced from: Ruby_Format_TypeError(char const*, char const*, char const*, int, unsigned long)in CPPExampleWrapper.o "_rb_str_new", referenced from: SWIG_FromCharPtrAndSize(char const*, unsigned long)in CPPExampleWrapper.o Ruby_Format_TypeError(char const*, char const*, char const*, int, unsigned long)in CPPExampleWrapper.o "_rb_str_new_cstr", referenced from: _SWIG_Ruby_NewClassInstance in CPPExampleWrapper.o _SWIG_Ruby_NewPointerObj in CPPExampleWrapper.o Ruby_Format_TypeError(char const*, char const*, char const*, int, unsigned long)in CPPExampleWrapper.o "_rb_string_value_ptr", referenced from: _wrap_XferParams_exclude_patterns_set(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _wrap_CPPTransfer_SetExcludePattern(int, unsigned long*, unsigned long)in CPPExampleWrapper.o _SWIG_Ruby_MangleStr in CPPExampleWrapper.o SWIG_AsCharPtrAndSize(unsigned long, char**, unsigned long*, int*)in CPPExampleWrapper.o Ruby_Format_TypeError(char const*, char const*, char const*, int, unsigned long)in CPPExampleWrapper.o "_rb_uint2big", referenced from: SWIG_From_unsigned_SS_long(unsigned long)in CPPExampleWrapper.o "_rb_undef_alloc_func", referenced from: _Init_CPPExample in CPPExampleWrapper.o "_rb_undef_method", referenced from: _SWIG_Ruby_define_class in CPPExampleWrapper.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status/ Perhaps not so coincidentally, all of the undefined symbols are members of the Ruby C API. I've rebuilt the Ruby using RVM and manually verified that the corresponding object files are 32 bit. I've also tried linking directly against the (32 bit) ruby.o file, with the same results. Does anyone have any clues as to how I might resolve this issue? Any feedback is greatly appreciated. Cheers, James -- View this message in context: http://swig.10945.n7.nabble.com/Undefined-symbol-for-architecture-i386-on-linking-SWIG-C-Wrapper-Object-for-Ruby-compiled-with-m32-on-tp13093.html Sent from the swig-user mailing list archive at Nabble.com. |