Hello.
I am writing a game engine and wanted to use Python for game scripts. My Main.cpp file is as follows:
// Main.cpp
// This software, including the source code, is release under the terms of
// the License.
#include "Common.h"
#include <sstream>
#include <iostream>
#include "Util/Vector.h"
#include <Python.h>
using namespace std;
int main(int argc, char *argv[])
{
Py_SetProgramName(argv[0]);
Py_Initialize();
Py_Finalize();
while (1);
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
stringstream ss;
ss << "SDL failed to initialise: " << SDL_GetError();
abortEngine(ss.str());
};
wasInitSDL = true;
if (SDL_SetVideoMode(640, 480, 32, SDL_OPENGL) == NULL)
{
stringstream ss;
ss << "Failed to open window: " << SDL_GetError();
abortEngine(ss.str());
};
SDL_WM_SetCaption("Rage Engine", "Rage Engine");
bool quitEngine = false;
while (!quitEngine)
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
quitEngine = true;
};
};
SDL_GL_SwapBuffers();
};
SDL_Quit();
return 0;
};
As you can see, I include Python.h and call Py_Initialize() etc. I specified in the settings the path to Python libs and the include directory, and passed the -lpython26 flag. However, when I compile, I get the following linking errors:
Linking console executable: bin\RageEngine.exe
obj\Release\Main.o:Main.cpp:(.text+0x4c): undefined reference to `_imp__Py_SetProgramName'
obj\Release\Main.o:Main.cpp:(.text+0x52): undefined reference to `_imp__Py_Initialize'
obj\Release\Main.o:Main.cpp:(.text+0x58): undefined reference to `_imp__Py_Finalize'
collect2: ld returned 1 exit status
When I opened python26.lib with notepad I could see that there were symbol names like __imp_Py_Initialize (so the number of underscores disagrees with what the IDE is trying to link with). Does anyone know what may be causing this, and how I could fix it?
Thank you.