Compilation VLC模块,Cwiid,Linux,Wiimote,编译问题

Compilation VLC模块,Cwiid,Linux,Wiimote,编译问题,compilation,vlc,undefined-symbol,wiimote,Compilation,Vlc,Undefined Symbol,Wiimote,我想写一个vlc模块,用wiimote控制它。 我在用图书馆cwiid.h 我在Kubuntu 11.10上,当我使用./vlc-vvv--extrantf wiimote编译模块时,我收到以下消息: 主界面警告:无法加载模块“/home/staross/vlc/modules/control/.libs/libwimote\u plugin.so”(/home/staross/vlc/modules/control/.libs/libwimote\u plugin.so:未定义符号:cwii

我想写一个vlc模块,用wiimote控制它。

我在用图书馆cwiid.h 我在Kubuntu 11.10上,当我使用./vlc-vvv--extrantf wiimote编译模块时,我收到以下消息:

主界面警告:无法加载模块“/home/staross/vlc/modules/control/.libs/libwimote\u plugin.so”(/home/staross/vlc/modules/control/.libs/libwimote\u plugin.so:未定义符号:cwiid\u find\u 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
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
修改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

include /etc/ld.so.conf.d/*.conf
include /usr/local/lib/*.h
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");
}
#包括
#如果定义有配置
#包括“config.h”
#恩迪夫
/*VLC核心API头*/
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#定义电池结构14
#定义4号通道
#定义卷文本更改全局导入->卷系统->卷通道[0]
#定义音量控件\u CHAN p\u global\u intf->p\u sys->p\u通道[1]
/*转发声明*/
静态int打开(vlc_object_t*);
静态空洞闭合(vlc_对象_t*);
/*****************************************************************************
*模块描述符
*****************************************************************************/
vlc_模块_开始()
set_shortname(N_uu(“Wiimote”))
设置描述(N(“Wii远程控制接口”))
设置_类别(CAT_接口)
设置子类别(子类别接口控制)
设置_能力(“接口”,0)
设置回调(打开、关闭)
vlc_模块_端()
/*****************************************************************************
*intf_系统:接口的描述和状态
*****************************************************************************/
结构输入系统
{
cwiid_wiimote_t*p_wiimote;/*wiimote手柄*/
结构cwiid_state state;/*wiimote state*/
bdaddr\u t bdaddr;/*蓝牙设备地址*/
int p_通道[通道编号];/*包含已注册的
*通道ID*/
uint16_t状态;
};
/*****************************************************************************
*本地原型
*****************************************************************************/
静态无效运行(intf_线程_t*);
无效cwiid_回调(cwiid_wiimote_t*wiimote,int-mesg_计数,联合cwiid_-mesg-mesg[],结构timespec*时间戳);
无效cwiid_btn(结构cwiid_btn_mesg*mesg);
静态void DisplayVolume(intf_thread_t*p_intf,vout_thread_t*p_vout,
音频(音量);
静态无效清除通道(intf_线程\u t*p_intf、vout_线程\u t*p_vout);
/*****************************************************************************
*打开:初始化接口
*****************************************************************************/
静态整数打开(vlc_对象_t*obj)
{   
intf_thread_t*p_intf=(intf_thread_t*)对象;/*déclaration d'un thread*/
intf_系统*p_系统;/*déclaration d'un pointeur p_系统de type intf_系统*/
p_intf->p_sys=p_sys=malloc(sizeof(intf_sys_t));
如果(p_sys==NULL)
{
msg_Info(p_intf,“VLC_ENOMEM”);
返回VLC_ENOMEM;
}
/*#定义BDADDR_ANY(&(BDADDR_t){{{0,0,0,0,0}})*/
p_sys->bdaddr=*bdaddr_ANY;
p_intf->pf_run=run;
消息信息(p_intf,“VLC_成功”\n);
返回VLC_成功;
}
/*****************************************************************************
*关闭:销毁接口
*****************************************************************************/
静态空隙闭合(vlc_对象_t*obj)
{
intf_thread_t*p_intf=(intf_thread_t*)obj;
intf_sys_t*p_sys=p_intf->p_sys;
免费(p_sys);
}
intf_线程\u t*p_全局\u intf=NULL;
/*****************************************************************************
*运行:主循环
*****************************************************************************/
静态无效运行(intf\U线程\U t*p\U intf)
{
p_global_intf=p_intf;
intf_sys*p_sys=p_intf->p_sys;/*déclaration d'un pointeur p_sys de type intf_sys*/
结构cwiid_状态;
p_sys->status=0;
msg_Err(p_intf,“将Wiimote置于可发现模式(按1+2)以连接它…\n”);
cwiid\u find\u wiimote(&p\u sys->bdaddr,0);
msg_Info(p_intf,“Test\n”);
}
所以这里的问题是,我现在能做些什么,希望编译器能够找到库并识别cwiid.h函数? 谢谢大家!

我解决了这个问题:

objdump -T libwiimote_plugin.so
我修改了vlc/modules/control/Makefile中的Makefile,并添加了:LIBS_wiimote=-lcwiid

之后

rm*wiimote*

重建

make V=1 libwimote\u plugin.la

问题已解决:)