[Pythonmac-SIG] swig example on mac osx 10.6.4

Christopher Barker Chris.Barker at noaa.gov
Fri Sep 17 20:37:37 CEST 2010


Massimo Di Stefano wrote:
> Hello All,
> 
> i'm tring to run the swig - python example, from the page :
> 
> http://www.swig.org/tutorial.html

AARRGG! I can't believe they haven't upgraded that page yet. (I'm pretty 
sure I submitted a doc patch a couple years ago!)

> but running it i have a "wrong architecture" problem.

> MacBook-Pro-15-di-sasha:~ sasha$ gcc -c example.c example_wrap.c -I 

When building python extensions, you REALLY want to use distutils. See 
here for an example:

http://www.swig.org/Doc2.0/Python.html#Python_nn6

at least that doc patch got in there.

Let us know if that still doesn't work.

-Chris





> /usr/include/python2.
> python2.5/ python2.6/ 
> MacBook-Pro-15-di-sasha:~ sasha$ gcc -c example.c example_wrap.c -I 
> /usr/include/python2.6
> MacBook-Pro-15-di-sasha:~ sasha$ ld -dylib example.o example_wrap.o -o 
> _example.so
> Undefined symbols:
>  "_PyLong_AsLong", referenced from:
>      _SWIG_AsVal_long in example_wrap.o
>  "_PyDict_New", referenced from:
>      _SWIG_Python_NewShadowInstance in example_wrap.o
>      _SWIG_Python_NewShadowInstance in example_wrap.o
>      _SWIG_Python_SetSwigThis in example_wrap.o
>      _SWIG_Python_TypeCache in example_wrap.o
>  "_PyDict_SetItem", referenced from:
>      _SWIG_Python_NewShadowInstance in example_wrap.o
>      _SWIG_Python_NewShadowInstance in example_wrap.o
>      _SWIG_Python_SetSwigThis in example_wrap.o
>      _SWIG_Python_SetSwigThis in example_wrap.o
>      _SWIG_Python_TypeQuery in example_wrap.o
>  "_PyExc_ValueError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>  "_PyDict_SetItemString", referenced from:
>      _SWIG_Python_SetConstant in example_wrap.o
>      _SWIG_Python_InstallConstants in example_wrap.o
>      _init_example in example_wrap.o
>  "_strstr", referenced from:
>      _SWIG_Python_ConvertFunctionPtr in example_wrap.o
>      _SWIG_Python_FixMethods in example_wrap.o
>  "_PyCFunction_Type", referenced from:
>      _SWIG_Python_ConvertFunctionPtr in example_wrap.o
>  "_PyErr_Occurred", referenced from:
>      _SWIG_Python_AddErrorMsg in example_wrap.o
>      _SwigPyClientData_New in example_wrap.o
>      _SWIG_Python_GetSwigThis in example_wrap.o
>      _SWIG_Python_ConvertPtrAndOwn in example_wrap.o
>      _SWIG_Python_GetModule in example_wrap.o
>      _SWIG_Python_AddErrMesg in example_wrap.o
>      _SWIG_Python_ArgFail in example_wrap.o
>      _SWIG_AsVal_double in example_wrap.o
>      _SWIG_AsVal_long in example_wrap.o
>      _swig_varlink_getattr in example_wrap.o
>      _swig_varlink_setattr in example_wrap.o
>  "_PyInt_FromLong", referenced from:
>      _SWIG_From_int in example_wrap.o
>  "_Py_InitModule4_64", referenced from:
>      _SWIG_Python_SetModule in example_wrap.o
>      _init_example in example_wrap.o
>  "__PyWeakref_CallableProxyType", referenced from:
>      _SWIG_Python_GetSwigThis in example_wrap.o
>  "_PyString_FromString", referenced from:
>      _SWIG_Python_str_FromChar in example_wrap.o
>      _swig_varlink_repr in example_wrap.o
>      _swig_varlink_str in example_wrap.o
>      _swig_varlink_str in example_wrap.o
>      _swig_varlink_str in example_wrap.o
>      _swig_varlink_str in example_wrap.o
>  "_PyType_IsSubtype", referenced from:
>      _SWIG_AsVal_double in example_wrap.o
>  "_PyFloat_FromDouble", referenced from:
>      _Swig_var_My_variable_get in example_wrap.o
>  "_PyModule_GetDict", referenced from:
>      _init_example in example_wrap.o
>  "__PyInstance_Lookup", referenced from:
>      _SWIG_Python_GetSwigThis in example_wrap.o
>  "___assert_rtn", referenced from:
>      _SWIG_Python_ConvertPtrAndOwn in example_wrap.o
>      _SWIG_Python_ConvertFunctionPtr in example_wrap.o
>  "_PyLong_FromVoidPtr", referenced from:
>      _SwigPyObject_long in example_wrap.o
>  "_PyErr_Clear", referenced from:
>      _SWIG_Python_AddErrorMsg in example_wrap.o
>      _SwigPyClientData_New in example_wrap.o
>      _SWIG_Python_GetSwigThis in example_wrap.o
>      _SWIG_Python_ConvertPtrAndOwn in example_wrap.o
>      _SWIG_Python_GetModule in example_wrap.o
>      _SWIG_Python_AddErrMesg in example_wrap.o
>      _SWIG_Python_MustGetPtr in example_wrap.o
>      _SWIG_AsVal_double in example_wrap.o
>      _SWIG_AsVal_long in example_wrap.o
>  "_PyObject_Free", referenced from:
>      _SwigPyObject_dealloc in example_wrap.o
>      _SwigPyPacked_dealloc in example_wrap.o
>      _SwigPyPacked_New in example_wrap.o
>  "___stack_chk_guard", referenced from:
>      _SwigPyObject_str in example_wrap.o
>      _SwigPyObject_str in example_wrap.o
>      _SwigPyPacked_print in example_wrap.o
>      _SwigPyPacked_print in example_wrap.o
>      _SwigPyPacked_repr in example_wrap.o
>      _SwigPyPacked_repr in example_wrap.o
>      _SwigPyPacked_str in example_wrap.o
>      _SwigPyPacked_str in example_wrap.o
>      _SWIG_Python_ArgFail in example_wrap.o
>      _SWIG_Python_ArgFail in example_wrap.o
>  "_PyArg_ParseTuple", referenced from:
>      __wrap_fact in example_wrap.o
>      __wrap_my_mod in example_wrap.o
>      __wrap_get_time in example_wrap.o
>  "__PyWeakref_ProxyType", referenced from:
>      _SWIG_Python_GetSwigThis in example_wrap.o
>  "_PyClass_Type", referenced from:
>      _SwigPyClientData_New in example_wrap.o
>  "_PyOS_snprintf", referenced from:
>      _SWIG_Python_ArgFail in example_wrap.o
>  "_PyExc_SystemError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>      _SWIG_Python_UnpackTuple in example_wrap.o
>  "_PyObject_Call", referenced from:
>      _SWIG_Python_NewShadowInstance in example_wrap.o
>  "__Py_ZeroStruct", referenced from:
>      _SwigPyObject_richcompare in example_wrap.o
>  "__PyObject_GetDictPtr", referenced from:
>      _SWIG_Python_GetSwigThis in example_wrap.o
>      _SWIG_Python_NewShadowInstance in example_wrap.o
>      _SWIG_Python_SetSwigThis in example_wrap.o
>  "_malloc", referenced from:
>      _SwigPyClientData_New in example_wrap.o
>      _SwigPyPacked_New in example_wrap.o
>      _SWIG_Python_addvarlink in example_wrap.o
>      _SWIG_Python_addvarlink in example_wrap.o
>      _SWIG_Python_FixMethods in example_wrap.o
>  "_PyErr_Fetch", referenced from:
>      _SWIG_Python_AddErrorMsg in example_wrap.o
>      _SWIG_Python_AddErrMesg in example_wrap.o
>  "_PyExc_RuntimeError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>      _SWIG_Python_ErrorType in example_wrap.o
>      _SWIG_Python_AddErrorMsg in example_wrap.o
>  "_PyList_New", referenced from:
>      _SWIG_Python_AppendOutput in example_wrap.o
>  "_strncmp", referenced from:
>      _SwigPyPacked_compare in example_wrap.o
>      _SWIG_Python_FixMethods in example_wrap.o
>  "_PyObject_CallFunctionObjArgs", referenced from:
>      _SwigPyObject_dealloc in example_wrap.o
>      _SWIG_Python_ConvertPtrAndOwn in example_wrap.o
>  "___memcpy_chk", referenced from:
>      _SwigPyPacked_New in example_wrap.o
>      ___inline_memcpy_chk in example_wrap.o
>      _SwigPyPacked_UnpackData in example_wrap.o
>  "__Py_NoneStruct", referenced from:
>      _SWIG_Python_AppendOutput in example_wrap.o
>      _SWIG_Py_Void in example_wrap.o
>      _SWIG_Python_ConvertPtrAndOwn in example_wrap.o
>  "_PyExc_MemoryError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>  "_PyString_FromStringAndSize", referenced from:
>      _SWIG_FromCharPtrAndSize in example_wrap.o
>  "___memset_chk", referenced from:
>      _SWIG_UnpackDataName in example_wrap.o
>      ___inline_memset_chk in example_wrap.o
>  "_printf", referenced from:
>      _SwigPyObject_dealloc in example_wrap.o
>  "_PyExc_IOError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>  "___stack_chk_fail", referenced from:
>      _SwigPyObject_str in example_wrap.o
>      _SwigPyPacked_print in example_wrap.o
>      _SwigPyPacked_repr in example_wrap.o
>      _SwigPyPacked_str in example_wrap.o
>      _SWIG_Python_ArgFail in example_wrap.o
>  "_PyModule_AddObject", referenced from:
>      _SWIG_Python_SetModule in example_wrap.o
>  "_PyList_Append", referenced from:
>      _SWIG_Python_AppendOutput in example_wrap.o
>  "_fprintf", referenced from:
>      _swig_varlink_print in example_wrap.o
>  "_PyTuple_New", referenced from:
>      _SwigPyClientData_New in example_wrap.o
>      _SwigPyObject_format in example_wrap.o
>  "_PyExc_ZeroDivisionError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>  "_PyString_Format", referenced from:
>      _SwigPyObject_format in example_wrap.o
>  "_PyFloat_AsDouble", referenced from:
>      _SWIG_AsVal_double in example_wrap.o
>  "_PyDict_GetItem", referenced from:
>      _SWIG_Python_GetSwigThis in example_wrap.o
>      _SWIG_Python_TypeQuery in example_wrap.o
>  "_PyObject_GetAttr", referenced from:
>      _SWIG_Python_GetSwigThis in example_wrap.o
>  "_PyType_Type", referenced from:
>      __PySwigObject_type in example_wrap.o
>      __PySwigPacked_type in example_wrap.o
>      _swig_varlink_type in example_wrap.o
>  "_PyObject_Str", referenced from:
>      _SWIG_Python_AddErrorMsg in example_wrap.o
>      _SWIG_Python_AddErrMesg in example_wrap.o
>      _SWIG_Python_TypeError in example_wrap.o
>  "_PyCObject_AsVoidPtr", referenced from:
>      _SWIG_Python_TypeQuery in example_wrap.o
>  "_free", referenced from:
>      _SwigPyPacked_dealloc in example_wrap.o
>      _swig_varlink_dealloc in example_wrap.o
>      _swig_varlink_dealloc in example_wrap.o
>  "_PyExc_TypeError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>      _SWIG_Python_UnpackTuple in example_wrap.o
>      _SWIG_Python_UnpackTuple in example_wrap.o
>      _SWIG_Python_UnpackTuple in example_wrap.o
>      _SWIG_Python_TypeError in example_wrap.o
>      _SWIG_Python_TypeError in example_wrap.o
>      _SWIG_Python_TypeError in example_wrap.o
>      _SWIG_Python_TypeError in example_wrap.o
>  "_PyArg_UnpackTuple", referenced from:
>      _SwigPyObject_own in example_wrap.o
>  "_PyBool_FromLong", referenced from:
>      _SwigPyObject_own in example_wrap.o
>  "_PyTuple_SetItem", referenced from:
>      _SwigPyClientData_New in example_wrap.o
>      _SwigPyObject_format in example_wrap.o
>  "__Py_NotImplementedStruct", referenced from:
>      _SwigPyObject_richcompare in example_wrap.o
>      _SwigPyObject_richcompare in example_wrap.o
>      _SwigPyObject_richcompare in example_wrap.o
>  "_PyObject_IsTrue", referenced from:
>      _SwigPyObject_own in example_wrap.o
>  "_PyCObject_Import", referenced from:
>      _SWIG_Python_GetModule in example_wrap.o
>  "_time", referenced from:
>      _get_time in example.o
>     (maybe you meant: cstring=:get_time, cstring=get_time , _get_time )
>  "_PyInstance_NewRaw", referenced from:
>      _SWIG_Python_NewShadowInstance in example_wrap.o
>  "_PyErr_SetString", referenced from:
>      _SWIG_Python_AddErrorMsg in example_wrap.o
>      _SWIG_Python_SetErrorMsg in example_wrap.o
>      _SWIG_Python_UnpackTuple in example_wrap.o
>      _swig_varlink_getattr in example_wrap.o
>      _swig_varlink_setattr in example_wrap.o
>  "_PyExc_OverflowError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>  "_fputc", referenced from:
>      _SwigPyPacked_print in example_wrap.o
>  "_PyInt_AsLong", referenced from:
>      _SWIG_AsVal_double in example_wrap.o
>      _SWIG_AsVal_long in example_wrap.o
>  "_PyErr_SetObject", referenced from:
>      _SWIG_Python_SetErrorObj in example_wrap.o
>  "_PyObject_Malloc", referenced from:
>      _SwigPyObject_New in example_wrap.o
>      _SwigPyPacked_New in example_wrap.o
>      _SWIG_Python_newvarlink in example_wrap.o
>  "_PyString_FromFormat", referenced from:
>      _SwigPyObject_repr in example_wrap.o
>      _SwigPyPacked_repr in example_wrap.o
>      _SwigPyPacked_repr in example_wrap.o
>      _SwigPyPacked_str in example_wrap.o
>  "_strlen", referenced from:
>      _SWIG_TypeEquiv in example_wrap.o
>      _SWIG_TypeCompare in example_wrap.o
>      _SWIG_PackVoidPtr in example_wrap.o
>      _SWIG_PackDataName in example_wrap.o
>      _SWIG_FromCharPtr in example_wrap.o
>      _SWIG_Python_addvarlink in example_wrap.o
>      _SWIG_Python_FixMethods in example_wrap.o
>      _SWIG_Python_FixMethods in example_wrap.o
>  "_PyExc_AttributeError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>  "___strcpy_chk", referenced from:
>      _SWIG_PackVoidPtr in example_wrap.o
>      ___inline_strcpy_chk in example_wrap.o
>  "_PyLong_AsDouble", referenced from:
>      _SWIG_AsVal_double in example_wrap.o
>  "__Py_TrueStruct", referenced from:
>      _SwigPyObject_richcompare in example_wrap.o
>  "_fputs", referenced from:
>      _SwigPyObject_print in example_wrap.o
>      _SwigPyPacked_print in example_wrap.o
>      _SwigPyPacked_print in example_wrap.o
>  "_strcmp", referenced from:
>      _SWIG_TypeCheck in example_wrap.o
>      _SWIG_MangledTypeQueryModule in example_wrap.o
>      _SWIG_UnpackVoidPtr in example_wrap.o
>      _SWIG_UnpackDataName in example_wrap.o
>      _SwigPyObject_Check in example_wrap.o
>      _SwigPyPacked_Check in example_wrap.o
>      _swig_varlink_getattr in example_wrap.o
>      _swig_varlink_setattr in example_wrap.o
>  "_PyErr_Format", referenced from:
>      _SWIG_Python_AddErrorMsg in example_wrap.o
>      _SWIG_Python_UnpackTuple in example_wrap.o
>      _SWIG_Python_UnpackTuple in example_wrap.o
>      _SWIG_Python_UnpackTuple in example_wrap.o
>      _SWIG_Python_AddErrMesg in example_wrap.o
>      _SWIG_Python_AddErrMesg in example_wrap.o
>      _SWIG_Python_TypeError in example_wrap.o
>      _SWIG_Python_TypeError in example_wrap.o
>      _SWIG_Python_TypeError in example_wrap.o
>      _SWIG_Python_TypeError in example_wrap.o
>  "_PyExc_SyntaxError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>  "_PyObject_GenericGetAttr", referenced from:
>      _tmp.9623 in example_wrap.o
>      _tmp.9773 in example_wrap.o
>  "_PyFloat_Type", referenced from:
>      _SWIG_AsVal_double in example_wrap.o
>      _SWIG_AsVal_double in example_wrap.o
>  "_PyString_ConcatAndDel", referenced from:
>      _SwigPyObject_repr in example_wrap.o
>      _swig_varlink_str in example_wrap.o
>      _swig_varlink_str in example_wrap.o
>      _swig_varlink_str in example_wrap.o
>  "_PyCObject_FromVoidPtr", referenced from:
>      _SWIG_Python_SetModule in example_wrap.o
>      _SWIG_Python_TypeQuery in example_wrap.o
>  "_PyList_SetItem", referenced from:
>      _SWIG_Python_AppendOutput in example_wrap.o
>  "___strncpy_chk", referenced from:
>      _SWIG_PackDataName in example_wrap.o
>      ___inline_strncpy_chk in example_wrap.o
>      _SWIG_Python_addvarlink in example_wrap.o
>      _SWIG_Python_FixMethods in example_wrap.o
>      _SWIG_Python_FixMethods in example_wrap.o
>  "_ctime", referenced from:
>      _get_time in example.o
>  "_PyExc_IndexError", referenced from:
>      _SWIG_Python_ErrorType in example_wrap.o
>  "_PyObject_GetAttrString", referenced from:
>      _SwigPyClientData_New in example_wrap.o
>      _SwigPyClientData_New in example_wrap.o
>      _SWIG_Python_SetSwigThis in example_wrap.o
>  "_PyString_AsString", referenced from:
>      _SWIG_Python_str_AsChar in example_wrap.o
>  "_PyObject_Init", referenced from:
>      _SwigPyObject_New in example_wrap.o
>      _SwigPyPacked_New in example_wrap.o
>      _SWIG_Python_newvarlink in example_wrap.o
>  "_PyExc_NameError", referenced from:
>      _swig_varlink_getattr in example_wrap.o
>      _swig_varlink_setattr in example_wrap.o
>  "_PyInstance_Type", referenced from:
>      _SWIG_Python_GetSwigThis in example_wrap.o
>  "_fwrite", referenced from:
>      _SwigPyPacked_print in example_wrap.o
>      _SwigPyPacked_print in example_wrap.o
>      _swig_varlink_print in example_wrap.o
>  "_memcpy", referenced from:
>      __PySwigObject_type in example_wrap.o
>      __PySwigPacked_type in example_wrap.o
>      _swig_varlink_type in example_wrap.o
> ld: symbol(s) not found for inferred architecture x86_64
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list