Linking OpenVX with OpenCV based Application

Hi,

I am trying to convert OpenCV data structure ( cv::Mat) to OpenVX data structure (vx_image). To do so using nvx_cv::createVXImageFromCVMat(context,src_image), I need a context object to be created. However, when I try to instantiate the object I get the following error.

undefined reference to `vxCreateContext’

Following is the code snippet I am using.

#include <VX/vx_types.h>

vx_context context = vxCreateContext();

My CMakeLists.txt has the following link libraries command:

target_link_libraries(/usr/lib/libvisionworks.so)

libvisionworks.so exists at the path. Also when I checked the symbols in this library it shows the following:

00000000000dc078 T vxCreateContext

I believe this symbol exists in the library. I am unable to make connections. Please guide me where I am making mistakes.

It may be compiler version issue.
Does the error message from linker indicates the expected prototype ?
If yes, check what gives :

objdump -T libvisionworks.so| grep vxCreateContext

If it is different, it might be because the library would have been built with one toolchain and options (say gcc4) but you are linking with another toolchain (say gcc5) or options.

Hi Honey_Patouceul,

Linker does not seem to indicate expected prototype.

[ 96%] Linking CXX executable hardwareOpt
od/libod.a(od.cpp.o): In function `aaObjectDetect::runODY(cv::Mat&)':
od.cpp:(.text+0xc24): undefined reference to `vxCreateContext'
collect2: error: ld returned 1 exit status
CMakeFiles/hardwareOpt.dir/build.make:157: recipe for target 'hardwareOpt' failed
ubuntu@tegra-ubuntu:~/VisionWorks-1.6-Samples$     objdump -T /usr/lib/libvisionworks.so| grep vxCreateContext
00000000000dc078 g    DF .text	0000000000000154  Base        vxCreateContext

It is likely an issue to make/tool/gcc version as you allude to. Is there an example which I can follow ? I do not see an VisionWorks sample using this (vxCreateContext) call. Instead all examples seem to use wrapper (ContextGuard) around it. Since that gets compiled, I used same g++, however no luck…

It’s hard to guess what happens, but you may try to add :

-std=c++11

in your CFLAGS.

Hi,

Please include ‘VX/vx.h’

For example:

#include <iostream>
#include <VX/vx.h>

int main(int argc, char** argv)
{
    vx_context context = vxCreateContext();
    std::cout <<"Good!" << std::endl;
    return 0;
}
$ nvcc topic_1016124.cpp -lvisionworks -o test && ./test

If you still met error, please attach source for us debugging.
Thanks.