I’m trying to compile the example visual studio solution that comes with the 3.2 source. I copied the directory up one level as it says to do. I am not using the same visual studio as they used.
For some reason I get this:
1>LINK : fatal error LNK1181: cannot open input file 'python26.lib'
I don’t understand how the linker (Or much of visual c++) works. However I have checked that the include and library directories don’t have anything that looks wrong for VS and for the project.
Can anyone help me understand and fix this?
Here is the sample module source:
#include "Python.h"
static PyObject *
ex_foo(PyObject *self, PyObject *args)
{
printf("Hello, world\n");
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef example_methods[] = {
{"foo", ex_foo, METH_VARARGS, "foo() doc string"},
{NULL, NULL}
};
static struct PyModuleDef examplemodule = {
PyModuleDef_HEAD_INIT,
"example",
"example module doc string",
-1,
example_methods,
NULL,
NULL,
NULL,
NULL
};
PyMODINIT_FUNC
PyInit_example(void)
{
return PyModule_Create(&examplemodule);
}
I wouldn’t use the example code that comes with the source, your project settings must have Python26.lib in the input list. It is much easier to use distutils instead, this is a setup.py for a Simple module:
Run it from a cmd.exe where you have run vcvarsall.bat, and has python in its path.
However, if you must use Visual Studio: