I'm trying to create a "helloworld" app in C++, with an integrated Python code. I include Python.h, and it is seen by static analyzer fine. As I build my code I get undefined reference to '_imp__Py_Initialize', so make failed
I'm running Windows7-x64 with Python3.5-x32, MinGW-x64, CLion to write code. None of guides i found show the complete step-by-step solutions. If I have to re-install some specific versions of software, I need to know - what to do...
CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(sample)
find_package(PythonLibs 3.5 REQUIRED)
find_package(PythonInterp 3.5 REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 14)
add_executable(sample main.cpp)
main.cpp
#include <Python.h>
int main() {
Py_Initialize();
PyRun_SimpleString("print('hello, python')");
Py_Finalize();
return 0;
}
So the subject raises, i have an undefined reference. As i add target_link_libraries(${PYTHON_LIBRARIES}) to my CMakeLists.txt i get another exception:
Cannot specify link libraries for target
"C:/Users/...../Python35-32/python35.dll"
which is not built by this target.
Please provide me some more ideas, what to do with this, if you don't mind.
target_link_libraries(${PYTHON_LIBRARIES})takes the target as first parameter. Your target issample, so try withtarget_link_libraries(sample ${PYTHON_LIBRARIES})add_executable?