Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Wrong paths from cmake targets #23483

Closed
aavbsouza opened this issue Jan 24, 2025 · 0 comments
Closed

[Build] Wrong paths from cmake targets #23483

aavbsouza opened this issue Jan 24, 2025 · 0 comments
Labels
build build issues; typically submitted using template

Comments

@aavbsouza
Copy link

Describe the issue

First I have downloaded the binary package from the github release page (version 1.20.1). After that I have unzipped the contents. Creating a directory called onnxruntime-linux-x64-gpu-1.20.1. Them I have created a simple CMakeLists.txt

cmake_minimum_required(VERSION 3.28)
project(onnx-test LANGUAGES C CXX CUDA VERSION 0.0.1)

set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)

find_package(onnxruntime REQUIRED)

I proceeded to configure the cmake project

cmake -S. -Bbuild -DCMAKE_PREFIX_PATH=./onnxruntime-linux-x64-gpu-1.20.1/lib/cmake

Them I got this error

CMake Error at onnxruntime-linux-x64-gpu-1.20.1/lib/cmake/onnxruntime/onnxruntimeTargets.cmake:84 (message):
  The imported target "onnxruntime::onnxruntime" references the file

     "/workspaces/onnx-cpp/onnxruntime-linux-x64-gpu-1.20.1/lib64/libonnxruntime.so.1.20.1"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/workspaces/onnx-cpp/onnxruntime-linux-x64-gpu-1.20.1/lib/cmake/onnxruntime/onnxruntimeTargets.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  onnxruntime-linux-x64-gpu-1.20.1/lib/cmake/onnxruntime/onnxruntimeConfig.cmake:26 (include)
  CMakeLists.txt:29 (find_package)

I them copied all files from the lib directory to a newly created lib64 directory. This change fix the previous error message but throw another one.

CMake Error in csrc/CMakeLists.txt:
  Imported target "onnxruntime::onnxruntime" includes non-existent path

    "/workspaces/onnx-cpp/onnxruntime-linux-x64-gpu-1.20.1/include/onnxruntime"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

Creating an empty onnruntinme at the error path, "fix the cmake error", to throw another one during compilation:

When trying to compile a simple example (only including the header onnxruntime_cxx_api.h)

[1/2] Building CXX object csrc/CMakeFiles/onnx_simple.dir/onnx_simple.cpp.o
FAILED: csrc/CMakeFiles/onnx_simple.dir/onnx_simple.cpp.o 
/usr/bin/c++ -DNSYNC_ATOMIC_CPP11 -isystem /workspaces/onnx-cpp/onnxruntime-linux-x64-gpu-1.20.1/include/onnxruntime -O3 -DNDEBUG -std=c++17 -Wextra -Wall -rdynamic -fno-omit-frame-pointer -g -ggdb -fdiagnostics-color=always -MD -MT csrc/CMakeFiles/onnx_simple.dir/onnx_simple.cpp.o -MF csrc/CMakeFiles/onnx_simple.dir/onnx_simple.cpp.o.d -o csrc/CMakeFiles/onnx_simple.dir/onnx_simple.cpp.o -c /workspaces/onnx-cpp/csrc/onnx_simple.cpp
/workspaces/onnx-cpp/csrc/onnx_simple.cpp:9:10: fatal error: onnxruntime_cxx_api.h: No such file or directory
    9 | #include <onnxruntime_cxx_api.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.

the CMake try to use the fullpath (with onnxruntime).

I believe that are some problem with the exported targets trying to use a older configuration

Urgency

No response

Target platform

x64-cuda

Build script

binary release from github

Error / output

CMake detection error of these binary release

Visual Studio Version

No response

GCC / Compiler Version

No response

@aavbsouza aavbsouza added the build build issues; typically submitted using template label Jan 24, 2025
@snnn snnn closed this as completed Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template
Projects
None yet
Development

No branches or pull requests

2 participants