Ralith / openxrs

OpenXR bindings for Rust
Apache License 2.0
282 stars 59 forks source link

Statically linking leads to openxr-sys build error #92

Closed Danielduel closed 3 years ago

Danielduel commented 3 years ago
cargo 1.56.0 (4ed5d137b 2021-10-04)
cmake version 3.21.3
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Linux *** 5.11.0-38-generic #42~20.04.1-Ubuntu SMP *** x86_64 x86_64 x86_64 GNU/Linux

in CMake logs: #include <xcb/glx.h> ... fatal error: xcb/glx.h: No such file or directory

Before that CMake is warning (not sure if it is relevant):

CMake Warning (dev) at src/loader/CMakeLists.txt:48 (add_library):
    Policy CMP0063 is not set: Honor visibility properties for all target
    types.  Run "cmake --help-policy CMP0063" for policy details.  Use the
    cmake_policy command to set the policy and suppress this warning.

    Target "openxr_loader" of type "STATIC_LIBRARY" has the following
    visibility properties set for C:

      C_VISIBILITY_PRESET

    For compatibility CMake is not honoring them for this target.
  This warning is for project developers.  Use -Wno-dev to suppress it.

// I am not the rust/cpp/unix expert - I am happy to provide more info if needed :)

Dockerfile able to reproduce the issue

FROM ubuntu:20.04

ENV PATH="/root/.cargo/bin:${PATH}"

# Disable standard debian question about timezone
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y build-essential cmake curl
RUN apt-get update

# https://www.rust-lang.org/tools/install
# added "-y" to proceed with defaults
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y

# check in logs to ensure cargo 1.56.0 (4ed5d137b 2021-10-04)
RUN cargo -V

WORKDIR /home/someuser

RUN cargo new app --bin

WORKDIR /home/someuser/app

RUN echo 'openxr = { version = "0.15.4", features = ["static"] }' >> Cargo.toml
RUN tail -n 2 Cargo.toml # log out last 2 lines are [dependencies] \n openxr =...

RUN cargo build

You can copy-paste this docker script into file named "Dockerfile" and run docker build . given docker is installed on your machine. Buildlog with cached steps before actual build: buildlog.txt

Ralith commented 3 years ago

Thanks for the issue! This looks like a problem with your build environment: you do not have the compile-time dependencies of the OpenXR loader installed. Those can be found in the OpenXR SDK documentation. If you're targeting Linux, you should also consider dynamically linking a pre-compiled OpenXR loader build provided by the environment; e.g. Ubuntu 21 includes it.

Danielduel commented 3 years ago

Thanks for the issue! This looks like a problem with your build environment: you do not have the compile-time dependencies of the OpenXR loader installed. Those can be found in the OpenXR SDK documentation. If you're targeting Linux, you should also consider dynamically linking a pre-compiled OpenXR loader build provided by the environment; e.g. Ubuntu 21 includes it.

Thank you! It makes sense. Thought rust (cargo) is automagically resolving all dependencies like npm (node package manager) :)

(I will close the issue in a moment, after checking if everything links ok)

Ralith commented 3 years ago

Cargo handles Rust dependencies. Neither it nor npm can handle foreign dependencies.

Danielduel commented 3 years ago

Useful link: https://dochavez.github.io/Documenting-with-Docusaurus-V2.-/docs/monado/ Project has compiled, but is panicking on the runtime. I think I will have to go and read docs more carefully before asking questions :) Once again - thank you @Ralith