openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.98k stars 2.55k forks source link

[macOS / osx] lib path problems with ofxOpenCv and ofxKinect(libusb) [buildAllExamples] #8170

Open artificiel opened 2 weeks ago

artificiel commented 2 weeks ago

had to swap macos to osx in the libs of these addons to get through buildAllExamples.sh.

with the macos transition not sure what is correct/incorrect in this case (other that it should compile!)

using fresh from git, scripts/osx/download_libs.sh and PG from last week to multi-update the examples files.

NB: Makefiles do compile.

danoli3 commented 2 weeks ago

projectGenerator not adding the xcframeworks again in last few versions.

For now just add the opencv.xcframework and it will work instantly, no headers needed.

image image image
dimitre commented 2 weeks ago

@roymacdonald is this working in your branch? if not I can take a look at PG

roymacdonald commented 2 weeks ago

@roymacdonald is this working in your branch? if not I can take a look at PG it is solved.

eloimaduell commented 1 week ago

hi @danoli3, I'm trying to run the OpenCV examples from the of_v20241109_osx_release nightlybuild. I just added as you mentioned the opencv.xcframework and it keeps poping an error at linking stage : Screenshot 2024-11-13 at 17 43 49

ld: Undefined symbols: carotene_o4t::bitwiseAnd(carotene_o4t::Size2D const&, unsigned char const, long, unsigned char const, long, unsigned char, long), referenced from: cv::hal::and8u(unsigned char const, unsigned long, unsigned char const, unsigned long, unsigned char, unsigned long, int, int, void*) in opencv.a[arm64]494 and some hundreds more like this ...

Screenshot 2024-11-13 at 17 42 33

In my case the error is : ld Undefined Symbols. What I'm doing wrong ?

