Opencv installed but not working in c++

System information (version)
  • OpenCV => 4.5.2
  • Operating System / Platform => Arch Linux
  • Compiler => g++
Detailed description

I installed opencv using pacman

sudo pacman -S opencv

When i use the following makefile to compile it

CC = "g++"
PROJECT = opencvTut
SRC = main.cpp

LIBS = `pkg-config opencv4 --cflags --libs`

$(PROJECT): $(SRC)
	$(CC) $(SRC) -o $(PROJECT) $(LIBS)

I get the following error

collect2: error: ld returned 1 exit status
make: *** [makefile:8: opencvTut] Error 1

the complete error log is here:

Please help

what does it do, exactly ?
if it installs prebuilt opencv libs, problem might be, that they were built against a different version of vtk, than you have locally

do you really need the opencv viz module ? (that’s where all the errors are from)

maybe, ditching the pkg-config approach in favour of an explicit g++ cmdline can give you more finedgrained control on what you’re actually linking

That is not the problem because arch builds them on the fly for you. Is there a way to install opencv viz module correcty. I am not sure if i am using them but the error still persists.

I tried using Cmake but the same error came.

This got me thinking and when i checked i found that i did not have an existing vtk installation on my pc. I installed vtk and it worked. But I am still not on the latest version of vtk. I am not able to build vtk-9 from arch user repo can you help me with that

no, sorry, that’s way off

again, most likely you don’t want to visualize 3d point clouds using opencv’s viz module, and all you have to do is to build a smarter compile script (pkg-config will drag in ALL available opencv libs, if <ou want them, or not, just get rid of that!)

you should take it up with the package maintainers of your distribution.

Maintainers: Antonio Rojas
Last Packager: Felix Yan

https://archlinux.org/packages/extra/x86_64/opencv/

1 Like