Page 2 of 2

Re: Help with Declaration Problem

Posted: Tue Jul 06, 2010 3:26 pm
by xiphirx
Ok, I believe I have forward declared correctly, and it compiles fine now, but I have 48 LNK2005 errors...

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
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

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();
}
mapEditor.h

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

Re: Help with Declaration Problem

Posted: Tue Jul 06, 2010 4:55 pm
by dandymcgee
Do all of your headers have include protection? It looks like something is being included twice (judging by the fact that all of the linker errors end with "is already defined in main.obj").

Re: Help with Declaration Problem

Posted: Tue Jul 06, 2010 5:16 pm
by xiphirx
dandymcgee wrote:Do all of your headers have include protection? It looks like something is being included twice (judging by the fact that all of the linker errors end with "is already defined in main.obj").
yes they do

EDIT: got it down to 29 somehow D8

Re: Help with Declaration Problem

Posted: Sun Jul 11, 2010 7:13 am
by MrDeathNote
xiphirx wrote:
dandymcgee wrote:Do all of your headers have include protection? It looks like something is being included twice (judging by the fact that all of the linker errors end with "is already defined in main.obj").
yes they do

EDIT: got it down to 29 somehow D8
Where else are you including SDL.h? And theres no forward decalration in mapEditor.h just a bunch of includes.

Re: Help with Declaration Problem

Posted: Sun Jul 11, 2010 5:54 pm
by xiphirx
I've fixed this problem a few days ago lol, didn't mark the topic sorry.

Anyway I am a dumbass (as usual) and I was thinking headers were something they weren't :) Everything is fine now.