Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation errors [osx] #5

Closed
edbond opened this issue Oct 11, 2017 · 12 comments
Closed

Installation errors [osx] #5

edbond opened this issue Oct 11, 2017 · 12 comments

Comments

@edbond
Copy link

edbond commented Oct 11, 2017

go version go1.9.1 darwin/amd64
osx high sierra

Installed opencv first

$ brew install opencv

Next

$ go get github.com/hybridgroup/gocv
# github.com/hybridgroup/gocv
Undefined symbols for architecture x86_64:
  "cv::HoughLines(cv::_InputArray const&, cv::_OutputArray const&, double, double, int, double, double, double, double)", referenced from:
      _HoughLines in imgproc.cpp.o
  "cv::HoughLinesP(cv::_InputArray const&, cv::_OutputArray const&, double, double, int, double, double)", referenced from:
      _HoughLinesP in imgproc.cpp.o
  "cv::VideoWriter::fourcc(char, char, char, char)", referenced from:
      _VideoWriter_Open in videoio.cpp.o
  "cv::VideoWriter::VideoWriter()", referenced from:
      _VideoWriter_New in videoio.cpp.o
  "cv::getTextSize(cv::String const&, int, double, int, int*)", referenced from:
      _GetTextSize in imgproc.cpp.o
  "cv::namedWindow(cv::String const&, int)", referenced from:
      _Window_New in highgui.cpp.o
  "cv::GaussianBlur(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)", referenced from:
      _GaussianBlur in imgproc.cpp.o
  "cv::VideoCapture::VideoCapture()", referenced from:
      _VideoCapture_New in videoio.cpp.o
  "cv::destroyWindow(cv::String const&)", referenced from:
      _Window_Close in highgui.cpp.o
  "cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)", referenced from:
      _CascadeClassifier_DetectMultiScale in objdetect.cpp.o
  "cv::CascadeClassifier::load(cv::String const&)", referenced from:
      _CascadeClassifier_Load in objdetect.cpp.o
  "cv::CascadeClassifier::CascadeClassifier()", referenced from:
      _CascadeClassifier_New in objdetect.cpp.o
  "cv::CascadeClassifier::~CascadeClassifier()", referenced from:
      _CascadeClassifier_Close in objdetect.cpp.o
  "cv::Mat::deallocate()", referenced from:
      _Mat_Close in core.cpp.o
      _Mat_Clone in core.cpp.o
      _Image_IMRead in imgcodecs.cpp.o
  "cv::Mat::create(int, int const*, int)", referenced from:
      _Mat_NewWithSize in core.cpp.o
  "cv::Mat::copySize(cv::Mat const&)", referenced from:
      _Image_IMRead in imgcodecs.cpp.o
  "cv::Mat::Mat(cv::Mat const&, cv::Rect_<int> const&)", referenced from:
      _Mat_Region in core.cpp.o
  "cv::Mat::operator=(cv::Scalar_<double> const&)", referenced from:
      _Mat_NewWithSize in core.cpp.o
  "cv::blur(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, cv::Point_<int>, int)", referenced from:
      _Blur in imgproc.cpp.o
  "cv::Canny(cv::_InputArray const&, cv::_OutputArray const&, double, double, int, bool)", referenced from:
      _Canny in imgproc.cpp.o
  "cv::String::deallocate()", referenced from:
      cvflann::anyimpl::big_any_policy<cv::String>::static_delete(void**) in core.cpp.o
      cvflann::anyimpl::big_any_policy<cv::String>::move(void* const*, void**) in core.cpp.o
      _Window_New in highgui.cpp.o
      _Window_Close in highgui.cpp.o
      _Window_IMShow in highgui.cpp.o
      cvflann::anyimpl::big_any_policy<cv::String>::static_delete(void**) in highgui.cpp.o
      cvflann::anyimpl::big_any_policy<cv::String>::move(void* const*, void**) in highgui.cpp.o
      ...
  "cv::String::allocate(unsigned long)", referenced from:
      _Window_New in highgui.cpp.o
      _Window_Close in highgui.cpp.o
      _Window_IMShow in highgui.cpp.o
      _Image_IMRead in imgcodecs.cpp.o
      _Image_IMWrite in imgcodecs.cpp.o
      _Image_IMEncode in imgcodecs.cpp.o
      _GetTextSize in imgproc.cpp.o
      ...
  "cv::imread(cv::String const&, int)", referenced from:
      _Image_IMRead in imgcodecs.cpp.o
  "cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from:
      _Window_IMShow in highgui.cpp.o
  "cv::imwrite(cv::String const&, cv::_InputArray const&, std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
      _Image_IMWrite in imgcodecs.cpp.o
  "cv::putText(cv::_InputOutputArray const&, cv::String const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)", referenced from:
      _PutText in imgproc.cpp.o
  "cv::waitKey(int)", referenced from:
      _Window_WaitKey in highgui.cpp.o
  "cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)", referenced from:
      _CvtColor in imgproc.cpp.o
  "cv::fastFree(void*)", referenced from:
      _Mat_Close in core.cpp.o
      _Mat_Clone in core.cpp.o
      _Image_IMRead in imgcodecs.cpp.o
  "cv::imencode(cv::String const&, cv::_InputArray const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&, std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
      _Image_IMEncode in imgcodecs.cpp.o
  "cv::rectangle(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)", referenced from:
      _Rectangle in imgproc.cpp.o
  "cv::Mat::copyTo(cv::_OutputArray const&) const", referenced from:
      _Mat_Clone in core.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@ariesdevil
