I Can't Get Cross Compiling From Ubuntu To Windows Working

北城余情 提交于 2020-08-25 07:27:08

问题


I Want To Cross Compile Some Rust Code from Ubuntu to Windows, and receive an error about onexitbegin.

Tried to follow various suggestions, but they don't have my specific error message: crt2.o:crtexe.c: (.rdata$.refptr.__onexitend[.refptr.__onexitend]+0x0): undefined reference to `__onexitend' collect2: error: ld returned 1 exit status

cargo build --release --target x86_64-pc-windows-gnu

Expected to get something built, but it blows up. The output says this: /usr/bin/x86_64-w64-mingw32-ld: /home/vince/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/crt2.o:crtexe.c:(.rdata$.refptr.__onexitbegin[.refptr.__onexitbegin]+0x0): undefined reference to __onexitbegin' /usr/bin/x86_64-w64-mingw32-ld: /home/vince/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/crt2.o:crtexe.c:(.rdata$.refptr.__onexitend[.refptr.__onexitend]+0x0): undefined reference to__onexitend'


回答1:


If you receive messages about an undefined reference to

__onexitbegin` or something similar, you may have an older version of crt2.o, instead of the version that ming has available to it. I did! (running on stable rust 1.35).

Try this in your terminal and see if it helps:

cd ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/

mv crt2.o crt2.o.bak

cp /usr/x86_64-w64-mingw32/lib/crt2.o ./

Your executable should now be built for windows.



来源:https://stackoverflow.com/questions/56602101/i-cant-get-cross-compiling-from-ubuntu-to-windows-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!