Question

I'm trying to write a vlc module to control it with the wiimote. http://wiki.videolan.org/Hacker_Guide/How_To_Write_a_Module

I'm using the library cwiid.h http://abstrakraft.org/cwiid/wiki/libcwiid I'm on Kubuntu 11.10 and when I'm compiling my module with ./vlc -vvv --extraintf wiimote I've this message :

main interface warning: cannot load module `/home/staross/vlc/modules/control/.libs/libwiimote_plugin.so' (/home/staross/vlc/modules/control/.libs/libwiimote_plugin.so: undefined symbol: cwiid_find_wiimote)

The compilator can't find the library, there is a link problem.

the library is installed in this directory: /usr/local/include/cwiid.h

I've already try lot of things:

put the absolute path in the #include<>

Change the path of cwiid.h : /home/staross/vlc/include/

Modify the file ld.so.conf and add this lines:

include /etc/ld.so.conf.d/*.conf
include /usr/local/lib/*.h

Modify the configure.ac file and add theses lines

dnl
dnl  Wiimote plugin
dnl
AC_ARG_ENABLE(wiimote,
  [  --enable-wiimote           wiimote support (default disabled)])
if test "${enable_wiimote}" = "yes"
then
  AC_CHECK_HEADER(cwiid.h, AC_CHECK_LIB(cwiid, cwiid_open, have_cwiid="true", have_cwiid="false"), have_cwiid="false")
  if test "${have_cwiid}" = "true"
  then
    VLC_ADD_PLUGIN([wiimote])
    VLC_ADD_LIBS([wiimote],[-lcwiid])
  fi
fi

Modify the Modules.am like that

SOURCES_hello = hello.c
SOURCES_wiimote = wiimote.c

SUBDIRS = globalhotkeys dbus
SOURCES_dummy = dummy.c
SOURCES_gestures = gestures.c
SOURCES_netsync = netsync.c
SOURCES_ntservice = ntservice.c
SOURCES_hotkeys = hotkeys.c
SOURCES_lirc = lirc.c
SOURCES_oldrc = rc.c
if HAVE_DARWIN
motion_extra = unimotion.c unimotion.h
else
motion_extra = $(NULL)
endif
SOURCES_motion = \
        motion.c \
        $(motion_extra) \
        $(NULL)

libvlc_LTLIBRARIES += \
    libdummy_plugin.la \
    libgestures_plugin.la \
    libnetsync_plugin.la \
    libhotkeys_plugin.la \
    libhello_plugin.la \
    libwiimote_plugin.la
if !HAVE_WINCE
libvlc_LTLIBRARIES += \
    liboldrc_plugin.la
if !HAVE_WIN32
libvlc_LTLIBRARIES += \
    libmotion_plugin.la
else
libvlc_LTLIBRARIES += \
    libntservice_plugin.la
endif
endif

And of course the code from wiimote.c

#include <fcntl.h>

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

/* VLC core API headers */
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_interface.h>

#include <stdlib.h>
#include <vlc_input.h>
#include <vlc_vout.h>
#include <vlc_aout.h>
#include <vlc_osd.h>
#include <vlc_playlist.h>
#include <cwiid.h>

#define BATTERY_STR_LEN 14
#define CHANNELS_NUMBER 4
#define VOLUME_TEXT_CHAN     p_global_intf->p_sys->p_channels[ 0 ]
#define VOLUME_WIDGET_CHAN   p_global_intf->p_sys->p_channels[ 1 ]

/* Forward declarations */
static int  Open    ( vlc_object_t * );
static void Close   ( vlc_object_t * );

/*****************************************************************************
 * Module descriptor
 *****************************************************************************/

vlc_module_begin ()
    set_shortname( N_("Wiimote") )
    set_description( N_("Wiimote control interface") )
    set_category( CAT_INTERFACE )
    set_subcategory( SUBCAT_INTERFACE_CONTROL )
    set_capability( "interface", 0 )
    set_callbacks( Open, Close )
vlc_module_end ()

/*****************************************************************************
 * intf_sys_t: description and status of interface
 *****************************************************************************/
struct intf_sys_t
{
    cwiid_wiimote_t* p_wiimote;        /* wiimote handle */
    struct cwiid_state state;          /* wiimote state */
    bdaddr_t bdaddr;                   /* bluetooth device address */
    int p_channels[ CHANNELS_NUMBER ]; /* contains registered
                                        * channel IDs */
    uint16_t status;
};

/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
static void Run( intf_thread_t * );
void cwiid_callback(cwiid_wiimote_t *wiimote, int mesg_count, union cwiid_mesg mesg[], struct timespec *timestamp);
void cwiid_btn(struct cwiid_btn_mesg *mesg);

static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,
                         audio_volume_t i_vol );
static void ClearChannels( intf_thread_t *p_intf, vout_thread_t *p_vout );

/*****************************************************************************
 * Open: initialize interface
 *****************************************************************************/
static int Open( vlc_object_t *obj )
{   
    intf_thread_t *p_intf = (intf_thread_t *)obj; /* déclaration d'un Thread */
    intf_sys_t *p_sys; /* déclaration d'un pointeur p_sys de type intf_sys_t */

    p_intf->p_sys = p_sys = malloc( sizeof( intf_sys_t ) );
    if( p_sys == NULL )
    {
    msg_Info(p_intf, "VLC_ENOMEM\n");
        return VLC_ENOMEM;
    }
    /* #define BDADDR_ANY   (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) */
    p_sys->bdaddr = *BDADDR_ANY; 
    p_intf->pf_run = Run;

    msg_Info(p_intf, "VLC_SUCCESS\n");
    return VLC_SUCCESS;
}

/*****************************************************************************
 * Close: destroy interface
 *****************************************************************************/
static void Close( vlc_object_t *obj )
{
    intf_thread_t *p_intf = (intf_thread_t *)obj;
    intf_sys_t *p_sys = p_intf->p_sys;

    free( p_sys );
}

intf_thread_t *p_global_intf = NULL;

/*****************************************************************************
 * Run: main loop
 *****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
    p_global_intf = p_intf;
    intf_sys_t *p_sys = p_intf->p_sys; /* déclaration d'un pointeur p_sys de type intf_sys_t */
    struct cwiid_state state;
    p_sys->status = 0;

    msg_Err(p_intf, "Put Wiimote in discoverable mode (press 1+2) to connect it...\n");
    cwiid_find_wiimote(&p_sys->bdaddr, 0);
    msg_Info(p_intf, "Test\n");
}

So the question here is what can I do now to hope that the compilator will find the library and recognise the cwiid.h functions ? Thank you!

Was it helpful?

Solution

I solved the problem:

objdump -T libwiimote_plugin.so

I modified the Makefile from vlc/modules/control/Makefile and add: LIBS_wiimote = -lcwiid

after

rm *wiimote*

rebuild with

make V=1 libwiimote_plugin.la

problem solved :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top