在Qt中移植VPU编解码程序时遇到的问题

来源:互联网 发布:java io读取文件 编辑:程序博客网 时间:2024/05/18 02:21
在使用freescale开发板实现VPU的硬编码过程中,将测试程序中关于vpu编码函数移植到Qt中,在pro文件中包含 "vpu_lib.h"、"vpu_io.h"的文件路径以及对应的链接库文件:
  INCLUDEPATH  += "/mnt/hgfs/window_share/linux-3.0.35/include"
  INCLUDEPATH  += "/home/imx6/rootfs/usr/include"
  LIBS += -L"/home/imx6/rootfs/usr/lib" -lvpu


在源文件中包含了vpu的两个头文件:
#include "vpu_lib.h"
#include "vpu_io.h"


但会出现如下错误提示,经过排查,上面的路径设置都没有问题,那么问题在哪呢?
undefined reference to `vpu_Init(void*)'
undefined reference to `vpu_GetVersionInfo(vpu_versioninfo*)'
undefined reference to `vpu_UnInit()'
undefined reference to `IOGetPhyMem(vpu_mem_desc*)'
undefined reference to `IOGetVirtMem(vpu_mem_desc*)'
undefined reference to `vpu_DecOpen(CodecInst**,........)


解决办法:
对于在C++中调用C语言编写的函数或C编译器生成的链接库文件,需要添加extern "C"{ },因为C编译器编译生成的函数名与C++编译器生成的函数名不同的。
在源文件中包含了vpu的两个头文件则修改为如下形式即可运行通过:
#ifdef __cplusplus
extern "C" {
#endif
#include "vpu_lib.h"
#include "vpu_io.h"
#ifdef __cplusplus
}

#endif


原创粉丝点击