BORBET Temat założony przez niniejszego użytkownika |
[C++][PSP] Błędy multiple definition of... oraz first defined here... » 2012-10-21 21:46:51 Witam, mam problem ze skompilowaniem trzech plików źródłowych. Problem polega na tym, że przy końcu kompilacji występują następujące błędy: MainMenu.o: In function `SetupCallbacks()': MainMenu.cpp:(.text+0x2a0): multiple definition of `SetupCallbacks()' main.o:main.cpp:(.text+0x0): first defined here MainMenu.o: In function `CallbackThread(unsigned int, void*)': MainMenu.cpp:(.text+0x330): multiple definition of `CallbackThread(unsigned int, void*)' main.o:main.cpp:(.text+0xc0): first defined here MainMenu.o: In function `setupPSP()': MainMenu.cpp:(.text+0x2fc): multiple definition of `setupPSP()' main.o:main.cpp:(.text+0x5c): first defined here MainMenu.o: In function `exit_callback(int, int, void*)': MainMenu.cpp:(.text+0x370): multiple definition of `exit_callback(int, int, void*)' main.o:main.cpp:(.text+0x100): first defined here Quit.o: In function `SetupCallbacks()': Quit.cpp:(.text+0x164): multiple definition of `SetupCallbacks()' main.o:main.cpp:(.text+0x0): first defined here Quit.o: In function `CallbackThread(unsigned int, void*)': Quit.cpp:(.text+0x1f4): multiple definition of `CallbackThread(unsigned int, void*)' main.o:main.cpp:(.text+0xc0): first defined here Quit.o: In function `setupPSP()': Quit.cpp:(.text+0x1c0): multiple definition of `setupPSP()' main.o:main.cpp:(.text+0x5c): first defined here Quit.o: In function `exit_callback(int, int, void*)': Quit.cpp:(.text+0x234): multiple definition of `exit_callback(int, int, void*)' main.o:main.cpp:(.text+0x100): first defined here C:\LTE\bin\make.exe: *** [AF.elf] Error 1 Kod Quit.cpp: #include "main.h"
void MainMenu::QuitWindow() { s32 cnt = 0; IGUIEnvironment * env = MenuDevice->getGUIEnvironment(); IGUIWindow * quit = env->addWindow( rect < s32 > ( 100 + cnt, 100 + cnt, 300 + cnt, 200 + cnt ), false, L"QUIT" ); env->addStaticText( L"Do you want to quit the Assault Forces?", rect < s32 > ( 45, 35, 180, 60 ), false, false, quit ); env->addButton( rect < s32 >( 20, 70, 80, 90 ), quit, 005, L"YES" ); env->addButton( rect < s32 >( 120, 70, 180, 90 ), quit, 006, L"NO" ); } Kod setupPSP.h: #ifndef SETUPPSP_H_INCLUDED #define SETUPPSP_H_INCLUDED
#include <pspkernel.h> #include <psppower.h> #include <pspdebug.h>
int exit_callback( int arg1, int arg2, void * common ) { sceKernelExitGame(); return 0; }
int CallbackThread( SceSize args, void * argp ) { int cbid; cbid = sceKernelCreateCallback( "Exit Callback", exit_callback, NULL ); sceKernelRegisterExitCallback( cbid ); sceKernelSleepThreadCB(); return 0; }
int SetupCallbacks( void ) { int thid = 0; thid = sceKernelCreateThread( "update_thread", CallbackThread, 0x11, 0xFA0, 0, 0 ); if( thid >= 0 ) { sceKernelStartThread( thid, 0, 0 ); } return thid; }
int setupPSP( void ) { scePowerSetClockFrequency( 333, 333, 166 ); SetupCallbacks(); pspDebugScreenInit(); }
#endif
Kod main.h:
[ cpp ] # ifndef MAIN_H_INCLUDED #define MAIN_H_INCLUDED
#include <engine.h> #include "setupPSP.h"
using namespace engine;
using namespace gui; using namespace core; using namespace scene; using namespace video; using namespace audio; using namespace io;
class MainMenu : public IEventReceiver { public: void Run(); virtual bool OnEvent( SEvent event ); private: engineDevice * MenuDevice; void QuitWindow(); };
#endif
Kod main.cpp:
[ cpp ] # include "main.h"
int engineMain( unsigned int, void * argv ) { setupPSP(); MainMenu menu; menu.Run(); } Kod MainMenu.cpp: #include "main.h"
bool MainMenu::OnEvent( SEvent event ) { if( event.EventType == EET_GUI_EVENT ) { s32 id = event.GUIEvent.Caller->getID(); switch( event.GUIEvent.EventType ) { case EGET_BUTTON_CLICKED: if( id == 000 ) { QuitWindow(); return true; } } return false; } }
void MainMenu::Run() { video::IVideoDriver * video = MenuDevice->getVideoDriver(); IGUIEnvironment * env = MenuDevice->getGUIEnvironment(); env->addButton( rect < s32 >( 360, 210, 460, 230 ), 0, 000, L"QUIT" ); env->addButton( rect < s32 >( 360, 170, 460, 190 ), 0, 001, L"ABOUT" ); env->addButton( rect < s32 >( 360, 130, 460, 150 ), 0, 002, L"SETTINGS" ); env->addButton( rect < s32 >( 360, 90, 460, 110 ), 0, 003, L"MULTIPLAYER" ); env->addButton( rect < s32 >( 360, 50, 460, 70 ), 0, 004, L"SINGLEPLAYER" ); while( MenuDevice->run() ) { video->beginScene( true, true, SColor( 0, 200, 200, 200 ) ); env->drawAll(); video->endScene(); } } Prosiłbym o pomoc, ponieważ próbowałem to zrobić, ale za chiny nie idzie. Używam silnika LTE Game Engine (port Irrlicht). Z góry dziękuje. |