2

I am trying to embed python in my c++ code in my qt project as per this tutorial. I am now getting this error code: "error: undefined reference to `_imp__Py_Initialize'"

Before this, I had the same problem in CodeBlocks and fixed it by with these additional arguments "-IC:\Python27\include\ -IC:\Python27\libs\" and "C:\Python27\libs\python27.lib"

Adding the same commands to my .pro file as such:

QMAKE_CXXFLAGS += -Wall -fexceptions -g -IC:\Python27\include\ -IC:\Python27\libs\ C:\Python27\libs\python27.lib

Allows me to import python.h but nothing more.

I know that questions like this have been posted before, and they helped me get running in CodeBlocks, but the same information dosent apply to Qt, or I am implementing it wrong.

2 Answers 2

2

You should use LIBS configuration variable to add an external library to your project. Something like this:

LIBS += C:\Python27\libs\python27.lib

You can find more info in documentation.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm afraid that this does not help, the error still persists.
I'm sorry, -L prefix was wrong. It's used for adding a new library path.
2

To build on HeyYO's answer, the .pro arguments to fix the problem are:

INCLUDEPATH = c:\Python27\include\ c:\Python27\libs\

LIBS += C:\Python27\libs\python27.lib

QMAKE_CXXFLAGS += C:\Python27\libs\python27.lib

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.