• XSS.stack #1 – первый литературный журнал от юзеров форума

C++ - Error linking Python Libraries

MoPharma

(L2) cache
Пользователь
Регистрация
31.05.2020
Сообщения
351
Реакции
68
Гарант сделки
10
Hello, Im trying to link python for execute this code:
Код:
#include <Python.h>

int main(int argc, char *argv[])
{
    Py_SetProgramName((wchar_t *)argv[0]);  /* optional but recommended */
    Py_Initialize();
    PyRun_SimpleString("from time import time,ctime\n"
        "print('Today is', ctime(time()))\n");
    Py_Finalize();
    return 0;
}

Код:
But I got this error:
||=== Build: Debug in test (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `main':|
C:\Users\xxxxxxxxxxxxxxxxxxxxxx\test\test\main.cpp|5|undefined reference to `__imp_Py_SetProgramName'|
C:\Users\xxxxxxxxxxxxxxxxxxxxxx\test\test\main.cpp|6|undefined reference to `__imp_Py_Initialize'|
C:\Users\xxxxxxxxxxxxxxxxxxxxxx\test\test\main.cpp|8|undefined reference to `__imp_PyRun_SimpleStringFlags'|
C:\Users\xxxxxxxxxxxxxxxxxxxxxx\test\test\main.cpp|9|undefined reference to `__imp_Py_Finalize'|
||error: ld returned 1 exit status|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I linked 'python\include' and 'python\libs\', anyone how what I can do?
Im using Codeblocks and MinGW.
 
Пожалуйста, обратите внимание, что пользователь заблокирован
I linked 'python\include' and 'python\libs\', anyone how what I can do?
Did you actually link the library (by passing '-lpython' argument or something to the linker) or just added the paths to compiler and linker search paths (by using '-I' and '-L' arguments)?
 
Пожалуйста, обратите внимание, что пользователь заблокирован
I tryed it and same problem
Why on earth do you have empty -I and -L flags there? Post the full command line that are used for compiling and linking, post the content of your python\libs folder.
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх