Fórum Root.cz

Hlavní témata => Vývoj => Téma založeno: Jenda 27. 02. 2012, 22:30:14

Název: Program se přeloží jen na virtuálu
Přispěvatel: Jenda 27. 02. 2012, 22:30:14
Ahoj psal jsem program pod Win Vista, a prubezne ho zkousel prekladat na virtualnim stroji s Ubuntu. Kdyz jsem si vsak nainstaloval cistou instalaci Ubuntu a pokusil se program prelozit dostavam hlasky vypsane nize se kterymi se nevim rady a to ani po prohledani diskuznich for.
Poprosil bych nekoho zkusenejsiho zda by mi nemohl rici pricinu problemu. Predem dekuji.

Kód: [Vybrat]
#ifndef JUK_H_INCLUDED
#define JUK_H_INCLUDED

class JukeboxApp : public wxApp
{
    public:
        virtual bool OnInit();
};
///
class SDL_Frame : public wxFrame
{
public :
SDL_Frame (wxWindow* parent, wxWindowID id,const wxString& label) : wxFrame(parent, id, label, wxDefaultPosition,wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{

wxButton* btn = new wxButton(this,wxID_ANY,_("Click me!")) ;
btn->Show () ;
}

void OnClicked (wxCommandEvent& evt)
{
WX_SendData((::Uint8)SDL_USEREVENT,0,NULL) ;
}

private :
DECLARE_EVENT_TABLE()
} ;

BEGIN_EVENT_TABLE(SDL_Frame, wxFrame)
EVT_BUTTON(wxID_ANY, SDL_Frame::OnClicked)
END_EVENT_TABLE()


class WXFrame_DebugAlgoritmu : public WX_Object
{
public :
bool OnInit ()
{
DebugAlgoritmu::DebugAlgoritmu* frame = new DebugAlgoritmu::DebugAlgoritmu(NULL) ;
frame->Show() ;
return true ;
}

int OnExit ()
{
return 0 ;
}

void OnData (WX_Data* data)
{
fprintf(stderr, "Get SDL event.%s\n", "DebugAlgoritmu");
}
private :
} ;

class WXFrame_Password : public WX_Object
{
public :
bool OnInit ()
{
Password::Password* frame = new Password::Password(NULL) ;
frame->Show() ;
return true ;
}

int OnExit ()
{
return 0 ;
}

void OnData (WX_Data* data)
{
fprintf(stderr, "Get SDL event.%s\n", "Password");
}
private :
} ;

class WXFrame_ServisniMenu: public WX_Object
{
public :
bool OnInit ()
{
ServisniMenu::ServisniMenu* frame = new ServisniMenu::ServisniMenu(NULL) ;
///SDL_Frame* frame = new SDL_Frame(NULL, wxID_ANY, _T("Test")) ;
frame->Show() ;
return true ;
}

int OnExit ()
{
return 0 ;
}

void OnData (WX_Data* data)
{
fprintf(stderr, "Get SDL event.%s\n", "ServisniMenu");
}
private :
} ;

class WXFrame_OknoVidea: public WX_Object
{
public :
bool OnInit ()
{
OknoVidea::OknoVidea* frame = new OknoVidea::OknoVidea(NULL) ;
frame->Show() ;
return true ;
}

int OnExit ()
{
return 0 ;
}

void OnData (WX_Data* data)
{
fprintf(stderr, "Get SDL event.%s\n", "OknoVidea");
}
private :
} ;


class SDL_Data : public WX_Data
{
public :
SDL_Data () : WX_Data ()
{
m_pStrBuf = NULL ;
}

void SetData ( const char* data )
{
if ( Lock () ) {
if ( data == NULL ) return ;
if ( m_pStrBuf != NULL ) {
delete[] m_pStrBuf ;
}
m_pStrBuf = new char [strlen(data)+1] ;
strcpy ( m_pStrBuf, data ) ;
Unlock () ;
}
}

void OnRelease ()
{
delete[] m_pStrBuf ;
}
private :
char* m_pStrBuf ;
} ;



#endif // JUK_H_INCLUDED


In member function ‘virtual bool WXFrame_DebugAlgoritmu::OnInit()’:|
error: ‘frame’ was not declared in this scope|
error: expected type-specifier|
error: expected ‘;’|
In member function ‘virtual bool WXFrame_Password::OnInit()’:|
error: ‘frame’ was not declared in this scope|
error: expected type-specifier|
error: expected ‘;’|
In member function ‘virtual bool WXFrame_ServisniMenu::OnInit()’:|
error: ‘frame’ was not declared in this scope|
error: expected type-specifier|
error: expected ‘;’|
In member function ‘virtual bool WXFrame_OknoVidea::OnInit()’:|
error: ‘frame’ was not declared in this scope|
error: expected type-specifier|
error: expected ‘;’|
In function ‘int main(int, char**)’:|
warning: passing NULL to non-pointer argument 1 of ‘int WX_Init(int, char**)’|
||=== Build finished: 12 errors, 1 warnings ===|
Název: Re:was not declared in this scope
Přispěvatel: tlwhitec 28. 02. 2012, 00:08:14
Cau, pokud je tohle jedinej a celej zdrojak, tak mu tam nejspis chybi nejaky #includy. Nikdy jsem nedelal s wxWidgets, a tak nevim, jestli se nejak nemontujou do kompilatoru, ani nepises, jakej na to pouzivas (Je mozny, ze je tam nejakej vlastni prave na to, coz bych vedel, kdybych to pouzival :)). Nicmene ta hlaska obecne znamena, ze kompilator nevidi nikde deklaraci objektu 'frame'. Pocitam, ze ta by mohla byt nekdy u deklarace WX_Object, takze by teoreticky mohlo stacit includnout spravnej header.

Pokud to ale kompilujes v pohode na virtualnim Ubuntu a na nromalnim ne, tak to je prinejmensim podivny. Jsi si jistej, ze ty instalace jsou jinak identicky? Pouzivas stejnou verzi wxWidgets? Pouzivas stejnou verzi kompilatoru? Jsou verze toho Ubuntu stejny? Mas vsechny baliky, co potrebujes? Pokud jo, tak je mi lito, ale vic nevim.
Název: Re:Program se přeloží jen na virtuálu
Přispěvatel: Jenda 28. 02. 2012, 22:47:27
Tridy z jednoho hlavickoveho souboru jsem rozdelil do vice samostatnych. A dosahl toho ze jeden se prelozi a druhy vypisuje nasledujici errory. Pro preklad pouzivam gcc. Prikladam i obsah WX_Object




Kód: [Vybrat]
#ifndef WXFRAME_PASSWORD_H_INCLUDED
#define WXFRAME_PASSWORD_H_INCLUDED

