I wrote this program on DEV C ++. If you compile errors such as: [Linker Error] undefined reference to _imp__Py_SetProgramName ' . How to compile? (I'm completely new)

#include "c:/Python26/include/Python.h" main(int argc, char **argv) { Py_SetProgramName(argv[0]); Py_Initialize(); PyRun_SimpleString("import time\n"); PyRun_SimpleString("print time.localtime(time.time())\n"); Py_Finalize(); } 
  • How to connect python26.lib? I already read how to connect and compile this code from the command line, but I could not understand. Can you explain something else ... - Drakon
  • compile on gcc? if yes then you need to type -lpython26 in the command line like so, you may need to specify the full path - Roman Goriachevskiy

1 answer 1

Well, it seems like you connected the current header from the python, but did not connect the library with the implementation of the functions defined in the header.
Therefore, it cannot find the function during linking.

Find in your place where you connect the header .lib library file.
Something like Python2.7.lib if in windows or libpytron2.7.a in Linux.
And connect to the project.

UPD: found on the network, but not checked, since there is no Dev-C itself
open dev there will be a service at the top -> compiler parameters and in the second window you will write the path to .a and do not forget to put a tick