Building and Running GoLang executable

Hello there! I am kinda new to GoLang and I have created a C++ code using OpenCV-4.0.0, wrapped it inside C library which I have included into my GoLang project. Here is my opencvTest.go file:

package main

#cgo LDFLAGS: -L/usr/local/lib -lopencv_core -lopencv_video -lopencv_videoio -lopencv_highgui -lopencv_tracking -lopencv_optflow
#include "dense_flow.h"
import (

func main(){

	sampleVideo := "URFD_images/Falls/fall_fall-01"
	fmt.Printf("Calculating Optical Flow for Video: %s", sampleVideo)

	previousFrame := gocv.NewMat()
	defer previousFrame.Close()

	currentFrame := gocv.NewMat()
	defer currentFrame.Close()

When I ran go build command and then ./Test (its called Test since files are located in Test directory) everything worked perfectly fine. Then I tried to build my other Go project, and I get the following:

pkg-config --cflags – opencv4

Package opencv4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv4.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘opencv4’ found
pkg-config: exit status 1

NOTE: I am using gocv inside that project.

I am not sure what is going on. Any suggestions?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.