1

我正在尝试编写一个 vlc 模块来用 wiimote 控制它。 http://wiki.videolan.org/Hacker_Guide/How_To_Write_a_Module

我正在使用库 cwiid.h http://abstrakraft.org/cwiid/wiki/libcwiid 我在 Kubuntu 11.10 上,当我用./vlc -vvv --extraintf wiimote编译我的模块时,我有这个信息 :

主界面警告:无法加载模块`/home/staross/vlc/modules/control/.libs/libwiimote_plugin.so'(/home/staross/vlc/modules/control/.libs/libwiimote_plugin.so:未定义符号:cwiid_find_wiimote)

编译器找不到库,有链接问题。

该库安装在此目录中:/usr/local/include/cwiid.h

我已经尝试了很多事情:

将绝对路径放在#include<>

更改 cwiid.h 的路径:/home/staross/vlc/include/

修改文件 ld.so.conf 并添加以下行:

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

修改 configure.ac 文件并添加这些行

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

像这样修改 Modules.am

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

当然还有来自 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");
}

所以这里的问题是我现在可以做些什么来希望编译器能够找到库并识别 cwiid.h 函数?谢谢!

4

1 回答 1

0

我解决了这个问题:

objdump -T libwiimote_plugin.so

我从vlc/modules/control/Makefile 修改了 Makefile并添加: LIBS_wiimote = -lcwiid

rm *wiimote*

重建

make V=1 libwiimote_plugin.la

问题解决了 :)

于 2012-05-01T12:58:36.123 回答