← Foro de C / C++

wiimote C ubuntu Codeblock

Hilo en el foro de C / C++ · 19 de Abril del 2010 · 2 respuestas
hook2419 de Abril del 2010
Pregunta
Hola, estoy realizando un proyecto en el cual manejare un submarino a trabes del mando de la wii.
Estoy comenzando por la conexión entre el Pc y el mando de la wii, para esto utilizo Ubuntu y la librería wiimote_api.h
He empezado con la simple tonteria de la conexion utilizando codeblock como entorno de programacion. Pero me he encontrado que al realizar el compilado me peta en la comanda
wiimote_connect( &wi, "XX:XX:XX:XX:XX:XX");
me sale undefined reference wiimote_connect( &wi, "XX:XX:XX:XX:XX:XX"). alguien tiene idea de como solucionarlo? he intentado agregar la libreria pero no he obtenido ninguna solucion.
A continuacion agrego el codigo, agradeceria cualquier respuesta.
Tambien he observado que hay una libreria Cwiid pero no me convence, nose si esta es mas facil de manejar que la otro o no, o si hay alguna libreria mas indicada.
Desde ya gracias, y si alguien sabe como se agrega la libreria para poder compilarlo con el codeblock para que no me salga este fallo se lo agradesco.

Saludos

[CODIGO]

#include "wx_pch.h"
#include "MandoMain.h"
#include <wx/msgdlg.h>
#include <stdio.h>
#include "wiimote_api.h"
#include "wiimote.h"
//(*InternalHeaders(MandoFrame)
#include <wx/string.h>
#include <wx/intl.h>
//*)

wiimote_t wi = WIIMOTE_INIT;

//helper functions
enum wxbuildinfoformat {
short_f, long_f };

wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);

if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif

#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}

return wxbuild;
}

//(*IdInit(MandoFrame)
const long MandoFrame::idMenuQuit = wxNewId();
const long MandoFrame::idMenuAbout = wxNewId();
const long MandoFrame::ID_STATUSBAR1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(MandoFrame,wxFrame)
//(*EventTable(MandoFrame)
//*)
END_EVENT_TABLE()

MandoFrame::MandoFrame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(MandoFrame)
wxMenuItem* MenuItem2;
wxMenuItem* MenuItem1;
wxMenu* Menu1;
wxMenuBar* MenuBar1;
wxMenu* Menu2;

Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&File"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Help"));
SetMenuBar(MenuBar1);
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
SetStatusBar(StatusBar1);

Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MandoFrame::OnQuit);
Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MandoFrame::OnAbout);
//*)
}

MandoFrame::~MandoFrame()
{
//(*Destroy(MandoFrame)
//*)
}

void MandoFrame::OnQuit(wxCommandEvent& event)
{
Close();
}

void MandoFrame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}

void MandoFrame::OnBConectarClick(wxCommandEvent& event)
{
//wiimote_connect(&wi, wi.link.r_addr);
wiimote_connect( &wi, "xx:xX:xx:xx");
}

void MandoFrame::OnBDesconectarClick(wxCommandEvent& event)
{

}


[\CODIGO]

Respuestas 2

trasgu19 de Abril del 2010
-Puede ser que el proyecto esté en C++ y la librería libwiimote utilize C, en este caso ahi que utilizar extern "C" o
-Puede que además de la librería .h requiera una librería .a o .so o .lib que puede ser añadida a través de las opciones de construcción del proyecto (Proyect/Build Options/Linker settings/Add)
hook2419 de Abril del 2010
es un WxWidgets project. LAs librerias .so .a las he intentado agregar de todas las formas correspondientes pero sigue el mismo fallo.
¿Buscas más hilos como este? Mira el foro de C / C++ o usa el buscador.