# RISCV OpenCV Linker Error

**URL:** <https://forum.opencv.org/t/riscv-opencv-linker-error/11217>\
**Category:** C++\
**Tags:** dnn, highgui, cuda, imgproc\
**Created:** [December 5, 2022, 1:34pm UTC](https://forum.opencv.org/t/riscv-opencv-linker-error/11217 "2022-12-05T13:34:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kahretsinanil](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@kahretsinanil](https://forum.opencv.org/u/kahretsinanil)\
**Post date:** [December 5, 2022, 1:34pm UTC](https://forum.opencv.org/t/riscv-opencv-linker-error/11217/1 "2022-12-05T13:34:28Z")

</div>

Hi,

The OpenCV version is 4.6.0-dev  
My system is Ubuntu 20.04  
I’m using RISCV GNU Toolchain.

I can run the basic image processing codes with gcc and RISCV but when I’m trying to compile the Googlenet sample code in [this](https://docs.opencv.org/4.x/d5/de7/tutorial_dnn_googlenet.html) link I have got this errors.

Even when I try to compile the code with gcc or RISCV, I got the same linker error.

```auto
gcc main.cpp -o sone -I /home/anil/Desktop/project/opencv/include/ -I /home/anil/Desktop/project/opencv/modules/core/include -I /home/anil/Desktop/project/opencv/build/install/include/opencv4 -I /home/anil/Desktop/project/opencv/modules/core/include/opencv2 -I /home/anil/Desktop/project/riscv-gnu-toolchain/gdb/zlib -I /home/anil/Desktop/deneme/gitdene/cnpy/ -I /usr/include/mkl -L/home/anil/Desktop/project/opencv/build/lib -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -I /home/anil/Desktop/project/opencv/samples/dnn/ -I/usr/local/cuda/include
/bin/ld: skipping incompatible /home/anil/Desktop/project/opencv/build/lib/libopencv_core.so when searching for -lopencv_core
/bin/ld: cannot find -lopencv_core
/bin/ld: skipping incompatible /home/anil/Desktop/project/opencv/build/lib/libopencv_imgcodecs.so when searching for -lopencv_imgcodecs
/bin/ld: cannot find -lopencv_imgcodecs
/bin/ld: skipping incompatible /home/anil/Desktop/project/opencv/build/lib/libopencv_imgproc.so when searching for -lopencv_imgproc
/bin/ld: cannot find -lopencv_imgproc
collect2: error: ld returned 1 exit status

```

```auto
riscv64-unknown-linux-gnu-g++ main.cpp -o sone -I /home/anil/Desktop/project/opencv/include/ -I /home/anil/Desktop/project/opencv/modules/core/include -I /home/anil/Desktop/project/opencv/build/install/include/opencv4 -I /home/anil/Desktop/project/opencv/modules/core/include/opencv2 -I /home/anil/Desktop/project/riscv-gnu-toolchain/gdb/zlib -I /home/anil/Desktop/deneme/gitdene/cnpy/ -I /usr/include/mkl -L/home/anil/Desktop/project/opencv/build/lib -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -I /home/anil/Desktop/project/opencv/samples/dnn/ -I/usr/local/cuda/include --static
/opt/riscv/lib/gcc/riscv64-unknown-linux-gnu/12.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: cannot find -lopencv_core: No such file or directory
/opt/riscv/lib/gcc/riscv64-unknown-linux-gnu/12.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: cannot find -lopencv_imgcodecs: No such file or directory
/opt/riscv/lib/gcc/riscv64-unknown-linux-gnu/12.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: cannot find -lopencv_imgproc: No such file or directory
collect2: error: ld returned 1 exit status

```

The main problem is linker in the linker I think, but the LD\_LİBRARY\_PATH is defined as shown below

```auto
root@ubuntu:/home/anil/Desktop/googlenet# echo $LD_LIBRARY_PATH
/home/anil/Desktop/project/opencv/build/lib

```

and the inside of this path is:

 ![aa](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/d/d2dcbc31aa01e9def932d0adcc9060a3326c5b85.png)

```auto
root@ubuntu:/home/anil/Desktop/googlenet# ls /home/anil/Desktop/project/opencv/build/lib
libopencv_calib3d.so libopencv_dnn.so.4.6.0 libopencv_gapi.so.406 libopencv_imgproc.so libopencv_objdetect.so.4.6.0 libopencv_videoio.so
libopencv_calib3d.so.406 libopencv_features2d.so libopencv_gapi.so.4.6.0 libopencv_imgproc.so.406 libopencv_photo.so libopencv_videoio.so.406
libopencv_calib3d.so.4.6.0 libopencv_features2d.so.406 libopencv_highgui.so libopencv_imgproc.so.4.6.0 libopencv_photo.so.406 libopencv_videoio.so.4.6.0
libopencv_core.so libopencv_features2d.so.4.6.0 libopencv_highgui.so.406 libopencv_ml.so libopencv_photo.so.4.6.0 libopencv_video.so
libopencv_core.so.406 libopencv_flann.so libopencv_highgui.so.4.6.0 libopencv_ml.so.406 libopencv_stitching.so libopencv_video.so.406
libopencv_core.so.4.6.0 libopencv_flann.so.406 libopencv_imgcodecs.so libopencv_ml.so.4.6.0 libopencv_stitching.so.406 libopencv_video.so.4.6.0
libopencv_dnn.so libopencv_flann.so.4.6.0 libopencv_imgcodecs.so.406 libopencv_objdetect.so libopencv_stitching.so.4.6.0
libopencv_dnn.so.406 libopencv_gapi.so libopencv_imgcodecs.so.4.6.0 libopencv_objdetect.so.406 libopencv_ts.a

```

Do you have any suggestions?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [December 5, 2022, 1:57pm UTC](https://forum.opencv.org/t/riscv-opencv-linker-error/11217/2 "2022-12-05T13:57:04Z")

</div>

are you trying to cross-compile? did you tell the compiler/toolchain this?

did _you_ compile those OpenCV module libraries? did you compile them _for RISCV_?

the official binary releases probably don’t include binaries for RV yet.

---

<div class="post-metadata">

**Author:** ![kahretsinanil](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@kahretsinanil](https://forum.opencv.org/u/kahretsinanil)\
**Post date:** [December 5, 2022, 6:00pm UTC](https://forum.opencv.org/t/riscv-opencv-linker-error/11217/3 "2022-12-05T18:00:54Z")

</div>

Hi,  
Im trying to cross compile and followed [this](https://opencv.org/optimizing-opencv-for-the-risc-v-architecture/) link.

Sample image processing applications can run on RISCV like image denoising, filtering and edge detection. But this libraries didn’t use the libraries which are shown above.
