I am getting a linking error in my Visual Studio C project. Those are related to external functions of C-Python API not being resolved in the linking stage. One of them being: unresolved external symbol __ipm_Py_Finalize referenced in function _main
I Have Added the library folder of Python in the Linker Additional Library Directory and added include folder in C/C++ Additional Include Directory. Here is my C code:
#include <stdio.h>
#include <stdbool.h>
#include <Python.h>
int main() {
Py_Initialze();
printf("Initialized python interpreter!");
PyObject* module = PyImport_ImportModule("CPBridger");
if (module == NULL) {
printf("Can't find module!");
return -1;
}
PyObject* func = PyObject_GetAttrString(module, "helloWorld");
PyObject* args = PyTuple_Pack(0);
PyObject_CallObject(func, args);
Py_XDECREF(func);
Py_XDECREF(args);
func = PyObject_GetAttrString(module, "sayHelloTo");
args = PyTuple_Pack(1, PyString_FromString("LakshyaK2011"));
PyObject_CallObject(func, args);
Py_XDECREF(func);
Py_XDECREF(args);
Py_XDECREF(module);
Py_Finalize();
printf("Finalized python interpreter!");
}
What shall I configure in VS to make it resolve the external references?
Okay so in this secnario, I haven't included python3.lib, Simple fix to this is to iinclude python3.lib in the Linker.