Installing OpenCV on OSX 10.6 Using MacPorts

I tried installing OpenCV in accordance with the MacPorts installation instructions at http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port by typing

sudo port install opencv

in the terminal.

The installs / compilations seem to be all right and the files are in the / opt / local subdirectories, as it should be. As a first test, I tried to include highgui.h in the C ++ source file:

#include <highgui.h>

but when compiling with g ++ or gcc I get error: highgui.h: No such file or directory. I'm new to Mac development, so maybe I missed something? It seemed to me that I needed to set some path variable, and after reading some of the messages that I found while searching on Google, I tried to set DYLD_LIBRARY_PATH = / opt / local / lib, but this was a wild assumption, and this did not seem to help . What can compilers find a library for?

Thank!

+3
source share
4 answers

MacPorts C/++ /opt/local/include, . , GCC, , . , "-" "-I":

-             dir , , -I, .            , , . dir "=",             "=" sysroot; . --sysroot -isysroot.


-Idir             .             , . ,             , ( -).             -I, ; .

-, -I, -I            . - , .             , GCC - include_next            . , -nostdinc / -.

-, , . , std:: auto_ptr, -std = ++ 0x ..

. GCC, , -L.

+2

, , pkg-config.

, , :

g++ `pkg-config --libs --cflags opencv` -o helloWorld  helloWorld.cpp 

gcc, C ++.

, !

+3

- OpenCV: http://opencv.willowgarage.com/wiki/CompileOpenCVUsingMacOSX

:

export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
export LD_LIBRARY_PATH=/opt/local/lib

opencv- :

g++ -bind_at_load `pkg-config --cflags opencv` morphology.c -o morphology `pkg-config --libs opencv`

:

./morphology
+1

Macports install , tbb opencv, (, , ).

#include <highgui.h> ++.

#include<opencv2/highgui/highgui.hpp> /opt/local/include /opt/local/include/opencv.

0

Source: https://habr.com/ru/post/1764666/


All Articles