I'm working with several programmers to get a program to compile & run on Windows and Linux. It compiles fine under Windows using SDL for most of the functions (sound, graphics & input), but we're getting an error when using a makefile under Linux. We've tried several things without any success at locating the reason behind the errors.
Here is the file that is causing the error message
#include "game.h"
#include "SDL/SDL.h"
using namespace std;
int main (int argc, char* args[] )
{
bool quit = false;
// event structure
SDL_Event event;
if (!Game_Init()) return 0;
while ( quit == false )
{
Game_Run(0);
while ( SDL_PollEvent( &event ) )
{
if ( event.type == SDL_QUIT )
{
quit = true;
}
}
}
Game_End(0);
return 0;
}
and here is the header file that (Game_Init, Game_Run & Game_End) are created (well part of the header file, it's rather long)
#ifndef GAME_H
#define GAME_H
#include "CPInit.h"
// standard libraries
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
#ifndef USE_SDL
//windows/directx headers
#include <windows.h>
#include <dinput.h>
#include "dxinput.h"
#else
// define HWND class for SDL
typedef unsigned short int HWND; // 4 bytes
#endif
// cross-plat library headers
#include "SDL/SDL.h"
#include "SDL/SDL_mixer.h"
//function prototypes
int Game_Init();
void Game_Run(HWND);
void Game_End(HWND);
Now what we are getting is the following error messages
SDLMain.cpp: (.text+0x192): undefined reference to 'Game_Init()'
SDLMain.cpp: (.text+0x1ae): undefined reference to 'Game_Run(unsigned short)'
SDLMain.cpp: (.text+0x1eb): undefined reference to 'Game_End(unsigned short)'
the header file has a corresponding .cpp file that calls all 3 of those to perform their obvious functions. I'm just not sure why Linux is having so much trouble with them. I've even tried to just compile the SDLMain.cpp by itself and I receive the same error so I know the issue is most likely not the makefile, but I could be wrong on that.