Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[C++][PSP] Błędy multiple definition of... oraz first defined here...

Ostatnio zmodyfikowano 2012-10-21 23:10
Autor Wiadomość
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:

C/C++
#include "main.h"

/////////////////////////////////////////////////
void MainMenu::QuitWindow()
{
   
    s32 cnt = 0;
    IGUIEnvironment * env = MenuDevice->getGUIEnvironment();
   
    //Add quit window
    IGUIWindow * quit = env->addWindow(
    rect < s32 >
    ( 100 + cnt, 100 + cnt, 300 + cnt, 200 + cnt ), // Xpos, Ypos, Xwidth, Yheight
    false,
    L"QUIT" );
   
    //Add text
    env->addStaticText(
    L"Do you want to quit the Assault Forces?",
    rect < s32 >
    ( 45, 35, 180, 60 ),
    false, //Border
    false,
    quit );
   
    //Add buttons
    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:

C/C++
#ifndef SETUPPSP_H_INCLUDED
#define SETUPPSP_H_INCLUDED

/////////////////////////////////////////////////
#include <pspkernel.h>
#include <psppower.h>
#include <pspdebug.h>

/////////////////////////////////////////////////
/* Exit callback */
int exit_callback( int arg1, int arg2, void * common ) {
    sceKernelExitGame();
    return 0;
}

/* Callback thread */
int CallbackThread( SceSize args, void * argp ) {
    int cbid;
   
    cbid = sceKernelCreateCallback( "Exit Callback", exit_callback, NULL );
    sceKernelRegisterExitCallback( cbid );
   
    sceKernelSleepThreadCB();
   
    return 0;
}

/* Sets up the callback thread and returns its thread id */
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 // SETUPPSP_H_INCLUDED[/cpp]



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 // MAIN_H_INCLUDED[/cpp]



Kod main.cpp:

[ cpp ] # include "main.h"

/////////////////////////////////////////////////
int engineMain( unsigned int, void * argv )
{
    setupPSP();
   
    MainMenu menu;
   
    menu.Run();
}


Kod MainMenu.cpp:

C/C++
#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 ) //Quit button
            {
                QuitWindow();
               
                return true;
            }
        }
        return false;
       
    }
}

/////////////////////////////////////////////////
void MainMenu::Run()
{
    //Drivers
    video::IVideoDriver * video = MenuDevice->getVideoDriver();
    IGUIEnvironment * env = MenuDevice->getGUIEnvironment();
   
    //Add buttons
    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.
P-67251
Admixior
» 2012-10-21 22:05:05
Zauważ że plik "setupPSP.h" inkludujesz w main.h, natomiast ten inkludujesz w 3 plikach więc w gruncie rzeczy są 3 definicje kilku funkcji. I o to chodzi kompilatorowi. w pliku "setupPSP.h" daj same deklaracje funkcji, natomiast utwórz plik "setupPSP.cpp" w którym będą definicje.


Należy kolorować składnie:
Kolorowanie składni
P-67252
BORBET
Temat założony przez niniejszego użytkownika
» 2012-10-21 23:10:10
Udało się! Dzięki za pomoc.
P-67253
« 1 »
  Strona 1 z 1