luxonis / depthai-unity

DepthAI Unity Library, Unity projects and examples (OAK For Unity)
MIT License
200 stars 34 forks source link

How can I build this project within or without depthai-core? #46

Closed personball closed 10 months ago

personball commented 10 months ago

build Fail

reproduce:

git clone  https://github.com/luxonis/depthai-unity.git
cd depthai-unity
git submodule update --init --recursive
cmake -G"Visual Studio 17 2022" -S. -Bbuild -D'BUILD_SHARED_LIBS=ON'  -DHUNTER_STATUS_DEBUG=ON -DHUNTER_TLS_VERIFY=OFF

output

-- [hunter *** DEBUG *** 2024-01-15T17:25:15] nlohmann_json versions available: [2.1.1-p0;2.1.1-p1;3.0.0;3.0.1;3.1.0;3.1.1;3.1.2;3.2.0;3.3.0;3.4.0;3.5.0;3.6.0;3.6.1;3.7.0;3.7.1;3.7.2;3.7.3;3.8.0]
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Package 'nlohmann_json' CONFIGURATION_TYPES: Release;Debug
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Package 'nlohmann_json' is cacheable: YES
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Install to: C:/.hunter/_Base/cb0ea1f/eb87dbf/900ca43/Install
-- [hunter] NLOHMANN_JSON_ROOT: C:/.hunter/_Base/cb0ea1f/eb87dbf/900ca43/Install (ver.: 3.9.1)
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Locking directory: C:/.hunter/_Base/cb0ea1f/eb87dbf/900ca43
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Lock done
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Already locked: C:/.hunter/_Base/cb0ea1f/eb87dbf/900ca43
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Locking directory: C:/.hunter/_Base/Download/nlohmann_json/3.9.1/f8a20a7
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Lock done
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Package 'nlohmann_json' default arguments: 'JSON_BuildTests=OFF'
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Add extra CMake args: 'JSON_BuildTests' = 'OFF'
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Locking directory: C:/.hunter/_Base/Cache
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Lock done
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Using environment variable USERPROFILE
-- [hunter *** DEBUG *** 2024-01-15T17:25:15] Downloading DONE metafile (try #0 of 10):
-- [hunter *** DEBUG *** 2024-01-15T17:25:15]   https://raw.githubusercontent.com/cpp-pm/hunter-cache/master/eb87dbf/nlohmann_json/3.9.1/f8a20a7/151cbba/4830b34/da39a3e/basic-deps.DONE
-- [hunter *** DEBUG *** 2024-01-15T17:25:15]   -> C:/.hunter/_Base/Cache/meta/eb87dbf/nlohmann_json/3.9.1/f8a20a7/151cbba/4830b34/da39a3e/basic-deps.DONE
-- [hunter *** DEBUG *** 2024-01-15T17:25:17] Download error ("Couldn't connect to server")
-- [hunter *** DEBUG *** 2024-01-15T17:25:17] Downloading DONE metafile (try #1 of 10):
-- [hunter *** DEBUG *** 2024-01-15T17:25:17]   https://raw.githubusercontent.com/cpp-pm/hunter-cache/master/eb87dbf/nlohmann_json/3.9.1/f8a20a7/151cbba/4830b34/da39a3e/basic-deps.DONE
-- [hunter *** DEBUG *** 2024-01-15T17:25:17]   -> C:/.hunter/_Base/Cache/meta/eb87dbf/nlohmann_json/3.9.1/f8a20a7/151cbba/4830b34/da39a3e/basic-deps.DONE
-- [hunter *** DEBUG *** 2024-01-15T17:25:19] Download error ("Couldn't connect to server")
-- [hunter *** DEBUG *** 2024-01-15T17:25:19] Downloading DONE metafile (try #2 of 10):
-- [hunter *** DEBUG *** 2024-01-15T17:25:19]   https://raw.githubusercontent.com/cpp-pm/hunter-cache/master/eb87dbf/nlohmann_json/3.9.1/f8a20a7/151cbba/4830b34/da39a3e/basic-deps.DONE
-- [hunter *** DEBUG *** 2024-01-15T17:25:19]   -> C:/.hunter/_Base/Cache/meta/eb87dbf/nlohmann_json/3.9.1/f8a20a7/151cbba/4830b34/da39a3e/basic-deps.DONE
-- [hunter *** DEBUG *** 2024-01-15T17:25:19] Retry after 5 seconds (attempt #2) ...
-- [hunter *** DEBUG *** 2024-01-15T17:25:27] Download error ("Couldn't connect to server")
-- [hunter *** DEBUG *** 2024-01-15T17:25:27] Downloading DONE metafile (try #3 of 10):
-- [hunter *** DEBUG *** 2024-01-15T17:25:27]   https://raw.githubusercontent.com/cpp-pm/hunter-cache/master/eb87dbf/nlohmann_json/3.9.1/f8a20a7/151cbba/4830b34/da39a3e/basic-deps.DONE
-- [hunter *** DEBUG *** 2024-01-15T17:25:27]   -> C:/.hunter/_Base/Cache/meta/eb87dbf/nlohmann_json/3.9.1/f8a20a7/151cbba/4830b34/da39a3e/basic-deps.DONE
-- [hunter *** DEBUG *** 2024-01-15T17:25:27] Retry after 5 seconds (attempt #3) ...

from first line, I see nlohmann_json 3.9.1 is not available in this Hunter Gate:

-- [hunter *** DEBUG *** 2024-01-15T17:25:15] nlohmann_json versions available: [2.1.1-p0;2.1.1-p1;3.0.0;3.0.1;3.1.0;3.1.1;3.1.2;3.2.0;3.3.0;3.4.0;3.5.0;3.6.0;3.6.1;3.7.0;3.7.1;3.7.2;3.7.3;3.8.0]

if I Update the version of nlohmann_json in depthai-core\cmake\Hunter\config.cmake with

hunter_config(
    nlohmann_json
    VERSION "3.8.0"
    URL "https://github.com/nlohmann/json/archive/v3.8.0.tar.gz"
    SHA1 "70a16819777672d3771a2754eccee95e4249b3b4"
)

build again, get this:

CMake Deprecation Warning at C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_lock_directory.cmake:4 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_make_directory.cmake:7 (include)
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_save_to_cache.cmake:8 (include)
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_download.cmake:26 (include)
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/projects/nlohmann_json/hunter.cmake:6 (include)
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_add_package.cmake:62 (include)
  depthai-core/cmake/depthaiDependencies.cmake:11 (hunter_add_package)
  depthai-core/CMakeLists.txt:167 (include)

[hunter ** FATAL ERROR **] 3.8.0 already used in 'hunter.cmake'.
[hunter ** FATAL ERROR **]  Please specify another version in hunter_config(nlohmann_json).
[hunter ** FATAL ERROR **] [Directory:C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/projects/nlohmann_json]

------------------------------ ERROR -----------------------------
    https://hunter.readthedocs.io/en/latest/reference/errors/error.incorrect.input.data.html
------------------------------------------------------------------

CMake Error at C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_error_page.cmake:12 (message):
Call Stack (most recent call first):
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_fatal_error.cmake:20 (hunter_error_page)
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_user_error.cmake:7 (hunter_fatal_error)
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_add_version.cmake:58 (hunter_user_error)
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/projects/nlohmann_json/hunter.cmake:151 (hunter_add_version)
  C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_add_package.cmake:62 (include)
  depthai-core/cmake/depthaiDependencies.cmake:11 (hunter_add_package)
  depthai-core/CMakeLists.txt:167 (include)

-- Configuring incomplete, errors occurred!

change any version for nlohmann_json will not Fix This.

[hunter ** FATAL ERROR **] 3.8.0 already used in 'hunter.cmake'.
[hunter ** FATAL ERROR **]  Please specify another version in hunter_config(nlohmann_json).
[hunter ** FATAL ERROR **] [Directory:C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/projects/nlohmann_json]

Please Help me.

personball commented 10 months ago

Or how to build depthai-unity without the source code of depthai-core, just reference the Releases of depthai-core ?

gespona commented 10 months ago

Hi @personball

Just tried with fresh clone following these steps and I was able to compile without any issue. Could you give a try?

git clone https://github.com/luxonis/depthai-unity.git cd depthai-unity/ git submodule update --init --recursive cmake -S. -BbuildW1 -D'BUILD_SHARED_LIBS=ON' cmake --build buildW1 --config Release --parallel 12

it was building with (-- Building for: Visual Studio 17 2022)

personball commented 10 months ago

Hi @gespona , Thank you for your reply.

When I follow your instructions to run cmake -S. -BbuildW1 -D'BUILD_SHARED_LIBS=ON' , I got this:

PS personball> cmake -S. -BbuildW1 -D'BUILD_SHARED_LIBS=ON'
-- Building for: Visual Studio 17 2022
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

CMake Deprecation Warning at depthai-core/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Generating new toolchain...
-- Using toolchain file: C:/Users/perso/source/repos/depthai-unity/buildW1/depthai-core/generated/toolchain.cmake
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.28/Modules/ExternalProject.cmake:3198 (message):
  The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
  not set.  The policy's OLD behavior will be used.  When using a URL
  download, the timestamps of extracted files should preferably be that of
  the time of extraction, otherwise code that depends on the extracted
  contents might not be rebuilt if the URL changes.  The OLD behavior
  preserves the timestamps from the archive instead, but this is usually not
  what you want.  Update your project to the NEW behavior or specify the
  DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
  robustness issue.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.28/Modules/ExternalProject.cmake:4422 (_ep_add_download_command)
  CMakeLists.txt:4 (ExternalProject_Add)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- [hunter] Initializing Hunter workspace (cb0ea1f74f4a2c49a807de34885743495fccccbe)
-- [hunter]   https://github.com/cpp-pm/hunter/archive/v0.23.322.tar.gz
-- [hunter]   -> C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f

[hunter ** INTERNAL **] Build project failed
[hunter ** INTERNAL **] [Directory:C:/Users/perso/source/repos/depthai-unity/depthai-core]

------------------------------ ERROR ------------------------------
    https://docs.hunter.sh/en/latest/reference/errors/error.internal.html
-------------------------------------------------------------------

CMake Error at depthai-core/cmake/HunterGate.cmake:87 (message):
Call Stack (most recent call first):
  depthai-core/cmake/HunterGate.cmake:97 (hunter_gate_error_page)
  depthai-core/cmake/HunterGate.cmake:345 (hunter_gate_internal_error)
  depthai-core/cmake/HunterGate.cmake:509 (hunter_gate_download)
  depthai-core/CMakeLists.txt:34 (HunterGate)

-- Configuring incomplete, errors occurred!

And I try it with hunter trace options -DHUNTER_STATUS_DEBUG=ON -DHUNTER_TLS_VERIFY=OFF, Then:

-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Build
-- [hunter] Initializing Hunter workspace (cb0ea1f74f4a2c49a807de34885743495fccccbe)
-- [hunter]   https://github.com/cpp-pm/hunter/archive/v0.23.322.tar.gz
-- [hunter]   -> C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f
适用于 .NET Framework MSBuild 版本 17.8.3+195e7f5a3

  1>Checking Build System
  Creating directories for 'Hunter'
  Building Custom Rule C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/CMakeLists.txt
  Performing download step (download, verify and extract) for 'Hunter'
  -- verifying file...
         file='C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/v0.23.322.tar.gz'
  -- SHA1 hash of
      C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/v0.23.322.tar.gz
    does not match expected value
      expected: 'cb0ea1f74f4a2c49a807de34885743495fccccbe'
        actual: 'da39a3ee5e6b4b0d3255bfef95601890afd80709'
  -- File already exists but hash mismatch. Removing...
  -- Downloading...
     dst='C:/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/v0.23.322.tar.gz'
     timeout='none'
     inactivity timeout='none'
  -- Using src='https://github.com/cpp-pm/hunter/archive/v0.23.322.tar.gz'
  -- Retrying...
  -- Using src='https://github.com/cpp-pm/hunter/archive/v0.23.322.tar.gz'
  -- Retry after 5 seconds (attempt #2) ...
  -- Using src='https://github.com/cpp-pm/hunter/archive/v0.23.322.tar.gz'
  -- Retry after 5 seconds (attempt #3) ...
  -- Using src='https://github.com/cpp-pm/hunter/archive/v0.23.322.tar.gz'
  -- Retry after 15 seconds (attempt #4) ...
  -- Using src='https://github.com/cpp-pm/hunter/archive/v0.23.322.tar.gz'

Append: After I update the SHA1 hash in HunterGate(...), and setup the http proxy(for jump over GFW):

...
  No update step for 'Hunter'
  No patch step for 'Hunter'
  No configure step for 'Hunter'
  No build step for 'Hunter'
  No install step for 'Hunter'
  Completed 'Hunter'
  Building Custom Rule C:/.hunter/_Base/Download/Hunter/0.23.322/da39a3e/CMakeLists.txt
-- [hunter *** DEBUG *** 2024-01-22T00:37:56] Finished

[hunter ** FATAL ERROR **] Master file not found:
[hunter ** FATAL ERROR **]   C:/.hunter/_Base/Download/Hunter/0.23.322/da39a3e/Unpacked/cmake/Hunter
[hunter ** FATAL ERROR **] try to update Hunter/HunterGate
[hunter ** FATAL ERROR **] [Directory:C:/Users/perso/source/repos/depthai-unity/depthai-core]

------------------------------ ERROR ------------------------------
    https://docs.hunter.sh/en/latest/reference/errors/error.incorrect.input.data.html
-------------------------------------------------------------------

CMake Error at depthai-core/cmake/HunterGate.cmake:87 (message):
Call Stack (most recent call first):
  depthai-core/cmake/HunterGate.cmake:111 (hunter_gate_error_page)
  depthai-core/cmake/HunterGate.cmake:115 (hunter_gate_fatal_error)
  depthai-core/cmake/HunterGate.cmake:529 (hunter_gate_user_error)
  depthai-core/CMakeLists.txt:34 (HunterGate)

-- Configuring incomplete, errors occurred!

It seems Hunter not work well.

gespona commented 10 months ago

yes seems an issue with hunter compiling depthai-core, but I'm not able to reproduce on my side.

did you tried to compile depthai-core alone ? https://github.com/luxonis/depthai-core

I see few issues here related to hunter: https://github.com/luxonis/depthai-core/issues/953 https://github.com/luxonis/depthai-core/issues/876

there is recommendation to delete hunter cache directory: del C:/.hunter maybe worth to try?

personball commented 10 months ago

yes seems an issue with hunter compiling depthai-core, but I'm not able to reproduce on my side.

did you tried to compile depthai-core alone ? https://github.com/luxonis/depthai-core

I see few issues here related to hunter: luxonis/depthai-core#953 luxonis/depthai-core#876

there is recommendation to delete hunter cache directory: del C:/.hunter maybe worth to try?

Hi @gespona

I delete C:/.hunter each time I run cmake.

Maybe it is some problem with network.

I have success build my demo project with released depthai-core dlls, And I use vcpkg to resolve dependencies.

Please Consider release all DepthAI packages through vcpkg, It is supported by microsoft and has much better experience for developer.

lighterhy commented 2 months ago

Hi, @gespona

Same error occured for me.

Below link returns 404: https://raw.githubusercontent.com/cpp-pm/hunter-cache/master/eb87dbf/nlohmann_json/3.9.1/f8a20a7/151cbba/4830b34/da39a3e/basic-deps.DONE.

AndreiMoraru123 commented 1 month ago

Hi @lighterhy, deleting your C:/Users/<USER>/.hunter/ seems to solve the issue on the hunter side.

Could you see if that works for you? If not, maybe it's best to open a new issue, since this one is closed.