Embedding Python within C++ (CPython API)
Question: I'm trying to embed Python within my C++ project (Qt5). My project looks like
this:

python_test.pro:

    
    
    QT += core
    QT -= gui
    
    TARGET = python_test
    CONFIG += console
    CONFIG -= app_bundle
    
    TEMPLATE = app
    
    SOURCES += main.cpp
    
    INCLUDEPATH += C:\Tools\Python\Python35_64\include
    
    LIBS += -LC:\Tools\Python\Python35_64\ -lpython3
    

main.cpp:

    
    
    #include <Python.h>
    #include <QCoreApplication>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        Py_Initialize();
        PyRun_SimpleString("from time import time,ctime\n"
                       "print('Today is', ctime(time()))\n");
        Py_Finalize();
        return a.exec();
    }
    

When compiling I get a linker error telling me this: `main.cpp:-1: Error:
undefined reference to `__imp_PyRun_SimpleStringFlags'`.

The funny thing is that `Py_Initialize()` and `Py_Finalize()` can be found. I
read something about the define `Py_LIMITED_API` which hides the function
PyRun_SimpleStringFlags. But I don't get it.

How am I supposed to run a Python script/file/string without these functions
being available within the C API?

Setup:

  * Win7 Prof 64 bit
  * Qt 5.5.1
  * g++.exe (Rev1, Built by MSYS2 project) 5.3.0
  * Python 3.5.1 64-bit (prebuilt from <https://www.python.org/downloads/release)/python-351/>)


Answer: I tested this on my computer (without Qt though), with `-lpython35` compiling
succeeded and with `-lpython3` it did not.

So

    
    
    LIBS += -LC:\Tools\Python\Python35_64\ -lpython35
    

instead of

    
    
    LIBS += -LC:\Tools\Python\Python35_64\ -lpython3
    