    class WXFrame_Password : public WX_Object
        {
        public :

            bool OnInit ()
                {
                Password * frame = new Password(NULL) ;
                frame->Show() ;
                return true ;
                }

            int OnExit ()
                {
                return 0 ;
                }

            void OnData (WX_Data* data)
                {
                fprintf(stderr, "Get SDL event.%s\n", "Password");
                }
        } ;
#endif // WXFRAME_PASSWORD_H_INCLUDED

Kód: [Vybrat]
#ifndef WXFRAME_DEBUGALGORITMU_INCLUDED
#define WXFRAME_DEBUGALGORITMU_INCLUDED

    class WXFrame_DebugAlgoritmu : public WX_Object
        {
        public :
            bool OnInit ()
                {
                DebugAlgoritmu* frame = new DebugAlgoritmu(NULL) ;
                frame->Show() ;
                return true ;
                }

            int OnExit ()
                {
                return 0 ;
                }

            void OnData (WX_Data* data)
                {
                fprintf(stderr, "Get SDL event.%s\n", "DebugAlgoritmu");
                }
        } ;
#endif // WXFRAME_DEBUGALGORITMU_INCLUDED


Kód: [Vybrat]
/**
    SDL_wx - using wxWidgets in SDL
    Copyright (C) 2003-2006 kr2.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    kr2
    ee12054g@hotmail.co.jp
*/
#ifndef __WX_OBJECT_HPP__
#define __WX_OBJECT_HPP__

#include "WX_Data.hpp"

#include <wx/wxprec.h>

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

/**
\class WX_Object
\brief wxWidgets‚ÅŠÇ—‚³‚ê‚éwxApp‚à‚Ç‚«

ƒƒCƒ“ƒXƒŒƒbƒh‚Ő¶¬‚µ‚Ä‚à–â‘è‚È‚¢‚ªA
Œˆ‚µ‚ăƒCƒ“ƒXƒŒƒbƒh‚©‚烁ƒ\ƒbƒh‚ðŒÄ‚яo‚³‚È‚¢‚±‚ƁB
‚Ü‚½AƒƒCƒ“ƒXƒŒƒbƒh‚ÅŽõ–½ŠÇ—‚às‚í‚È‚¢‚±‚ƁB

new‚Ő¶¬‚µAdelete‚͐â‘΂ɍs‚í‚È‚¢‚±‚ƁB
*/
class WX_Object
{
public :
virtual bool OnInit () { return true ; }
virtual void OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg) {}
/*
“o˜^–•ÁŽž‚É•K‚¸ŒÄ‚΂ê‚é
*/
virtual void OnUnregistered () {}
/*
”jŠü‚³‚ê‚éÛ‚É•K‚¸ŒÄ‚΂ê‚é
*/
virtual int OnExit () {return 0 ;}
virtual void OnData ( WX_Data* data ) {}
virtual bool OnCmdLineError(wxCmdLineParser& parser) { return true ; }
virtual bool OnCmdLineHelp(wxCmdLineParser& parser) { return true ; }
virtual bool OnCmdLineParsed(wxCmdLineParser& parser) { return true ; }
virtual void OnFatalException() {}
virtual void OnInitCmdLine(wxCmdLineParser& parser) {}
virtual void OnQueryEndSession(wxCloseEvent& event) {}
};

#endif // __WX_OBJECT_HPP__
Název: Re:Program se přeloží jen na virtuálu
Přispěvatel: tlwhitec 29. 02. 2012, 14:33:51
Jake pouzivas presne prikaz na ten preklad? Jestli pouzivas cisty gcc a ten soubor ma priponu .h, coz tak celkem vypada, tak to si pak gcc asi mysli, ze kouka na plain C a ne C++. Zkus vymenit gcc za g++, to by mohlo hodit neco rozumnejsiho.
Název: Re:Program se přeloží jen na virtuálu
Přispěvatel: Jenda 02. 03. 2012, 06:29:07
Tak jsem to jiz vyresil, nakonec stacilo preskladat nektere #include. Doted jsem nepovazoval za dulezite v jakem poradi je mam v souborech uvedene.

dekuji za rady