facebookresearch / ocean

Ocean is the in-house framework for Computer Vision (CV) and Augmented Reality (AR) applications at Meta. It is platform independent and is mainly implemented in C/C++.
https://facebookresearch.github.io/ocean/
MIT License
642 stars 58 forks source link

Compilation error (undefined symbols) when linking on iOS #37

Closed pzoltowski closed 2 months ago

pzoltowski commented 2 months ago

Instructions to reproduce the problem:

  1. The code or full code changes that exhibit the problem:

I followed building instructions and tested on included demo apps. The only app I'm able to compile and deploy is application_ocean_demo_base_console_ios. test targets also works. However all targets with gui having the same undefined symbols compilation error. Testing environment:

iphone 13 mini, iOS 17.4.1 macos sonoma 14.6.1 (macbook pro m2 max) xcode 15.4

tested on both ocean 1.0.0 and 1.0.1

cmake version 3.30.3

  1. Full logs or other relevant observations:
application_ocean_demo_tracking_pointtracker_ios
Undefined symbol: _hb_blob_create

Undefined symbol: _hb_blob_destroy

Undefined symbol: _hb_buffer_add_utf8

Undefined symbol: _hb_buffer_clear_contents

Undefined symbol: _hb_buffer_create

Undefined symbol: _hb_buffer_destroy

Undefined symbol: _hb_buffer_get_glyph_infos

Undefined symbol: _hb_buffer_get_glyph_positions

Undefined symbol: _hb_buffer_get_length

Undefined symbol: _hb_buffer_guess_segment_properties

Undefined symbol: _hb_face_create

Undefined symbol: _hb_face_create_for_tables

Undefined symbol: _hb_face_destroy

Undefined symbol: _hb_face_set_index

Undefined symbol: _hb_face_set_upem

Undefined symbol: _hb_font_create

Undefined symbol: _hb_font_destroy

Undefined symbol: _hb_font_get_face

Undefined symbol: _hb_font_set_scale

Undefined symbol: _hb_ot_layout_collect_lookups

Undefined symbol: _hb_ot_layout_lookup_collect_glyphs

Undefined symbol: _hb_ot_layout_lookup_would_substitute

Undefined symbol: _hb_ot_tags_from_script_and_language

Undefined symbol: _hb_set_create

Undefined symbol: _hb_set_destroy

Undefined symbol: _hb_set_is_empty

Undefined symbol: _hb_set_next

Undefined symbol: _hb_set_subtract

Undefined symbol: _hb_shape

Linker command failed with exit code 1 (use -v to see invocation)
enpe commented 2 months ago

Looks like it can't find the library of harfbuzz. I would suggest to verify the following:

  1. make sure to build and install all required third-party libs, cf. https://github.com/facebookresearch/ocean/blob/main/building_for_ios.md#2-building-the-third-party-libraries
  2. make sure the CMake is using the right paths to those libraries.
leapally commented 2 months ago

Hi, @pzoltowski.

Are you still having this issue?

I have been unable to repro this.

I believe there was a change back in July that removed dependency on Harfbuzz.

Is it possible that build artifacts left over from a build initiated on a commit from before that removal is causing issues? Was clean build also failing?

pzoltowski commented 2 months ago

I didn't retry but will have a look at it again tomorrow (together with compiling on MacOS for comparison) and will report back if still having issue

enpe commented 2 months ago

Closing for now. Please re-open if the problem persists.

pzoltowski commented 2 months ago

I tried again, cloned master, switched to v1.0.1 tag, followed build for iOS doc (without changing even build path) and this time having build error when trying to build demo iOS projects:

CMake Error at /opt/homebrew/Cellar/cmake/3.30.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find Freetype (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.30.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /opt/homebrew/Cellar/cmake/3.30.3/share/cmake/Modules/FindFreetype.cmake:165 (find_package_handle_standard_args)
  impl/ocean/cv/fonts/CMakeLists.txt:12 (find_package)

It seems for some reason build trying to pick freetype lib from my homebrew. Noticed also harfbuzz is a dependency of harfbuzz. Attaching logs from from both build scripts (for both build_thirdparty_ios and build_ocean_ios_release).

One CAVEAT - this time I'm using latest Xcode 16.0 RC released 2 days ago.

log_build_ocean_ios_release.txt log_build_thirdparty_ios.txt

enpe commented 2 months ago

Thanks for sharing the logs. From glimpsing over them, one thing that I noticed is that the installation directory for the third-party libs in log_build_thirdparty_ios.txt is

-i "${HOME}/install_ocean_thirdparty"

while the path specified in log_build_ocean_ios_release.txt is

-DCMAKE_INSTALL_PREFIX="${OCEAN_DEVELOPMENT_PATH}/install_ocean_thirdparty/ios_OS64_static_Release" \

Can you double-check your paths and retry to generate the XCode project?

t3h32eKK commented 2 months ago

I also have the same problem when I try to build for ios.

application_ocean_shark_ios
Undefined symbol: _hb_blob_create

Undefined symbol: _hb_blob_destroy

Undefined symbol: _hb_buffer_add_utf8

Undefined symbol: _hb_buffer_clear_contents

Undefined symbol: _hb_buffer_create

Undefined symbol: _hb_buffer_destroy

Undefined symbol: _hb_buffer_get_glyph_infos

Undefined symbol: _hb_buffer_get_glyph_positions

Undefined symbol: _hb_buffer_get_length

Undefined symbol: _hb_buffer_guess_segment_properties

Undefined symbol: _hb_face_create

Undefined symbol: _hb_face_create_for_tables

Undefined symbol: _hb_face_destroy

Undefined symbol: _hb_face_set_index

Undefined symbol: _hb_face_set_upem

Undefined symbol: _hb_font_create

Undefined symbol: _hb_font_destroy

Undefined symbol: _hb_font_get_face

Undefined symbol: _hb_font_set_scale

Undefined symbol: _hb_ot_layout_collect_lookups

Undefined symbol: _hb_ot_layout_lookup_collect_glyphs

Undefined symbol: _hb_ot_layout_lookup_would_substitute

Undefined symbol: _hb_ot_tags_from_script_and_language

Undefined symbol: _hb_set_create

Undefined symbol: _hb_set_destroy

Undefined symbol: _hb_set_is_empty

Undefined symbol: _hb_set_next

Undefined symbol: _hb_set_subtract

Undefined symbol: _hb_shape

Linker command failed with exit code 1 (use -v to see invocation)
pzoltowski commented 2 months ago

Thanks, I deleted the build and this time managed to generate xcode project but again same underfined symbol errors in xcode as in the beginning I had and exactly same as @t3h32eKK . Attaching new log:

log_build_ocean_ios_release2.txt

ASchneiderMeta commented 2 months ago

We're testing a patch now to disable depending on harfbuzz at all. Assuming it all works out, we can commit later today.

ASchneiderMeta commented 2 months ago

If you like, you can try adding 'set(FT_DISABLE_HARFBUZZ TRUE)' among the other set() calls in build/cmake/third-party/freetype.cmake. But please do make sure, as mentioned above, that the third-party install path is consistent between third-party build and ocean build.

pzoltowski commented 2 months ago

Tested only few demos so far but can confirm that changing:

set(FT_REQUIRE_HARFBUZZ FALSE) to set(FT_DISABLE_HARFBUZZ TRUE)

and rebuilding everything

seems to resolved the issue. Thanks!