fedora์์ Hello, world!
์ปดํ์ผ์ ์๋ํ๋ฉด
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
|
= note: "x86_64-w64-mingw32-gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/crt2.o" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsbegin.o" "-L" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver0.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver1.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver10.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver11.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver12.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver13.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver14.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver15.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver2.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver3.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver4.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver5.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver6.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver7.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver8.rust-cgu.o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.printserver9.rust-cgu.o" "-o" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.exe" "/app/target/x86_64-pc-windows-gnu/debug/deps/printserver-4c9c9553ae081d85.crate.allocator.rust-cgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/app/target/x86_64-pc-windows-gnu/debug/deps" "-L" "/app/target/debug/deps" "-L" "/home/rust/.cargo/git/checkouts/winapi-rs-a54263a8eb5d0916/70e1da8/x86_64/lib" "-L" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "-Wl,-Bstatic" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libstd-60d4a252bdda9250.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/liballoc_system-a05404e5e059417a.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librand-81cbf6f1d5a19206.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libpanic_unwind-0b63e20460046692.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/liballoc-f824a78e715239af.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libstd_unicode-2abaea46f194a6e1.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libunwind-7daa32005d584d8a.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/liblibc-49ff25caaa6e945f.rlib" "/app/target/x86_64-pc-windows-gnu/debug/deps/libwinapi-e1e9b0b9a817ecee.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcore-f2bd2d524c6ace24.rlib" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcompiler_builtins-c6139fac5e899293.rlib" "-Wl,-Bdynamic" "-l" "advapi32" "-l" "ws2_32" "-l" "userenv" "-l" "shell32" "-Wl,-Bstatic" "-l" "gcc_eh" "-l" "pthread" "-Wl,-Bdynamic" "-l" "winspool" "-l" "user32" "-l" "kernel32" "-l" "msimg32" "-l" "opengl32" "-l" "gdi32" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "/home/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsend.o"
= note: /usr/lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lpthread
collect2: error: ld returned 1 exit status
๋ด ์๊ฐ ์ ์ฐ๋ถํฌ์ ๊ฒฝ๋ก๊ฐ /usr/x86_64-w64-mingw32/lib/libpthread.a
๋ฐ๋ฉด ํ๋๋ผ์์๋ /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libpthread.a
์ด์ง๋ง RUSTFLAGS="-L /usr/x86_64-w64-mingw32/sys-root/mingw/lib" cargo build
(๋๋ ๋ชจ๋ ํ์ ๊ฒฝ๋ก๋ ์๋ ํจ)๋ฅผ ์คํํด๋ ๋์์ด๋์ง ์์์ต๋๋ค.
๋ด ํ ์คํธ ์ค์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
FROM ubuntu
RUN apt-get update && apt-get install -y \
vim \
curl \
gcc \
gcc-mingw-w64-x86-64 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app
ENV HOME=/home/rust
RUN groupadd -r -g 1000 rust \
&& useradd --no-log-init -r -g rust -u 1000 rust \
&& mkdir -p $HOME \
&& chown rust:rust $WORKDIR $HOME
USER rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="$HOME/.cargo/bin:$PATH"
RUN rustup target add x86_64-pc-windows-gnu
RUN echo >>~/.cargo/config '[build]\ntarget = "x86_64-pc-windows-gnu"\n\n[target.x86_64-pc-windows-gnu]\nlinker = "x86_64-w64-mingw32-gcc"\nar = "x86_64-w64-mingw32-gcc-ar"'
FROM fedora
RUN dnf install -y \
vim \
gcc \
mingw64-gcc \
&& dnf clean all
WORKDIR /app
ENV HOME=/home/rust
RUN groupadd -r -g 1000 rust \
&& useradd --no-log-init -r -g rust -u 1000 rust \
&& mkdir -p $HOME \
&& chown rust:rust $WORKDIR $HOME
USER rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="$HOME/.cargo/bin:$PATH"
RUN rustup target add x86_64-pc-windows-gnu
RUN echo -e >>~/.cargo/config '[build]\ntarget = "x86_64-pc-windows-gnu"\n\n[target.x86_64-pc-windows-gnu]\nlinker = "x86_64-w64-mingw32-gcc"\nar = "x86_64-w64-mingw32-gcc-ar"'
mkdir test
cd test
clippaste >Dockerfile # put above snippet in Dockerfile
docker build -t rust-test .
docker run --rm -it rust-test bash
USER=a cargo init --bin
cargo build # works with ubuntu but fails with fedora
๋๋ ์๋ winapi ์์๋ฅผ ์ถ๊ฐํ์ ๋๋ง ๋ฐ์ํ๋ค๊ณ ์๊ฐํ๊ธฐ ๋๋ฌธ์ https://github.com/retep998/winapi-rs/issues/527 ์ฌ๊ธฐ์ ์ ์ถํ์ต๋๋ค.
๋น์ทํ ๋ฌธ์ ๋ฅผ ๋ฐ๊ฒฌํ์ต๋๋ค https://github.com/rust-lang/rust/issues/32859 https://github.com/rust-lang/rust/issues/33465 https://github.com/rust-lang / rust / issues / 44787 ํ์ง๋ง ๋์ผํ์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค.
๋๋ฅผ ์ํด ๋ฌธ์ ๋ฅผ ํด๊ฒฐ ํ "mingw64-winpthreads-static"์ ์ค์นํด ๋ณด์ จ์ต๋๊น?
๊ฐ์ฌํฉ๋๋ค. ์ ๋ ๋ง์ฐฌ๊ฐ์ง์์ต๋๋ค.
/ usr / bin / x86_64-w64-mingw32-ld : -lboost_program_options-mt๋ฅผ ์ฐพ์ ์ ์์
collect2 : ์ค๋ฅ : ld๊ฐ 1 ์ข
๋ฃ ์ํ๋ฅผ ๋ฆฌํดํ์ต๋๋ค.
์ด ์ค๋ฅ๋ฅผ ํด๊ฒฐํ๋๋ก ๋์์ฃผ์ธ์ ..
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋๋ฅผ ์ํด ๋ฌธ์ ๋ฅผ ํด๊ฒฐ ํ "mingw64-winpthreads-static"์ ์ค์นํด ๋ณด์ จ์ต๋๊น?