Skip to content Skip to sidebar Skip to footer

Trying To Understand Linking Procedure For Writing Python/c++ Hybrid

I want to start learning more about using SWIG and other methods to interface Python and C++. To get started, I wanted to compile this simple program mentioned in another post: #in

Solution 1:

What you are seeing are linker errors. To fix those, you need to link python2.7 library.

Try next line :

gcc -I/usr/include/python2.7 test.c -lpython2.7

it should work.

Solution 2:

First, do you compile C or C++ code?

Use gcc for the former, and g++ for the latter. C++ code needs some additional linking to be performed.

Second: you have to link your program to libpython2.7.so to embed the interpreter into it. To do this, add -lpython2.7 to gcc command line.

Solution 3:

test.o is not your executable file, that's why you can't execute it.

The default name for your program is a.out, try running that. You can specify a name for your program using the -o option.

Post a Comment for "Trying To Understand Linking Procedure For Writing Python/c++ Hybrid"