( I'm on a M2 MacbookPro with MacOS Sonoma 14.5 and XCode 15.2. )

roymacdonald commented 1 week ago

Hi @eloimaduell which version of project generator do you have? I am not sure which one is being packaged but this is solved with the newest version of it

roymacdonald commented 1 week ago

I just checked it and it works with the newest PG versions > 0.78.0 (you can check this by clicking the cog icon on the top right of PG). ALthough, there is a mistake in the code itself, in the peopleDetector.h file you need to remove the line that says #include <opencv2/videoio.hpp>

danoli3 commented 1 week ago

hi @danoli3, I'm trying to run the OpenCV examples from the of_v20241109_osx_release nightlybuild. I just added as you mentioned the opencv.xcframework and it keeps poping an error at linking stage : Screenshot 2024-11-13 at 17 43 49

ld: Undefined symbols: carotene_o4t::bitwiseAnd(carotene_o4t::Size2D const&, unsigned char const, long, unsigned char const, long, unsigned char, long), referenced from: cv::hal::and8u(unsigned char const, unsigned long, unsigned char const, unsigned long, unsigned char, unsigned long, int, int, void*) in opencv.a[arm64]494 and some hundreds more like this ...

Screenshot 2024-11-13 at 17 42 33

In my case the error is : ld Undefined Symbols. What I'm doing wrong ?

( I'm on a M2 MacbookPro with MacOS Sonoma 14.5 and XCode 15.2. )

Yeah I think in the build commands the NEON/Instrinics were turned off, so it shouldn't have been trying to use those, maybe config is overridden by x86_64 with custom headers included.

I wonder if you remove the manually added headers and leave just the XCFrameworks (with sub headers) if that works.

Let's test with it on again, I'll see if it builds, better the have these optimisations for performance anyway

-DCV_ENABLE_INTRINSICS=ON -DWITH_CAROTENE=ON

ofTheo commented 3 days ago

@roymacdonald - I just tried the packaged nightly which is using projectGenerator 0.83.0 and I am still seeing the issue:


ld: Undefined symbols:
  cv::cvarrToMat(void const*, bool, bool, int, cv::AutoBuffer<double, 136ul>*), referenced from:
      ofxCvImage::getCvMat() in ofxCvColorImage.o
      ofxCvImage::getCvMat() const in ofxCvColorImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
  cv::Mat::~Mat(), referenced from:
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
      ...
  cv::error(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const*, char const*, int), referenced from:
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
  cv::noArray(), referenced from:
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
  cv::undistort(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&), referenced from:
      ofxCvImage::undistort(float, float, float, float, float, float, float, float) in ofxCvImage.o
  _cvAbsDiff, referenced from:
      ofxCvGrayscaleImage::absDiff(ofxCvGrayscaleImage&) in ofxCvGrayscaleImage.o
      ofxCvGrayscaleImage::absDiff(ofxCvGrayscaleImage&, ofxCvGrayscaleImage&) in ofxCvGrayscaleImage.o
  _cvAdaptiveThreshold, referenced from:
      ofxCvGrayscaleImage::adaptiveThreshold(int, int, bool, bool) in ofxCvGrayscaleImage.o
  _cvAdd, referenced from:
      ofxCvImage::operator+=(ofxCvImage&) in ofxCvImage.o
  _cvAddS, referenced from:
ofTheo commented 3 days ago

@danoli3 if I drag the opencv.xcframework into the allAddonsExamples project I get:

ld: Undefined symbols:
  carotene_o4t::bitwiseAnd(carotene_o4t::Size2D const&, unsigned char const*, long, unsigned char const*, long, unsigned char*, long), referenced from:
      cv::hal::and8u(unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, void*) in opencv.a[arm64][494](arithm.dispatch.cpp.o)
  carotene_o4t::bitwiseNot(carotene_o4t::Size2D const&, unsigned char const*, long, unsigned char*, long), referenced from:
      cv::hal::not8u(unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, void*) in opencv.a[arm64][494](arithm.dispatch.cpp.o)
  carotene_o4t::bitwiseXor(carotene_o4t::Size2D const&, unsigned char const*, long, unsigned char const*, long, unsigned char*, long), referenced from:
      cv::hal::xor8u(unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, void*) in opencv.a[arm64][494](arithm.dispatch.cpp.o)
  carotene_o4t::reciprocal(carotene_o4t::Size2D const&, signed char const*, long, signed char*, long, float, carotene_o4t::CONVERT_POLICY), referenced from:
      cv::hal::recip8s(signed char const*, unsigned long, signed char const*, unsigned long, signed char*, unsigned long, int, int, void*) in opencv.a[arm64][494](arithm.dispatch.cpp.o)
  carotene_o4t::reciprocal(carotene_o4t::Size2D const&, float const*, long, float*, long, float), referenced from:
      cv::hal::recip32f(float const*, unsigned long, float const*, unsigned long, float*, unsigned long, int, int, void*) in opencv.a[arm64][494](arithm.dispatch.cpp.o)
  carotene_o4t::reciprocal(carotene_o4t::Size2D const&, unsigned char const*, long, unsigned char*, long, float, carotene_o4t::CONVERT_POLICY), referenced from:
      cv::hal::recip8u(unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, void*) in opencv.a[arm64][494](arithm.dispatch.cpp.o)
  carotene_o4t::reciprocal(carotene_o4t::Size2D const&, int const*, long, int*, long, float, carotene_o4t::CONVERT_POLICY), referenced from:
      cv::hal::recip32s(int const*, unsigned long, int const*, unsigned long, int*, unsigned long, int, int, void*) in opencv.a[arm64][494](arithm.dispatch.cpp.o)
  carotene_o4t::reciprocal(carotene_o4t::Size2D const&, short const*, long, short*, long, float, carotene_o4t::CONVERT_POLICY), referenced from:
      cv::hal::recip16s(short const*, unsigned long, short const*, unsigned long, short*, unsigned long, int, int, void*) in opencv.a[arm64][494](arithm.dispatch.cpp.o)
  carotene_o4t::reciprocal(carotene_o4t::Size2D const&, unsigned short const*, long, unsigned short*, long, float, carotene_o4t::CONVERT_POLICY), referenced from:
      cv::hal::recip16u(unsigned short const*, unsigned long, unsigned short const*, unsigned long, unsigned short*, unsigned long, int, int, void*) in opencv.a[arm64][494](arithm.dispatch.cpp.o)
  carotene_o4t::rgb2bgr565(carotene_o4t::Size2D const&, unsigned char const*, long, unsigned char*, long), referenced from:
      TegraCvtColor_rgb2bgr565_Invoker::operator()(cv::Range const&) const in opencv.a[arm64][1182](color_rgb.dispatch.cpp.o)
  carotene_o4t::rgb2rgb565(carotene_o4t::Size2D const&, unsigned char const*, long, unsigned char*, long), referenced from:
      TegraCvtColor_rgb2rgb565_Invoker::operator()(cv::Range const&) const in opencv.a[arm64][1182](color_rgb.dispatch.cpp.o)
  carotene_o4t::addWeighted(carotene_o4t::Size2D const&, signed char const*, long, signed char const*, long, signed char*, long, float, float, float), referenced from:
      cv::

Looks like it might need to be built with: "WITH_CAROTENE": "OFF".

eloimaduell commented 2 days ago

@roymacdonald :: > Hi @eloimaduell which version of project generator do you have? I am not sure which one is being packaged but this is solved with the newest version of it

I'm using Project Generator 0.84.0

eloimaduell commented 2 days ago

@roymacdonald :: > I just checked it and it works with the newest PG versions > 0.78.0 (you can check this by clicking the cog icon on the top right of PG). ALthough, there is a mistake in the code itself, in the peopleDetector.h file you need to remove the line that says #include <opencv2/videoio.hpp>

Thanks for pointing this out ! Anyway the linking issue happened with any OfxOpenCV example. I solved with a weird that I don't understand which was createing a folder names /opencv/include/opencv4 with folder opencv2 inside. It doesn't make any sense to me, but it worked like this .... ?¿

Screenshot 2024-11-19 at 08 26 16

roymacdonald commented 2 days ago

@eloimaduell It kinda makes sense, but it is strange that it is not already there.