I reproduced the same problem on a 32-bit Lubuntu14.04 virtual machine running on a Win7 machine.
I did the following things to replicate the problem, primarily where the C ++ code is written in the Eclipse C / C ++ IDE. A C ++ Eclipse project called "test" is defined. The source file contains the following C ++ code, which is the same as Miguellissimo mentioned above.
C ++ Code ::
#include "python2.7/Python.h" int main(int argc, char *argv[]) { Py_Initialize(); PyRun_SimpleString("print \"Hello, world!\""); Py_Finalize(); return 0; }
Errors ::
test.o: In main': /home/ros/workspace/test/src/test.cpp:15: undefined reference to Py_Initialize' /home/ros/workspace/test/src/test.cpp:17: undefined link on PyRun_SimpleStringFlags' /home/ros/workspace/test/src/test.cpp:18: undefined reference to Py_Finalize' collect2: error: ld returned 1 exit status
The output of the following commands was the same as previously mentioned by Miguellissimo,
ros@rosPC :~/workspace/test/src$ python2.7-config --cflags -I/usr/include/python2.7 -I/usr/include/i386-linux-gnu/python2.7 -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes ros@rosPC :~/workspace/test/src$ python2.7-config --ldflags -L/usr/lib/python2.7/config-i386-linux-gnu -L/usr/lib -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions
Properties of a C ++ Eclipse project project called "test" ::
Inside I had the following C ++ build settings
GCC C ++ Compiler
Command: g++ All options: -I/opt/ros/indigo/include -O0 -g3 -Wall -c -fmessage-length=0 Command line pattern: ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} Includes include paths: /opt/ros/indigo/include
GCC C Compiler
Command: gcc All options: -I/opt/ros/indigo/include -I/usr/lib/python2.7/config-i386-linux-gnu -O0 -g3 -Wall -c -fmessage-length=0 Command line pattern: ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} Includes include paths: /opt/ros/indigo/include /usr/lib/python2.7/config-i386-linux-gnu
GCC C ++ Linker
Command: g++ All options: Command line pattern: ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} Libraries: Libraries(-I): Library search path(-L):
Decision::
The following C ++ build settings are defined in the Project Properties of the C ++ Eclipse Project
GCC C ++ Compiler
Command: g++ All options: -I/opt/ros/indigo/include -I/usr/include/python2.7 -O0 -g3 -Wall -c -fmessage-length=0 Command line pattern: ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} Includes include paths: /opt/ros/indigo/include /usr/include/python2.7
GCC C Compiler
Command: gcc All options: -I/opt/ros/indigo/include -I/usr/include/python2.7 -O0 -g3 -Wall -c -fmessage-length=0 Command line pattern: ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} Includes include paths: /opt/ros/indigo/include /usr/include/python2.7
GCC C ++ Linker
Command: g++ All options: -L/usr/lib/python2.7/config-i386-linux-gnu Command line pattern: ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} Libraries: Libraries(-I): python2.7 Library search path(-L): /usr/lib/python2.7/config-i386-linux-gnu
Result :: Linker errors that were obtained earlier from the compilation of the C ++ Eclipse project no longer occur.