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

Cargo build failures on LXQt #31

Open
hkk97 opened this issue Jan 18, 2024 · 3 comments
Open

Cargo build failures on LXQt #31

hkk97 opened this issue Jan 18, 2024 · 3 comments

Comments

@hkk97
Copy link

hkk97 commented Jan 18, 2024

Hello, I want to try learning from this project and running the example, but I encountered a few issues. I have ensured that I have installed CMake, g++, and c++, and my versions are as follows. The build process of dlib should be without any issues, but I don't know why the wrapper.rs file is unable to link with the header files referenced from the target build folder. Could you please give me some tips or ideas on how to solve these issues?

cmake --version

$ cmake --version
cmake version 3.22.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

c++ --version

$ c++ --version
c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

g++ --version

$ g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Cargo build errors

$ sudo cargo build
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /tester/dlib-face-recognition/sys/Cargo.toml
workspace: /tester/dlib-face-recognition/Cargo.toml
   Compiling dlib-face-recognition v0.3.2 (/tester/dlib-face-recognition)
The following warnings were emitted during compilation:

warning: src/wrapper.rs:2:14: fatal error: dlib/dnn.h: No such file or directory
warning:     2 |     #include <dlib/dnn.h>
warning:       |              ^~~~~~~~~~~~
warning: compilation terminated.

error: failed to run custom build command for `dlib-face-recognition v0.3.2 (/tester/dlib-face-recognition)`

Caused by:
  process didn't exit successfully: `/tester/dlib-face-recognition/target/debug/build/dlib-face-recognition-605abc5d9bdaa42a/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=./files
  cargo:rustc-link-lib=blas
  cargo:rustc-link-lib=dlib
  cargo:rustc-link-lib=lapack
  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CXX_x86_64-unknown-linux-gnu
  CXX_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CXX_x86_64_unknown_linux_gnu
  CXX_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64-unknown-linux-gnu
  CXXFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64_unknown_linux_gnu
  CXXFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "/tester/dlib-face-recognition" "-Wall" "-Wextra" "-std=c++14" "-o" "/tester/dlib-face-recognition/target/debug/build/dlib-face-recognition-d626b80a744e4d5a/out/1050f4fc78588567-cpp_closures.o" "-c" "/tester/dlib-face-recognition/target/debug/build/dlib-face-recognition-d626b80a744e4d5a/out/rust_cpp/cpp_closures.cpp"
  cargo:warning=src/wrapper.rs:2:14: fatal error: dlib/dnn.h: No such file or directory

  cargo:warning=    2 |     #include <dlib/dnn.h>

  cargo:warning=      |              ^~~~~~~~~~~~

  cargo:warning=compilation terminated.

  exit status: 1

  --- stderr


  error occurred: ToolExecError: Command "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "/tester/dlib-face-recognition" "-Wall" "-Wextra" "-std=c++14" "-o" "/tester/dlib-face-recognition/target/debug/build/dlib-face-recognition-d626b80a744e4d5a/out/1050f4fc78588567-cpp_closures.o" "-c" "/tester/dlib-face-recognition/target/debug/build/dlib-face-recognition-d626b80a744e4d5a/out/rust_cpp/cpp_closures.cpp" with args "c++" did not execute successfully (status code exit status: 1).
@HoKim98
Copy link
Member

HoKim98 commented Jan 23, 2024

Hello, this error may occur if the dlib native library is not installed on the host machine. This can be resolved by installing the library using a package manager, or preparing it for linking by manually building or downloading the binary.

If this process is cumbersome and you want to proceed smoothly, you can configure it to build automatically by activating the build-native feature when building cargo like: cargo build --features build-native.

The reason this feature is turned off by default is because the build time takes quite a bit, over 30 minutes.

@hkk97
Copy link
Author

hkk97 commented Jan 23, 2024

Thank you for answering and providing the suggested ideas. I think I should try running it on macOS and Windows.
To be honest, running cargo build --features build-native works fine for me. However, it seems to fail to link with the dlib library. I tried linking with the dlib library by configuring the .vscode/c_cpp_properties.json file as shown in the code below. After that, I ran cargo run again, and the built .o object file was able to link with the dlib library on my PC. However, the src/wrapper.rs file still fails to link with the header files from dlib.

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/tester/Desktop/dlib"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",                     
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-clang-x64"
        }
    ],
    "version": 4
}

@HoKim98
Copy link
Member

HoKim98 commented May 7, 2024

Could you register an environment variable DEP_DLIB_INCLUDE to your dlib path? It's likely be a __YOUR_LIBRARY_PATH__/dlib-19.24 if you downloaded it from the official homepage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants