Showing results for 
Show  only  | Search instead for 
Did you mean: 
Registered: ‎08-31-2018

undefined reference to Opencv function in Vivado Hls 2019.2

I have made an example of converting an RGB image to HSV and I have done that without OpenCV functions (just for fun!) then for the testbench I did the following:

#include "converter.h"
#include "hls_opencv.h"

int main(int argc, char** argv)
	IplImage* src=cvLoadImage("Input-test.jpg");
	IplImage* dst = cvCreateImage(cvGetSize(src), src->depth, src->nChannels);
	AXI_STREAM src_axi, dst_axi;
	IplImage2AXIvideo(src, src_axi);
	pynq_filters(src_axi, dst_axi);
	AXIvideo2IplImage(dst_axi, dst);
	cvSaveImage("testoutput.bmp", dst);

And in the convert.h file I included the following:

#include <ap_fixed.h>
#include <ap_int.h>
#include "hls_video.h"
#include "hls_math.h"

The errors that I get, when building, are only related to the testbench already mentioned above:

Building target: a.exe
Invoking: GCC C++ Linker
g++ -LC:/Xilinx/Vivado/2019.2/win64/tools/systemc/lib -o "a.exe"  ./testbench/ConverterTB.o  ./source/Convert.o   
./testbench/ConverterTB.o: In function `main':
C:/Users/anoir/Downloads/task2/ConverterTB.cpp:6: undefined reference to `cvLoadImage'
C:/Users/anoir/Downloads/task2/ConverterTB.cpp:7: undefined reference to `cvGetSize'
C:/Users/anoir/Downloads/task2/ConverterTB.cpp:7: undefined reference to `cvCreateImage'
C:/Users/anoir/Downloads/task2/ConverterTB.cpp:12: undefined reference to `cvSaveImage'
./testbench/ConverterTB.o: In function `void IplImage2AXIvideo<24>(_IplImage*, hls::stream<ap_axiu<24, 1, 1, 1> >&)':
C:/Xilinx/Vivado/2019.2/include/hls_opencv.h:137: undefined reference to `cvGet2D'
./testbench/ConverterTB.o: In function `void AXIvideo2IplImage<24>(hls::stream<ap_axiu<24, 1, 1, 1> >&, _IplImage*)':
C:/Xilinx/Vivado/2019.2/include/hls_opencv.h:244: undefined reference to `cvSet2D'
collect2.exe: error: ld returned 1 exit status
makefile:46: recipe for target 'a.exe' failed
make: *** [a.exe] Error 1

Could someone explain to me why am I getting this it is supposed to be a fixed issue since the 2014 version I think? Any idea how to fix this?


OS: Win10 - 64 bit

Vivado 2019.2


0 Kudos
1 Reply
Registered: ‎10-04-2011

Hello @anoir.nechi ,

The first thing I should say is that the hls_video.h library has been deprecated in the 2020.1 release, and the Vitis Vision library will provide all accelerated video functionality going forward. This library is located here:


I also would add that in versions prior to 2020.1, we provided an installation of OpenCV 2.x in the Vitis and Vivado installation directories. However, in 2020.1, we no longer provide this library in order to allow users to install the version of their choice, and to avoid version conflicts. This requires the user to install the OpenCV library, and provide environment variables pointing to that installation. In addition, we require multiple references to the OpenCV library for the HLS tools for C Simulation and CoSimulation, and the Vision Library for IP compilation. Note that the OpenCV installation is only necessary for testbench verification, and is not required in any way for kernel synthesis in HLS.


I have created a sticky post which highlights the process of setting up the environment and creating a TCL script to use the OpenCV library for the Vision Library L1 resize example. I recommend running this first, then using the project that is created for GUI development if you wish. That post is here:


That Vision library background aside, it seems that your environment is not setup correctly to reference the opencv libraries. Although your flow is slightly different, you should be able to modify that script I linked to for your older flow to point to the appropriate libraries. However, because that flow is deprecated, I recommend upgrading to the Vitis Vision flow so we can support you going forward.


OK, I hope this helps,


0 Kudos