Re: Help with Declaration Problem
Posted: Tue Jul 06, 2010 3:26 pm
Ok, I believe I have forward declared correctly, and it compiles fine now, but I have 48 LNK2005 errors...
I have been trying to figure this out for a good 2 hours now... I am willing to zip my source code up if anyone is willing to look at it D: I don't think I can paste it all here, but somethings of interest (I assume) are below:
main.cpp
mapEditor.h
Code: Select all
1>map.obj : error LNK2005: "struct SDL_Surface * __cdecl loadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?loadImage@@YAPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in main.obj
1>map.obj : error LNK2005: "void __cdecl applySurface(int,int,struct SDL_Surface *,struct SDL_Surface *,struct SDL_Rect *)" (?applySurface@@YAXHHPAUSDL_Surface@@0PAUSDL_Rect@@@Z) already defined in main.obj
1>map.obj : error LNK2005: "unsigned int __cdecl get_pixel32(struct SDL_Surface *,int,int)" (?get_pixel32@@YAIPAUSDL_Surface@@HH@Z) already defined in main.obj
1>map.obj : error LNK2005: "void __cdecl put_pixel32(struct SDL_Surface *,int,int,unsigned int)" (?put_pixel32@@YAXPAUSDL_Surface@@HHI@Z) already defined in main.obj
1>map.obj : error LNK2005: "void __cdecl flip_surface(struct SDL_Surface *,int,int)" (?flip_surface@@YAXPAUSDL_Surface@@HH@Z) already defined in main.obj
1>map.obj : error LNK2005: "void __cdecl rotate_surface(struct SDL_Surface *,int,struct SDL_Rect *)" (?rotate_surface@@YAXPAUSDL_Surface@@HPAUSDL_Rect@@@Z) already defined in main.obj
1>map.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl openFileName(char *,struct HWND__ *)" (?openFileName@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PADPAUHWND__@@@Z) already defined in main.obj
1>mapEditor.obj : error LNK2005: "struct SDL_Surface * __cdecl loadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?loadImage@@YAPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in main.obj
1>mapEditor.obj : error LNK2005: "void __cdecl applySurface(int,int,struct SDL_Surface *,struct SDL_Surface *,struct SDL_Rect *)" (?applySurface@@YAXHHPAUSDL_Surface@@0PAUSDL_Rect@@@Z) already defined in main.obj
1>mapEditor.obj : error LNK2005: "unsigned int __cdecl get_pixel32(struct SDL_Surface *,int,int)" (?get_pixel32@@YAIPAUSDL_Surface@@HH@Z) already defined in main.obj
1>mapEditor.obj : error LNK2005: "void __cdecl put_pixel32(struct SDL_Surface *,int,int,unsigned int)" (?put_pixel32@@YAXPAUSDL_Surface@@HHI@Z) already defined in main.obj
1>mapEditor.obj : error LNK2005: "void __cdecl flip_surface(struct SDL_Surface *,int,int)" (?flip_surface@@YAXPAUSDL_Surface@@HH@Z) already defined in main.obj
1>mapEditor.obj : error LNK2005: "void __cdecl rotate_surface(struct SDL_Surface *,int,struct SDL_Rect *)" (?rotate_surface@@YAXPAUSDL_Surface@@HPAUSDL_Rect@@@Z) already defined in main.obj
1>mapEditor.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl openFileName(char *,struct HWND__ *)" (?openFileName@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PADPAUHWND__@@@Z) already defined in main.obj
1>xi_button.obj : error LNK2005: "struct SDL_Surface * __cdecl loadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?loadImage@@YAPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in main.obj
1>xi_button.obj : error LNK2005: "void __cdecl applySurface(int,int,struct SDL_Surface *,struct SDL_Surface *,struct SDL_Rect *)" (?applySurface@@YAXHHPAUSDL_Surface@@0PAUSDL_Rect@@@Z) already defined in main.obj
1>xi_button.obj : error LNK2005: "unsigned int __cdecl get_pixel32(struct SDL_Surface *,int,int)" (?get_pixel32@@YAIPAUSDL_Surface@@HH@Z) already defined in main.obj
1>xi_button.obj : error LNK2005: "void __cdecl put_pixel32(struct SDL_Surface *,int,int,unsigned int)" (?put_pixel32@@YAXPAUSDL_Surface@@HHI@Z) already defined in main.obj
1>xi_button.obj : error LNK2005: "void __cdecl flip_surface(struct SDL_Surface *,int,int)" (?flip_surface@@YAXPAUSDL_Surface@@HH@Z) already defined in main.obj
1>xi_button.obj : error LNK2005: "void __cdecl rotate_surface(struct SDL_Surface *,int,struct SDL_Rect *)" (?rotate_surface@@YAXPAUSDL_Surface@@HPAUSDL_Rect@@@Z) already defined in main.obj
1>xi_button.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl openFileName(char *,struct HWND__ *)" (?openFileName@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PADPAUHWND__@@@Z) already defined in main.obj
1>xi_buttonbase.obj : error LNK2005: "struct SDL_Surface * __cdecl loadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?loadImage@@YAPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in main.obj
1>xi_buttonbase.obj : error LNK2005: "void __cdecl applySurface(int,int,struct SDL_Surface *,struct SDL_Surface *,struct SDL_Rect *)" (?applySurface@@YAXHHPAUSDL_Surface@@0PAUSDL_Rect@@@Z) already defined in main.obj
1>xi_buttonbase.obj : error LNK2005: "unsigned int __cdecl get_pixel32(struct SDL_Surface *,int,int)" (?get_pixel32@@YAIPAUSDL_Surface@@HH@Z) already defined in main.obj
1>xi_buttonbase.obj : error LNK2005: "void __cdecl put_pixel32(struct SDL_Surface *,int,int,unsigned int)" (?put_pixel32@@YAXPAUSDL_Surface@@HHI@Z) already defined in main.obj
1>xi_buttonbase.obj : error LNK2005: "void __cdecl flip_surface(struct SDL_Surface *,int,int)" (?flip_surface@@YAXPAUSDL_Surface@@HH@Z) already defined in main.obj
1>xi_buttonbase.obj : error LNK2005: "void __cdecl rotate_surface(struct SDL_Surface *,int,struct SDL_Rect *)" (?rotate_surface@@YAXPAUSDL_Surface@@HPAUSDL_Rect@@@Z) already defined in main.obj
1>xi_buttonbase.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl openFileName(char *,struct HWND__ *)" (?openFileName@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PADPAUHWND__@@@Z) already defined in main.obj
1>xi_label.obj : error LNK2005: "struct SDL_Surface * __cdecl loadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?loadImage@@YAPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in main.obj
1>xi_label.obj : error LNK2005: "void __cdecl applySurface(int,int,struct SDL_Surface *,struct SDL_Surface *,struct SDL_Rect *)" (?applySurface@@YAXHHPAUSDL_Surface@@0PAUSDL_Rect@@@Z) already defined in main.obj
1>xi_label.obj : error LNK2005: "unsigned int __cdecl get_pixel32(struct SDL_Surface *,int,int)" (?get_pixel32@@YAIPAUSDL_Surface@@HH@Z) already defined in main.obj
1>xi_label.obj : error LNK2005: "void __cdecl put_pixel32(struct SDL_Surface *,int,int,unsigned int)" (?put_pixel32@@YAXPAUSDL_Surface@@HHI@Z) already defined in main.obj
1>xi_label.obj : error LNK2005: "void __cdecl flip_surface(struct SDL_Surface *,int,int)" (?flip_surface@@YAXPAUSDL_Surface@@HH@Z) already defined in main.obj
1>xi_label.obj : error LNK2005: "void __cdecl rotate_surface(struct SDL_Surface *,int,struct SDL_Rect *)" (?rotate_surface@@YAXPAUSDL_Surface@@HPAUSDL_Rect@@@Z) already defined in main.obj
1>xi_label.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl openFileName(char *,struct HWND__ *)" (?openFileName@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PADPAUHWND__@@@Z) already defined in main.obj
1>xi_window.obj : error LNK2005: "struct SDL_Surface * __cdecl loadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?loadImage@@YAPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in main.obj
1>xi_window.obj : error LNK2005: "void __cdecl applySurface(int,int,struct SDL_Surface *,struct SDL_Surface *,struct SDL_Rect *)" (?applySurface@@YAXHHPAUSDL_Surface@@0PAUSDL_Rect@@@Z) already defined in main.obj
1>xi_window.obj : error LNK2005: "unsigned int __cdecl get_pixel32(struct SDL_Surface *,int,int)" (?get_pixel32@@YAIPAUSDL_Surface@@HH@Z) already defined in main.obj
1>xi_window.obj : error LNK2005: "void __cdecl put_pixel32(struct SDL_Surface *,int,int,unsigned int)" (?put_pixel32@@YAXPAUSDL_Surface@@HHI@Z) already defined in main.obj
1>xi_window.obj : error LNK2005: "void __cdecl flip_surface(struct SDL_Surface *,int,int)" (?flip_surface@@YAXPAUSDL_Surface@@HH@Z) already defined in main.obj
1>xi_window.obj : error LNK2005: "void __cdecl rotate_surface(struct SDL_Surface *,int,struct SDL_Rect *)" (?rotate_surface@@YAXPAUSDL_Surface@@HPAUSDL_Rect@@@Z) already defined in main.obj
1>xi_window.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl openFileName(char *,struct HWND__ *)" (?openFileName@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PADPAUHWND__@@@Z) already defined in main.obj
1>C:\Users\Xiphirx\Documents\CSPSPMEP Dev\CSPSPMEPv2\Debug\CSPSPMEPv2.exe : fatal error LNK1169: one or more multiply defined symbols found
main.cpp
Code: Select all
#include <iostream>
#include "SDL.h"
#include "mapEditor.h"
using namespace std;
int main( int argc, char* args[] )
{
mapEditor Editor(800, 600, 32, 60);
return Editor.loop();
}
Code: Select all
#ifndef MAPEDITOR
#define MAPEDITOR
#include <sstream>
#include "Timer.h"
#include "resourceManager.h"
#include "map.h"
#include "xi_window.h"
using namespace std;
class mapEditor
{
public:
mapEditor(int width, int height, int bbp, int fps = 60);
~mapEditor();
//Accessors
SDL_Surface * getScreen();
//Modifiers
void newMap(string path);
//other
int loop();
private:
//Screen surface, everything is drawn to it
SDL_Surface* screen;
SDL_Surface* backgroundFill;
SDL_Surface* tileSelector;
//Screen variables
int SCREENWIDTH,
SCREENHEIGHT,
SCREENBBP,
FPS;
//FPS Control
int frame;
//GUI data
int currentMap,
totalMaps;
//Events from keyboard
char key[323];
//Events
SDL_Event editorEvents;
//Program flow
bool quit;
//Timers
Timer FPSControl;
//Resource manager
resourceManager resources;
//maps
vector<map> maps;
//windowstest
xiGUI::window functionBar, infoBar;
//fonts
TTF_Font * editorFont;
//string stream for misc use
ostringstream stringStream;
};
#endif