User forums > General (but related to Code::Blocks)
Help linking Python
(1/1)
josejps84:
Hi there,
My code is :
--- Code: ---#include <python.h>
int main(int argc, char *argv[]) {
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print 'Today is',ctime(time())\n");
Py_Finalize();
return 0;
}
--- End code ---
I do link the python27.lib in project Build Options
but I get this link error:
Compiling: src\main.cpp
Linking console executable: bin\Release\PythonBind.exe
obj\Release\src\main.o:main.cpp:(.text.startup+0x10): undefined reference to `_imp__Py_Initialize'
obj\Release\src\main.o:main.cpp:(.text.startup+0x25): undefined reference to `_imp__PyRun_SimpleStringFlags'
obj\Release\src\main.o:main.cpp:(.text.startup+0x2b): undefined reference to `_imp__Py_Finalize'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings
It's like it doesn't link the lib but it found the file 'cause when I put another non-existent lib It tells me that can't be found
Please any help, What do I miss?
Thanks in advance for any help
Greetings
oBFusCATed:
Read this please:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F
This:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_My_build_fails_with_multiple_undefined_reference_errors.3F
This:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
And of course the manual and the documentation of python. You need the part for making c modules.
Navigation
[0] Message Index
Go to full version