mac os in mac os x error未定义的符号:“_ PyImport_Import”

时间:2011-12-01 08:48:17

标签: python macos compiler-errors

在mac os x(10.6.8)中构建SUMO(模拟城市移动性http://sumo.sf.net/)时发生以下错误。我不认为这是特定于SUMO,而是mac相关问题中的python安装,所以我在这里发帖。仅供参考,这里的python版本是2.7.1。

关于如何解决这个问题的任何想法?

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<char, std::char_traits<char>, std::allocator<char> >)in libtraciserver.a(TraCIServer.o)
"_PyString_FromString", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in libtraciserver.a(TraCIServer.o)
"_Py_Finalize", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in libtraciserver.a(TraCIServer.o)
"_Py_Initialize", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in libtraciserver.a(TraCIServer.o)
"_Py_InitModule4_64", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in libtraciserver.a(TraCIServer.o)
"_PyRun_SimpleFileExFlags", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in libtraciserver.a(TraCIServer.o)
"_PyErr_Print", referenced from:
traci::TraCIServer::runEmbedded(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)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

1 个答案:

答案 0 :(得分:1)

我在SUMO的网站(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

我可以通过这个编译错误。这些行正在与MacPort一起使用。