Copy link

Same error on MacOS High Sierra.

@edbond
Copy link
Author

edbond commented Oct 11, 2017

$ brew info opencv                           
opencv: stable 3.3.0 (bottled)
Open source computer vision library
http://opencv.org/
/usr/local/Cellar/opencv/3.3.0_3 (516 files, 123MB) *
  Poured from bottle on 2017-10-11 at 10:17:19
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/opencv.rb
==> Dependencies
Build: cmake ✘, pkg-config ✔
Required: eigen ✔, ffmpeg ✔, jpeg ✔, libpng ✔, libtiff ✔, openexr ✔, numpy ✔
==> Requirements
Required: python ✔, python3 ✔

@deadprogram
Copy link
Member

Hello, everyone.

Can you please try:

go get -d -u github.com/hybridgroup/gocv

The problem might be that go is trying to install before the pre-reqs are installed, or before the ENV vars are set as needed for your platform.

@edbond
Copy link
Author

edbond commented Oct 11, 2017

-d will not install

The -d flag instructs get to stop after downloading the packages; that is,
it instructs get not to install the packages.

Ran -d -u and then
$ go get -u github.com/hybridgroup/gocv results in the same error.

@edbond
Copy link
Author

edbond commented Oct 11, 2017

The build debug go build -v -x last command:

.......
cd /Users/eduard/go/default/src/gocv
clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fno-common -o $WORK/gocv/_obj/_cgo_.o $WORK/gocv/_obj/_cgo_main.o $WORK/gocv/_obj/_cgo_export.o $WORK/gocv/_obj/core.cgo2.o $WORK/gocv/_obj/highgui.cgo2.o $WORK/gocv/_obj/imgcodecs.cgo2.o $WORK/gocv/_obj/imgproc.cgo2.o $WORK/gocv/_obj/objdetect.cgo2.o $WORK/gocv/_obj/version.cgo2.o $WORK/gocv/_obj/videoio.cgo2.o $WORK/gocv/_obj/core.cpp.o $WORK/gocv/_obj/highgui.cpp.o $WORK/gocv/_obj/imgcodecs.cpp.o $WORK/gocv/_obj/imgproc.cpp.o $WORK/gocv/_obj/objdetect.cpp.o $WORK/gocv/_obj/version.cpp.o $WORK/gocv/_obj/videoio.cpp.o -g -O2
# gocv
Undefined symbols for architecture x86_64:
  "cv::HoughLines(cv::_InputArray const&, cv::_OutputArray const&, double, double, int, double, double, double, double)", referenced from:
      _HoughLines in imgproc.cpp.o
  "cv::HoughLinesP(cv::_InputArray const&, cv::_OutputArray const&, double, double, int, double, double)", referenced from:
.......

I think there should be cgo comment to include opencv lib in LDFLAGS like

// #cgo LDFLAGS: -lpng

I am not familiar with opencv, will let you know if find a way to fix.

@deadprogram
Copy link
Member

I think you need to first need to download:

go get -d -u github.com/hybridgroup/gocv

Once the package is downloaded, you would need to run the env.sh script to setup the build vars:

cd $GOPATH/src/github.com/hybridgroup/gocv
source ./env.sh

Once the env vars are set in that session, you should be able to try running code, such as the version command:

go run ./cmd/version/main.go

Please give that a try.

@edbond
Copy link
Author

edbond commented Oct 11, 2017

Yes, that works. Thanks.

$ source ./env.sh                
Environment variables configured for OSX
$ go run ./cmd/version/main.go 
gocv version: 0.1.0
opencv lib version: 3.3.0

@deadprogram
Copy link
Member

This is mentioned already here https://github.com/hybridgroup/gocv#how-to-buildrun-code but will need the go get -d -u part added.

@deadprogram
Copy link
Member

The README has been updated here ae24310 and the website here hybridgroup/gocv-site@898b709

I will close this issue once it is pushed to master. Thanks @edbond & @ariesdevil for your bug reports and assistance.

@deadprogram
Copy link
Member

OK this has now been released. Now closing, thank you again everyone.

@llitfkitfk
Copy link

image

@deadprogram
Copy link
Member

Hi @llitfkitfk from your log, looks like you are trying to build for iOS simulator, not Mac OS. Check your XCode default settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants