python in mac os x error Undefined symbols: “_PyImport_Import”-Collection of common programming errors
While building SUMO (Simulation of Urban MObility http://sumo.sf.net/) in mac os x (10.6.8) the following error occured. I don’t think this is specific to SUMO, rather python installation in mac related issue, so I am posting here. FYI, the python version is 2.7.1 here.
Any idea on how to solve this issue?
libtool: link: g++ -g -pthread -o sumo sumo_main.o ./microsim/MSMoveReminder.o -Wl,-bind_at_load -L/opt/local/lib ./netload/libnetload.a ./microsim/libmicrosim.a ./microsim/cfmodels/libmicrosimcfmodels.a ./microsim/devices/libmicrosimdevs.a ./microsim/output/libmicrosimoutput.a ./microsim/trigger/libmicrosimtrigger.a ./microsim/actions/libmsactions.a ./microsim/traffic_lights/libmicrosimtls.a ./utils/geom/libgeom.a ./utils/shapes/libshapes.a ./traci-server/libtraciserver.a ./utils/options/liboptions.a ./utils/common/libcommon.a ./utils/xml/libxml.a ./utils/importio/libimportio.a ./utils/iodevices/libiodevices.a ./foreign/tcpip/libtcpip.a ./foreign/nvwa/libnvwa.a -lxerces-c /opt/local/lib/libproj.dylib -lm -pthread
Undefined symbols:
"_PyImport_Import", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string)in libtraciserver.a(TraCIServer.o)
"_PyString_FromString", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string)in libtraciserver.a(TraCIServer.o)
"_Py_Finalize", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string)in libtraciserver.a(TraCIServer.o)
"_Py_Initialize", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string)in libtraciserver.a(TraCIServer.o)
"_Py_InitModule4_64", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string)in libtraciserver.a(TraCIServer.o)
"_PyRun_SimpleFileExFlags", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string)in libtraciserver.a(TraCIServer.o)
"_PyErr_Print", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string)in libtraciserver.a(TraCIServer.o)
"_PyArg_ParseTuple", referenced from:
traci::traciemb_execute(_object*, _object*)in libtraciserver.a(TraCIServer.o)
"_Py_BuildValue", referenced from:
traci::traciemb_execute(_object*, _object*)in libtraciserver.a(TraCIServer.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [sumo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1
-
I found a link on SUMO’s website (here):
export CPPFLAGS="$CPPFLAGS -I/opt/local/include" export LDFLAGS="$LDFLAGS -L/opt/local/lib -lpython2.7" ./configure --with-fox=/opt/local --with-proj-gdal=/opt/local --with-xerces=/opt/local --prefix=/opt/sumo --with-python
It worked for me to get past this compilation error. These lines are working with MacPort though.
Originally posted 2013-11-27 12:27:21.