VPU library - user project linkage fail

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

VPU library - user project linkage fail

跳至解决方案
2,762 次查看
petersuciu
Contributor III

Hello,

I want to build a simple C file, where I try to initialize the VPU on my imx6Q.

The sysroot has been obtained via Yocto and bitbake (latest dora branch), poky toolchain version @ 1.5.3.

My code is:

----------------------------------

#include <vpu_io.h>

#include <vpu_lib.h>

void func(void)

{

    int ret = 0, i;

    // Init VPU

    if(vpu_Init (NULL) < 0)

   {

        printf(">> failed to call vpu_Init()\n");

        ret = -1;

    }

}

-----------------------------------

full GCC command:

----------------------------------

arm-poky-linux-gnueabi-g++  -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/home/raziel/Programming/SDKs/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi -DHAVE_CONFIG_H -I. -I. -I..   --sysroot=/home/raziel/Programming/Workspace/Yocto/build/tmp/sysroots/nitrogen6x -I/home/raziel/Programming/Workspace/Yocto/build/tmp/sysroots/nitrogen6x/usr/include -I/home/raziel/Programming/Workspace/Yocto/build/tmp/sysroots/nitrogen6x/usr/src/kernel/include -fpermissive -g -O0  --sysroot=/home/raziel/Programming/Workspace/Yocto/build/tmp/sysroots/nitrogen6x -MT video_test.o -MD -MP -MF .deps/video_test.Tpo -c -o video_test.o video_test.cpp

arm-poky-linux-gnueabi-libtool --tag=CXX   --mode=link arm-poky-linux-gnueabi-g++  -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/home/raziel/Programming/SDKs/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi -I/home/raziel/Programming/Workspace/Yocto/build/tmp/sysroots/nitrogen6x/usr/include -I/home/raziel/Programming/Workspace/Yocto/build/tmp/sysroots/nitrogen6x/usr/src/kernel/include -fpermissive -g -O0  --sysroot=/home/raziel/Programming/Workspace/Yocto/build/tmp/sysroots/nitrogen6x -lvpu --sysroot=/home/raziel/Programming/Workspace/Yocto/build/tmp/sysroots/nitrogen6x -o video_test

--------------------------------------

I am specifying -lvpu as an argument to GCC, except that libtool complains:

undefined reference to 'vpu_Init(void*)'

I fail to see what the issue is, given the fact that GCC finds the library just fine.

Manually specifying the full path to libvpu.a or libvpu.so from the Yocto sysroot dir lead to the same result, undefined reference.

What am I doing wrong?

标签 (4)
标记 (2)
0 项奖励
回复
1 解答
1,657 次查看
petersuciu
Contributor III

Wrap the #include directive of vpu library headers inside extern "C".

new code:

extern "C"

{

#include <vpu_io.h>

#include <vpu_lib.h>

}

void func(void)

{

    int ret = 0, i;

    // Init VPU

    if(vpu_Init (NULL) < 0)

   {

        printf(">> failed to call vpu_Init()\n");

        ret = -1;

    }

}

this is because vpu library code is C compliant and I was using a C++ compiler to include a C generated library.

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,658 次查看
petersuciu
Contributor III

Wrap the #include directive of vpu library headers inside extern "C".

new code:

extern "C"

{

#include <vpu_io.h>

#include <vpu_lib.h>

}

void func(void)

{

    int ret = 0, i;

    // Init VPU

    if(vpu_Init (NULL) < 0)

   {

        printf(">> failed to call vpu_Init()\n");

        ret = -1;

    }

}

this is because vpu library code is C compliant and I was using a C++ compiler to include a C generated library.

0 项奖励
回复
1,657 次查看
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Thank you for sharing your solution. It is very appreciated.

Best Regards,

Alejandro

0 项奖励
回复