Ask Your Question
0

Build Static openCV 4 lib in MacOS

asked 2019-03-08 08:15:46 -0600

DatTT gravatar image

updated 2019-03-08 13:47:38 -0600

berak gravatar image

Hi all,

Following the guideline https://www.learnopencv.com/install-o..., In MacOS Mojave, I have successfully built C++ OpenCV4 dynamic libs from github source. I tried to run a simple program (which is shown below) and it worked well

#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
int main(void)
{
  std::cout << cv::getBuildInformation() << std::endl;
}

Then, I tried to build C++ static lib and it was successful too (I turn off CMAKE option BUILD_SHARED_LIBS). However, when I run the same code above, I got the following errors. Could somebody please help me? I would like to use static libs rather than dynamic libs.

Undefined symbols for architecture x86_64: "___itt_api_version_ptr__3_0", referenced from: cv::utils::trace::details::Region::LocationExtraData::LocationExtraData(cv::utils::trace::details::Region::LocationStaticStorage const&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::LocationExtraData::LocationExtraData(cv::utils::trace::details::Region::LocationStaticStorage const&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::LocationExtraData::init(cv::utils::trace::details::Region::LocationStaticStorage const&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl::Impl(cv::utils::trace::details::TraceManagerThreadLocal&, cv::utils::trace::details::Region, cv::utils::trace::details::Region&, cv::utils::trace::details::Region::LocationStaticStorage const&, long long) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl::registerRegion(cv::utils::trace::details::TraceManagerThreadLocal&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl::enterRegion(cv::utils::trace::details::TraceManagerThreadLocal&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl::leaveRegion(cv::utils::trace::details::TraceManagerThreadLocal&) in libopencv_core.a(trace.cpp.o) ... "___itt_domain_create_ptr__3_0", referenced from: cv::utils::trace::details::Region::LocationExtraData::LocationExtraData(cv::utils::trace::details::Region::LocationStaticStorage const&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::LocationExtraData::LocationExtraData(cv::utils::trace::details::Region::LocationStaticStorage const&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::LocationExtraData::init(cv::utils::trace::details::Region::LocationStaticStorage const&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl::Impl(cv::utils::trace::details::TraceManagerThreadLocal&, cv::utils::trace::details::Region, cv::utils::trace::details::Region&, cv::utils::trace::details::Region::LocationStaticStorage const&, long long) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl::registerRegion(cv::utils::trace::details::TraceManagerThreadLocal&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl::enterRegion(cv::utils::trace::details::TraceManagerThreadLocal&) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl::leaveRegion(cv::utils::trace::details::TraceManagerThreadLocal&) in libopencv_core.a(trace.cpp.o) ... "___itt_id_create_ptr__3_0", referenced from: cv::utils::trace::details::Region::Impl::Impl(cv::utils::trace::details::TraceManagerThreadLocal&, cv::utils::trace::details::Region, cv::utils::trace::details::Region&, cv::utils::trace::details::Region::LocationStaticStorage const&, long long) in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl::registerRegion(cv::utils::trace::details::TraceManagerThreadLocal&) in libopencv_core.a(trace.cpp.o) "___itt_id_destroy_ptr__3_0", referenced from: cv::utils::trace::details::Region::Impl::~Impl() in libopencv_core.a(trace.cpp.o) cv::utils::trace::details::Region::Impl ... (more)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-04-02 07:37:07 -0600

Since you are compiling the code with static libraries, you need to link all necessary libraries in you command. According to the error message, you are missing itt library, normally, it should be in ./build/share/OpenCV/3rdparty/lib with name libittnotify.a

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-03-08 08:15:46 -0600

Seen: 2,415 times

Last updated: Mar 08 '19