I fail to cross compile rust program with zmq. To reproduce easily (with docker) :
Write the following Dockerfile
FROM rust:latest
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y g++-mingw-w64-x86-64 libudev-dev libzmq3-dev
RUN rustup target add x86_64-pc-windows-gnu
RUN rustup toolchain install --force-non-host stable-x86_64-pc-windows-gnu
WORKDIR /app
# This permit to pkg-config to found zmq
ENV PKG_CONFIG_SYSROOT_DIR=/usr/x86_64-w64-mingw32/
CMD ["cargo", "build", "--target", "x86_64-pc-windows-gnu"]
Build docker image with docker build . -t mycrossimage.
Create Cargo.toml and src/main.rs files
echo "[package]\nname = \"demo\"\nversion = \"0.1.0\"\nedition = \"2021\"\n[dependencies]\nzmq = \"0.9.0\"" > Cargo.toml && mkdir -p src && echo 'use zmq; fn main() {}' > src/main.rs
Try to compile through docker with docker run --rm -v $(pwd):/app mycrossimage:latest
And fail on :
error: linking with `x86_64-w64-mingw32-gcc` failed: exit status:
[...]
= note: /usr/bin/x86_64-w64-mingw32-ld: cannot find -lzmq
collect2: error: ld returned 1 exit status
How to configure a linux system to be able to compile a Rust program using zmq ?
Related
I was trying to install telegram bot api on my ssh server and I ran into a problem.
Operating system: Debian 11, Linux
Commands which I used:
su -
apt-get update.
apt-get upgrade.
apt-get install make git zlib1g-dev libssl-dev gperf cmake g++.
exit.
git clone --recursive https://github.com/tdlib/telegram-bot-api.git.
cd telegram-bot-api.
rm -rf build.
mkdir build.
cd build.
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. ..
cmake --build . --target install
cd ../..
ls -l telegram-bot-api/bin/telegram-bot-api*
Problem:
When I was running this command "cmake --build . --target install", my downloading stopped on 33% with this message:
"[ 33%] Building CXX object td/CMakeFiles/tdapi.dir/td/generate/auto/td/telegram/td_api.cpp.o"
I've tried twice, nothing happens after this, how do I fix this?
Commands from https://tdlib.github.io/telegram-bot-api/build.html?os=Linux
I've tried to run the whole code again, but the problem was the same. I'm not into linux, thats why I'm asking here
I'm trying to build a rust app with rust-rocksdb as a dependency.
Using the latest rust docker image to compile and then moving the binary to a debian.
This is how my Dockerfile looks
FROM rust:1.61 as builder
RUN USER=root cargo new --bin fbrust
WORKDIR ./fbrust
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
RUN apt-get update \
&& apt-get install -y ca-certificates tzdata libclang-dev \
&& rm -rf /var/lib/apt/lists/*
RUN cargo build --release
RUN rm src/*.rs
ADD . ./
RUN rm ./target/release/deps/fbrust*
RUN cargo build --release
FROM debian:buster-slim
ARG APP=/usr/src/app
EXPOSE 5005
ENV TZ=Etc/UTC \
APP_USER=appuser
RUN groupadd $APP_USER \
&& useradd -g $APP_USER $APP_USER \
&& mkdir -p ${APP}
COPY --from=builder /fbrust/target/release/fbrust ${APP}/fbrust
RUN chown -R $APP_USER:$APP_USER ${APP}
USER $APP_USER
WORKDIR ${APP}
CMD ["./fbrust"]
I'm now getting this error(s):
./fbrust: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by ./fbrust)
./fbrust: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.30' not found (required by ./fbrust)
./fbrust: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by ./fbrust)
First of all, I'm confused why do I see both 2.29 and 2.30 required.
I checked within the container and indeed I have 2.28
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii libc-bin 2.28-10 amd64 GNU C Library: Binaries
Is there any other image I can use to achieve compatibility or can I get a hint on what dependencies/setup should I try?
If you look at the list of Debian releases, as of this writing Debian 10 "Buster" is one release behind, and Debian 11 "Bullseye" is the current released stable version. You can also look at the libc6 package listing and see that "Buster" contains libc6 2.28, and "Bullseye" contains libc6 2.31 (both with local patches).
So for your setup, it should work to change the final image to a newer version of Debian, like
FROM debian:bullseye-stable # one newer than buster
Rust builds binaries for the host system by default; This includes the version of glibc of whatever system compiled the binary. The easiest fix is to compile the binary in another docker image using the same version of the same distro.
You should not attempt to fix this by changing distro version to match your binary; You binary will again stop working whenever you upgrage/change the distro on your personal computer (or whatever computer you're using to build the binary).
Alternatively, you can try to compile a static binary: (related question)
rustup target add x86_64-unknown-linux-musl
cargo build --target=x86_64-unknown-linux-musl
I want to install openpose through docker for python 3. For that, I am making a Dockerfile with all the commands and getting an error with the installation process.
I am trying to build the Dockerfile from scratch using this code.
FROM ubuntu
LABEL maintainer = "Ankit Sharma" <ankit.kumar#mirrorsize.com>
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y tzdata
RUN apt-get install -y python3 python3-pip
RUN apt-get install -y libopencv-dev
RUN apt install -y libprotobuf-dev protobuf-compiler
RUN apt-get install -y libhdf5-dev
RUN apt-get install -y libgoogle-glog-dev
RUN apt-get install -y git
RUN apt-get install -y libboost-all-dev
RUN apt-get install -y wget
WORKDIR src
RUN git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose.git
WORKDIR /src/openpose/3rdparty
RUN rm -r caffe
RUN rm -r pybind11
RUN git clone https://github.com/BVLC/caffe.git
RUN git clone https://github.com/pybind/pybind11.git
WORKDIR /src/openpose/build
RUN apt-get -y install cmake
RUN cmake .. -DBUILD_CAFFE=ON -DBUILD_python=ON -DGPU_MODE=CPU_ONLY -USE_OPENCV=ON
RUN make
RUN make install
RUN make -j 64
I expected a clean installation and BUILD_python: ON and USE_OPENCV: ON.
Here's the complete output:
-- Build type : Release
--
-- BUILD_SHARED_LIBS : on
-- BUILD_python : OFF
-- BUILD_matlab : OFF
-- BUILD_docs : OFF
-- CPU_ONLY : ON
-- USE_OPENMP : ON
-- USE_OPENCV : OFF
-- USE_LEVELDB : OFF
-- USE_LMDB : OFF
-- ALLOW_LMDB_NOLOCK : OFF
-- USE_SYSTEMTAP : OFF
-- PERFORMANCE_MONITORING : OFF
-- CO_SIM : OFF
--
-- Dependencies:
-- BLAS : Yes (MKL)
-- MKL2017_SUPPORTED : ON, is a default engine
-- MKLDNN_SUPPORTED : ON, is a default engine
-- Boost : Yes (ver. 1.65)
-- glog : Yes
-- gflags : Yes
-- protobuf : Yes (ver. 3.0.0)
-- CUDA : No
--
-- Install:
-- Install path : /src/openpose/build/caffe
--
-- Configuring done
-- Generating done
Other errors are coming in the Caffe build -
[ 39%] Building CXX object src/caffe/CMakeFiles/caffe.dir/layers/mkldnn_eltwise_layer.cpp.o
[ 39%] Building CXX object
src/caffe/CMakeFiles/caffe.dir/layers/mkldnn_inner_product_layer.cpp.o
/src/openpose/3rdparty/caffe/src/caffe/layers/mkldnn_inner_product_layer.cpp: In member function 'void
caffe::MKLDNNInnerProductLayer<Dtype>::InitInnerProductBwd(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<bool>&, const std::vector<caffe::Blob<Dtype>*>&)':
/src/openpose/3rdparty/caffe/src/caffe/layers/mkldnn_inner_product_layer.cpp:357:2: error: this 'else' clause does not guard... [-Werror=misleading-indentation]
else
^~~~
/src/openpose/3rdparty/caffe/src/caffe/layers/mkldnn_inner_product_layer.cpp:361:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
ipBwdData_desc.reset(new inner_product_backward_data::desc(init_bottom_md, init_weights_md, init_top_md));
^~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
As part of one of my projects, I have to cross-compile a Rust crate from x86_64 to i686 on Linux. I'm currently using Travis CI for this, with a simple Hello World crate (the default binary crate). My Travis CI configuration for the relevant matrix entry is:
# ...
matrix:
include:
# ...
- os: linux
rust: 1.30.0
before_script:
- sudo apt-get update
- sudo apt-get install -y libc6-dev:i386
env: TARGET=i686-unknown-linux-gnu
# ...
script:
- rustup target install $TARGET
- cargo build --release --target=$TARGET
Unfortunately, when I push this configuration to Travis CI, I get a build error:
$ cargo build --release --target=$TARGET
Compiling test-rust-deploy-releases v0.1.0 (/home/travis/build/arnavb/test-rust-deploy-releases)
error: linker `cc` not found
|
= note: No such file or directory (os error 2)
error: aborting due to previous error
error: Could not compile `test-rust-deploy-releases`.
To learn more, run the command again with --verbose.
The command "cargo build --release --target=$TARGET" exited with 101.
How do I fix this?
Well, after experimenting and more googling, I changed my apt install command to:
sudo apt-get install -y gcc-4.8 cpp-4.8 gcc-multilib
(The first two are unmet dependencies of the third, which had to be manually installed).
Now the build runs properly.
I am trying to install nodejs using the docker console for ubuntu but I get an error installing node js. This is the error I am getting
The command [/bin/sh -c ./configure && make && make install] returned a non-zero code: 127
This is part of my dockerfile
FROM ubuntu:12.04
RUN mkdir -p /dir/subdir
RUN apt-get update
# Install nodejs
ADD http://nodejs.org/dist/v0.10.26/node-v0.10.26-linux-x64.tar.gz /dir
WORKDIR /dir/node-v0.10.26-linux-x64
RUN ./configure && make && make install
WORKDIR /dir
Exit code 127 typically means "command not found". Chances are build-essentials are not installed.
Try adding the following after the apt-get update:
RUN apt-get -y install build-essential