Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Lib Imf_2_3 undefined references under Manjaro

I'm trying to compile darknet under Manjaro Linux but seems I have a libImf version mismatch.

gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -O0 -g -DOPENCV -DGPU -DCUDNN obj/captcha.o obj/lsd.o obj/super.o obj/art.o obj/tag.o obj/cifar.o obj/go.o obj/rnn.o obj/segmenter.o obj/regressor.o obj/classifier.o obj/coco.o obj/yolo.o obj/detector.o obj/nightmare.o obj/instance-segmenter.o obj/darknet.o libdarknet.a -o darknet -lm -pthread -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'  `pkg-config --libs opencv` -lstdc++ -lopencv_videoio  -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -lopencv_highgui -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -lcudnn -lstdc++  libdarknet.a
/usr/bin/ld: warning: libIlmImf-2_3.so.24, needed by /opt/opencv3/lib/libopencv_imgcodecs.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::InputFile(char const*, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::insert(char const*, Imf_2_3::Slice const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::channels()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::chromaticities(Imf_2_3::Header const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::OutputFile(char const*, Imf_2_3::Header const&, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::begin()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::Header(int, int, float, Imath_2_3::Vec2<float> const&, float, Imf_2_3::LineOrder, Imf_2_3::Compression)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Channel::Channel(Imf_2_3::PixelType, int, int, bool)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::channels() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::end()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::header() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::~Header()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::readPixels(int, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::globalThreadCount()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::dataWindow() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::ChannelList::findChannel(char const*) const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::~OutputFile()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Slice::Slice(Imf_2_3::PixelType, char*, unsigned long, unsigned long, int, int, double, bool, bool)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Chromaticities::Chromaticities(Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::writePixels(int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::ChannelList::insert(char const*, Imf_2_3::Channel const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::hasChromaticities(Imf_2_3::Header const&)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:77: darknet] Error 1

How can I fix it?

Lib Imf_2_3 undefined references under Manjaro

I'm trying to compile darknet under Manjaro Linux but seems I have a libImf version mismatch.

gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -O0 -g -DOPENCV -DGPU -DCUDNN obj/captcha.o obj/lsd.o obj/super.o obj/art.o obj/tag.o obj/cifar.o obj/go.o obj/rnn.o obj/segmenter.o obj/regressor.o obj/classifier.o obj/coco.o obj/yolo.o obj/detector.o obj/nightmare.o obj/instance-segmenter.o obj/darknet.o libdarknet.a -o darknet -lm -pthread -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'  `pkg-config --libs opencv` -lstdc++ -lopencv_videoio  -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -lopencv_highgui -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -lcudnn -lstdc++  libdarknet.a
/usr/bin/ld: warning: libIlmImf-2_3.so.24, needed by /opt/opencv3/lib/libopencv_imgcodecs.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::InputFile(char const*, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::insert(char const*, Imf_2_3::Slice const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::channels()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::chromaticities(Imf_2_3::Header const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::OutputFile(char const*, Imf_2_3::Header const&, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::begin()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::Header(int, int, float, Imath_2_3::Vec2<float> const&, float, Imf_2_3::LineOrder, Imf_2_3::Compression)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Channel::Channel(Imf_2_3::PixelType, int, int, bool)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::channels() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::end()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::header() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::~Header()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::readPixels(int, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::globalThreadCount()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::dataWindow() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::ChannelList::findChannel(char const*) const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::~OutputFile()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Slice::Slice(Imf_2_3::PixelType, char*, unsigned long, unsigned long, int, int, double, bool, bool)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Chromaticities::Chromaticities(Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::writePixels(int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::ChannelList::insert(char const*, Imf_2_3::Channel const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::hasChromaticities(Imf_2_3::Header const&)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:77: darknet] Error 1

How can I fix it?

EDIT 1: Thanks @berak I did what you suggested and now I have new errors:

[ 51%] Linking CXX executable uselib
/usr/bin/ld: CMakeFiles/uselib.dir/src/yolo_console_dll.cpp.o: in function `draw_boxes(cv::Mat, std::vector<bbox_t, std::allocator<bbox_t> >, std::vector<std::string, std::allocator<std::string> >, int, int)':
yolo_console_dll.cpp:(.text+0x461): undefined reference to `cv::getTextSize(std::string const&, int, double, int, int*)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x633): undefined reference to `cv::getTextSize(std::string const&, int, double, int, int*)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x960): undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0xa8e): undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0xc76): undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
/usr/bin/ld: CMakeFiles/uselib.dir/src/yolo_console_dll.cpp.o: in function `main':
yolo_console_dll.cpp:(.text+0x2d05): undefined reference to `cv::VideoCapture::open(std::string const&, int)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x3493): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x358a): undefined reference to `cv::destroyWindow(std::string const&)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x384d): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x3971): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x3bd0): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
/usr/bin/ld: libdark.so: undefined reference to `cv::namedWindow(std::string const&, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::moveWindow(std::string const&, int, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::setWindowProperty(std::string const&, int, double)'
/usr/bin/ld: libdark.so: undefined reference to `cv::VideoWriter::VideoWriter(std::string const&, int, double, cv::Size_<int>, bool)'
/usr/bin/ld: libdark.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::VideoCapture::VideoCapture(std::string const&, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::resizeWindow(std::string const&, int, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::imencode(std::string const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/uselib.dir/build.make:138: uselib] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/uselib.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
==> ERROR: Makepkg was unable to build darknet-alexeyab-git.
==> Restart building darknet-alexeyab-git ? [y/N]
==> ---------------------------------------------

Lib Imf_2_3 undefined references under Manjaro

I'm trying to compile darknet under Manjaro Linux but seems I have a libImf version mismatch.

gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -O0 -g -DOPENCV -DGPU -DCUDNN obj/captcha.o obj/lsd.o obj/super.o obj/art.o obj/tag.o obj/cifar.o obj/go.o obj/rnn.o obj/segmenter.o obj/regressor.o obj/classifier.o obj/coco.o obj/yolo.o obj/detector.o obj/nightmare.o obj/instance-segmenter.o obj/darknet.o libdarknet.a -o darknet -lm -pthread -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'  `pkg-config --libs opencv` -lstdc++ -lopencv_videoio  -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -lopencv_highgui -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -lcudnn -lstdc++  libdarknet.a
/usr/bin/ld: warning: libIlmImf-2_3.so.24, needed by /opt/opencv3/lib/libopencv_imgcodecs.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::InputFile(char const*, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::insert(char const*, Imf_2_3::Slice const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::channels()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::chromaticities(Imf_2_3::Header const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::OutputFile(char const*, Imf_2_3::Header const&, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::begin()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::Header(int, int, float, Imath_2_3::Vec2<float> const&, float, Imf_2_3::LineOrder, Imf_2_3::Compression)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Channel::Channel(Imf_2_3::PixelType, int, int, bool)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::channels() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::end()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::header() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::~Header()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::readPixels(int, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::globalThreadCount()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::dataWindow() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::ChannelList::findChannel(char const*) const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::~OutputFile()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Slice::Slice(Imf_2_3::PixelType, char*, unsigned long, unsigned long, int, int, double, bool, bool)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Chromaticities::Chromaticities(Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::writePixels(int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::ChannelList::insert(char const*, Imf_2_3::Channel const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::hasChromaticities(Imf_2_3::Header const&)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:77: darknet] Error 1

How can I fix it?

EDIT 1: Thanks @berak I did what you suggested and now I have new errors:

[ 51%] Linking CXX executable uselib
/usr/bin/ld: CMakeFiles/uselib.dir/src/yolo_console_dll.cpp.o: in function `draw_boxes(cv::Mat, std::vector<bbox_t, std::allocator<bbox_t> >, std::vector<std::string, std::allocator<std::string> >, int, int)':
yolo_console_dll.cpp:(.text+0x461): undefined reference to `cv::getTextSize(std::string const&, int, double, int, int*)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x633): undefined reference to `cv::getTextSize(std::string const&, int, double, int, int*)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x960): undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0xa8e): undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0xc76): undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
/usr/bin/ld: CMakeFiles/uselib.dir/src/yolo_console_dll.cpp.o: in function `main':
yolo_console_dll.cpp:(.text+0x2d05): undefined reference to `cv::VideoCapture::open(std::string const&, int)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x3493): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x358a): undefined reference to `cv::destroyWindow(std::string const&)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x384d): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x3971): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x3bd0): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
/usr/bin/ld: libdark.so: undefined reference to `cv::namedWindow(std::string const&, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::moveWindow(std::string const&, int, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::setWindowProperty(std::string const&, int, double)'
/usr/bin/ld: libdark.so: undefined reference to `cv::VideoWriter::VideoWriter(std::string const&, int, double, cv::Size_<int>, bool)'
/usr/bin/ld: libdark.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::VideoCapture::VideoCapture(std::string const&, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::resizeWindow(std::string const&, int, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::imencode(std::string const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/uselib.dir/build.make:138: uselib] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/uselib.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
==> ERROR: Makepkg was unable to build darknet-alexeyab-git.
==> Restart building darknet-alexeyab-git ? [y/N]
==> ---------------------------------------------

yes I believe I'm linking here the makefile:

GPU=1
CUDNN=1
CUDNN_HALF=0
OPENCV=1
AVX=0
OPENMP=1
LIBSO=0
ZED_CAMERA=0

# set GPU=1 and CUDNN=1 to speedup on GPU
# set CUDNN_HALF=1 to further speedup 3 x times (Mixed-precision on Tensor Cores) GPU: Volta, Xavier, Turing and higher
# set AVX=1 and OPENMP=1 to speedup on CPU (if error occurs then set AVX=0)

DEBUG=0

ARCH= -gencode arch=compute_30,code=sm_30 \
      -gencode arch=compute_35,code=sm_35 \
      -gencode arch=compute_50,code=[sm_50,compute_50] \
      -gencode arch=compute_52,code=[sm_52,compute_52] \
      -gencode arch=compute_61,code=[sm_61,compute_61]

OS := $(shell uname)

# Tesla V100
# ARCH= -gencode arch=compute_70,code=[sm_70,compute_70]

# GeForce RTX 2080 Ti, RTX 2080, RTX 2070, Quadro RTX 8000, Quadro RTX 6000, Quadro RTX 5000, Tesla T4, XNOR Tensor Cores
# ARCH= -gencode arch=compute_75,code=[sm_75,compute_75]

# Jetson XAVIER
# ARCH= -gencode arch=compute_72,code=[sm_72,compute_72]

# GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, Titan Xp, Tesla P40, Tesla P4
# ARCH= -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61

# GP100/Tesla P100 - DGX-1
# ARCH= -gencode arch=compute_60,code=sm_60

# For Jetson TX1, Tegra X1, DRIVE CX, DRIVE PX - uncomment:
# ARCH= -gencode arch=compute_53,code=[sm_53,compute_53]

# For Jetson Tx2 or Drive-PX2 uncomment:
# ARCH= -gencode arch=compute_62,code=[sm_62,compute_62]


VPATH=./src/
EXEC=darknet
OBJDIR=./obj/

ifeq ($(LIBSO), 1)
LIBNAMESO=libdarknet.so
APPNAMESO=uselib
endif

CC=gcc
CPP=g++
NVCC=nvcc
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON= -Iinclude/ -I3rdparty/stb/include
CFLAGS=-Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -fPIC

ifeq ($(DEBUG), 1)
#OPTS= -O0 -g
#OPTS= -Og -g
COMMON+= -DDEBUG
CFLAGS+= -DDEBUG
else
ifeq ($(AVX), 1)
CFLAGS+= -ffp-contract=fast -mavx -mavx2 -msse3 -msse4.1 -msse4.2 -msse4a
endif
endif

CFLAGS+=$(OPTS)

ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv` -lIlmImf
COMMON+= `pkg-config --cflags opencv`
endif

ifeq ($(OPENMP), 1)
CFLAGS+= -fopenmp
LDFLAGS+= -lgomp
endif

ifeq ($(GPU), 1)
COMMON+= -DGPU -I/usr/local/cuda/include/
CFLAGS+= -DGPU
ifeq ($(OS),Darwin) #MAC
LDFLAGS+= -L/usr/local/cuda/lib -lcuda -lcudart -lcublas -lcurand
else
LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand
endif
endif

ifeq ($(CUDNN), 1)
COMMON+= -DCUDNN
ifeq ($(OS),Darwin) #MAC
CFLAGS+= -DCUDNN -I/usr/local/cuda/include
LDFLAGS+= -L/usr/local/cuda/lib -lcudnn
else
CFLAGS+= -DCUDNN -I/usr/local/cudnn/include
LDFLAGS+= -L/usr/local/cudnn/lib64 -lcudnn
endif
endif

ifeq ($(CUDNN_HALF), 1)
COMMON+= -DCUDNN_HALF
CFLAGS+= -DCUDNN_HALF
ARCH+= -gencode arch=compute_70,code=[sm_70,compute_70]
endif

ifeq ($(ZED_CAMERA), 1)
CFLAGS+= -DZED_STEREO -I/usr/local/zed/include
LDFLAGS+= -L/usr/local/zed/lib -lsl_core -lsl_input -lsl_zed
#-lstdc++ -D_GLIBCXX_USE_CXX11_ABI=0 
endif

OBJ=image_opencv.o http_stream.o gemm.o utils.o dark_cuda.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o captcha.o route_layer.o writing.o box.o nightmare.o normalization_layer.o avgpool_layer.o coco.o dice.o yolo.o detector.o layer.o compare.o classifier.o local_layer.o swag.o shortcut_layer.o activation_layer.o rnn_layer.o gru_layer.o rnn.o rnn_vid.o crnn_layer.o demo.o tag.o cifar.o go.o batchnorm_layer.o art.o region_layer.o reorg_layer.o reorg_old_layer.o super.o voxel.o tree.o yolo_layer.o upsample_layer.o lstm_layer.o conv_lstm_layer.o
ifeq ($(GPU), 1) 
LDFLAGS+= -lstdc++ 
OBJ+=convolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o network_kernels.o avgpool_layer_kernels.o
endif

OBJS = $(addprefix $(OBJDIR), $(OBJ))
DEPS = $(wildcard src/*.h) Makefile include/darknet.h

all: obj backup results setchmod $(EXEC) $(LIBNAMESO) $(APPNAMESO)

ifeq ($(LIBSO), 1)
CFLAGS+= -fPIC

$(LIBNAMESO): $(OBJS) include/yolo_v2_class.hpp src/yolo_v2_class.cpp
    $(CPP) -shared -std=c++11 -fvisibility=hidden -DLIB_EXPORTS $(COMMON) $(CFLAGS) $(OBJS) src/yolo_v2_class.cpp -o $@ $(LDFLAGS)

$(APPNAMESO): $(LIBNAMESO) include/yolo_v2_class.hpp src/yolo_console_dll.cpp
    $(CPP) -std=c++11 $(COMMON) $(CFLAGS) -o $@ src/yolo_console_dll.cpp $(LDFLAGS) -L ./ -l:$(LIBNAMESO)
endif

$(EXEC): $(OBJS)
    $(CPP) -std=c++11 $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS)

$(OBJDIR)%.o: %.c $(DEPS)
    $(CC) $(COMMON) $(CFLAGS) -c $< -o $@

$(OBJDIR)%.o: %.cpp $(DEPS)
    $(CPP) -std=c++11 $(COMMON) $(CFLAGS) -c $< -o $@

$(OBJDIR)%.o: %.cu $(DEPS)
    $(NVCC) $(ARCH) $(COMMON) --compiler-options "$(CFLAGS)" -c $< -o $@

obj:
    mkdir -p obj
backup:
    mkdir -p backup
results:
    mkdir -p results
setchmod:
    chmod +x *.sh

.PHONY: clean

clean:
    rm -rf $(OBJS) $(EXEC) $(LIBNAMESO) $(APPNAMESO)

Lib Imf_2_3 undefined references under Manjaro

I'm trying to compile darknet under Manjaro Linux but seems I have a libImf version mismatch.

gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -O0 -g -DOPENCV -DGPU -DCUDNN obj/captcha.o obj/lsd.o obj/super.o obj/art.o obj/tag.o obj/cifar.o obj/go.o obj/rnn.o obj/segmenter.o obj/regressor.o obj/classifier.o obj/coco.o obj/yolo.o obj/detector.o obj/nightmare.o obj/instance-segmenter.o obj/darknet.o libdarknet.a -o darknet -lm -pthread -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'  `pkg-config --libs opencv` -lstdc++ -lopencv_videoio  -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -lopencv_highgui -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -lcudnn -lstdc++  libdarknet.a
/usr/bin/ld: warning: libIlmImf-2_3.so.24, needed by /opt/opencv3/lib/libopencv_imgcodecs.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::InputFile(char const*, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::insert(char const*, Imf_2_3::Slice const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::channels()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::chromaticities(Imf_2_3::Header const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::OutputFile(char const*, Imf_2_3::Header const&, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::begin()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::Header(int, int, float, Imath_2_3::Vec2<float> const&, float, Imf_2_3::LineOrder, Imf_2_3::Compression)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Channel::Channel(Imf_2_3::PixelType, int, int, bool)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::channels() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::FrameBuffer::end()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::header() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::~Header()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::InputFile::readPixels(int, int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::globalThreadCount()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Header::dataWindow() const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::ChannelList::findChannel(char const*) const'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::~OutputFile()'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Slice::Slice(Imf_2_3::PixelType, char*, unsigned long, unsigned long, int, int, double, bool, bool)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::Chromaticities::Chromaticities(Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::OutputFile::writePixels(int)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::ChannelList::insert(char const*, Imf_2_3::Channel const&)'
/usr/bin/ld: /opt/opencv3/lib/libopencv_imgcodecs.so: undefined reference to `Imf_2_3::hasChromaticities(Imf_2_3::Header const&)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:77: darknet] Error 1

How can I fix it?

EDIT 1: Thanks @berak I did what you suggested and now I have new errors:

[ 51%] Linking CXX executable uselib
/usr/bin/ld: CMakeFiles/uselib.dir/src/yolo_console_dll.cpp.o: in function `draw_boxes(cv::Mat, std::vector<bbox_t, std::allocator<bbox_t> >, std::vector<std::string, std::allocator<std::string> >, int, int)':
yolo_console_dll.cpp:(.text+0x461): undefined reference to `cv::getTextSize(std::string const&, int, double, int, int*)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x633): undefined reference to `cv::getTextSize(std::string const&, int, double, int, int*)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x960): undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0xa8e): undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0xc76): undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)'
/usr/bin/ld: CMakeFiles/uselib.dir/src/yolo_console_dll.cpp.o: in function `main':
yolo_console_dll.cpp:(.text+0x2d05): undefined reference to `cv::VideoCapture::open(std::string const&, int)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x3493): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x358a): undefined reference to `cv::destroyWindow(std::string const&)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x384d): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x3971): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: yolo_console_dll.cpp:(.text+0x3bd0): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
/usr/bin/ld: libdark.so: undefined reference to `cv::namedWindow(std::string const&, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::moveWindow(std::string const&, int, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::setWindowProperty(std::string const&, int, double)'
/usr/bin/ld: libdark.so: undefined reference to `cv::VideoWriter::VideoWriter(std::string const&, int, double, cv::Size_<int>, bool)'
/usr/bin/ld: libdark.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::VideoCapture::VideoCapture(std::string const&, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::resizeWindow(std::string const&, int, int)'
/usr/bin/ld: libdark.so: undefined reference to `cv::imencode(std::string const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/uselib.dir/build.make:138: uselib] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/uselib.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
==> ERROR: Makepkg was unable to build darknet-alexeyab-git.
==> Restart building darknet-alexeyab-git ? [y/N]
==> ---------------------------------------------

yes I believe I'm linking here the makefile:

GPU=1
CUDNN=1
CUDNN_HALF=0
OPENCV=1
AVX=0
OPENMP=1
LIBSO=0
ZED_CAMERA=0

# set GPU=1 and CUDNN=1 to speedup on GPU
# set CUDNN_HALF=1 to further speedup 3 x times (Mixed-precision on Tensor Cores) GPU: Volta, Xavier, Turing and higher
# set AVX=1 and OPENMP=1 to speedup on CPU (if error occurs then set AVX=0)

DEBUG=0

ARCH= -gencode arch=compute_30,code=sm_30 \
      -gencode arch=compute_35,code=sm_35 \
      -gencode arch=compute_50,code=[sm_50,compute_50] \
      -gencode arch=compute_52,code=[sm_52,compute_52] \
      -gencode arch=compute_61,code=[sm_61,compute_61]

OS := $(shell uname)

# Tesla V100
# ARCH= -gencode arch=compute_70,code=[sm_70,compute_70]

# GeForce RTX 2080 Ti, RTX 2080, RTX 2070, Quadro RTX 8000, Quadro RTX 6000, Quadro RTX 5000, Tesla T4, XNOR Tensor Cores
# ARCH= -gencode arch=compute_75,code=[sm_75,compute_75]

# Jetson XAVIER
# ARCH= -gencode arch=compute_72,code=[sm_72,compute_72]

# GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, Titan Xp, Tesla P40, Tesla P4
# ARCH= -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61

# GP100/Tesla P100 - DGX-1
# ARCH= -gencode arch=compute_60,code=sm_60

# For Jetson TX1, Tegra X1, DRIVE CX, DRIVE PX - uncomment:
# ARCH= -gencode arch=compute_53,code=[sm_53,compute_53]

# For Jetson Tx2 or Drive-PX2 uncomment:
# ARCH= -gencode arch=compute_62,code=[sm_62,compute_62]


VPATH=./src/
EXEC=darknet
OBJDIR=./obj/

ifeq ($(LIBSO), 1)
LIBNAMESO=libdarknet.so
APPNAMESO=uselib
endif

CC=gcc
CPP=g++
NVCC=nvcc
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON= -Iinclude/ -I3rdparty/stb/include
CFLAGS=-Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -fPIC

ifeq ($(DEBUG), 1)
#OPTS= -O0 -g
#OPTS= -Og -g
COMMON+= -DDEBUG
CFLAGS+= -DDEBUG
else
ifeq ($(AVX), 1)
CFLAGS+= -ffp-contract=fast -mavx -mavx2 -msse3 -msse4.1 -msse4.2 -msse4a
endif
endif

CFLAGS+=$(OPTS)

ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV

LDFLAGS+= `pkg-config pkg-config --libs opencv` -lIlmImf opencv -lIlmImf -lopencv_core -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs

COMMON+= `pkg-config --cflags opencv`
endif

ifeq ($(OPENMP), 1)
CFLAGS+= -fopenmp
LDFLAGS+= -lgomp
endif

ifeq ($(GPU), 1)
COMMON+= -DGPU -I/usr/local/cuda/include/
CFLAGS+= -DGPU
ifeq ($(OS),Darwin) #MAC
LDFLAGS+= -L/usr/local/cuda/lib -lcuda -lcudart -lcublas -lcurand
else
LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand
endif
endif

ifeq ($(CUDNN), 1)
COMMON+= -DCUDNN
ifeq ($(OS),Darwin) #MAC
CFLAGS+= -DCUDNN -I/usr/local/cuda/include
LDFLAGS+= -L/usr/local/cuda/lib -lcudnn
else
CFLAGS+= -DCUDNN -I/usr/local/cudnn/include
LDFLAGS+= -L/usr/local/cudnn/lib64 -lcudnn
endif
endif

ifeq ($(CUDNN_HALF), 1)
COMMON+= -DCUDNN_HALF
CFLAGS+= -DCUDNN_HALF
ARCH+= -gencode arch=compute_70,code=[sm_70,compute_70]
endif

ifeq ($(ZED_CAMERA), 1)
CFLAGS+= -DZED_STEREO -I/usr/local/zed/include
LDFLAGS+= -L/usr/local/zed/lib -lsl_core -lsl_input -lsl_zed
#-lstdc++ -D_GLIBCXX_USE_CXX11_ABI=0 
endif

OBJ=image_opencv.o http_stream.o gemm.o utils.o dark_cuda.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o captcha.o route_layer.o writing.o box.o nightmare.o normalization_layer.o avgpool_layer.o coco.o dice.o yolo.o detector.o layer.o compare.o classifier.o local_layer.o swag.o shortcut_layer.o activation_layer.o rnn_layer.o gru_layer.o rnn.o rnn_vid.o crnn_layer.o demo.o tag.o cifar.o go.o batchnorm_layer.o art.o region_layer.o reorg_layer.o reorg_old_layer.o super.o voxel.o tree.o yolo_layer.o upsample_layer.o lstm_layer.o conv_lstm_layer.o
ifeq ($(GPU), 1) 
LDFLAGS+= -lstdc++ 
OBJ+=convolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o network_kernels.o avgpool_layer_kernels.o
endif

OBJS = $(addprefix $(OBJDIR), $(OBJ))
DEPS = $(wildcard src/*.h) Makefile include/darknet.h

all: obj backup results setchmod $(EXEC) $(LIBNAMESO) $(APPNAMESO)

ifeq ($(LIBSO), 1)
CFLAGS+= -fPIC

$(LIBNAMESO): $(OBJS) include/yolo_v2_class.hpp src/yolo_v2_class.cpp
    $(CPP) -shared -std=c++11 -fvisibility=hidden -DLIB_EXPORTS $(COMMON) $(CFLAGS) $(OBJS) src/yolo_v2_class.cpp -o $@ $(LDFLAGS)

$(APPNAMESO): $(LIBNAMESO) include/yolo_v2_class.hpp src/yolo_console_dll.cpp
    $(CPP) -std=c++11 $(COMMON) $(CFLAGS) -o $@ src/yolo_console_dll.cpp $(LDFLAGS) -L ./ -l:$(LIBNAMESO)
endif

$(EXEC): $(OBJS)
    $(CPP) -std=c++11 $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS)

$(OBJDIR)%.o: %.c $(DEPS)
    $(CC) $(COMMON) $(CFLAGS) -c $< -o $@

$(OBJDIR)%.o: %.cpp $(DEPS)
    $(CPP) -std=c++11 $(COMMON) $(CFLAGS) -c $< -o $@

$(OBJDIR)%.o: %.cu $(DEPS)
    $(NVCC) $(ARCH) $(COMMON) --compiler-options "$(CFLAGS)" -c $< -o $@

obj:
    mkdir -p obj
backup:
    mkdir -p backup
results:
    mkdir -p results
setchmod:
    chmod +x *.sh

.PHONY: clean

clean:
    rm -rf $(OBJS) $(EXEC) $(LIBNAMESO) $(APPNAMESO)