本文介绍了使用glfw-rs时,gcc.exe找不到-lglfw3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上运行Rust(可能是我的第一个错误,但我不会放弃)与mingw。我下载了64位的所有内容,当我构建我的项目时,我得到

 错误:与`gcc`链接失败:退出代码:1 
注意:gcc'-Wl, - enable-long-section-names''-fno-use-linker-plugin''-Wl, - nxcompat''-static-libgcc''-m64'' - L'C:\R
ust\bin\rustlib\x86_64-pc-windows-gnu\lib''-o''C:\Users\jay\projects\ hello_world\target\hello_world.exe''C:\Users\jay
\projects\hello_world\target\hello_world.o''-Wl, - gc-sections''C :\ Users \jay\projects\hello_world\target\deps\libglfw-5
007f9fddc425da6.rlib''C:\Users\jay\projects\hello_world\target \deps\libbitflags-57b03d5337bba57b.rlib'C:\ Users \jay\pr
ojects\hello_world\target\deps\libsemver-693b3d5412b8e4b9.rlib''C:\ Users\jay\projects\\ \\ hello_world\target\deps\liblog-4e
79c2d7625e8c6f.rlib'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libstd-4e7c5e5c .rlib'C:\Rust\\\\\\\\\\\\\\\\\\\\\\\\\\\\\''''C:\Rust\\\\\\\\\\\\\\' rustlib\x86_64-pc-windows-gnu\lib\libunicode-4e7c5e5c.rlib'
'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\\ \\ librand-4e7c5e5c.rlib''C:\Rust\\\\\\\\\\\\\\\\\\\''C:\Rust\\\\\\\\\\\\\\ \bin\rustlib\x86_64-pc-windows-gnu\lib\liblibc-4e7c5e5c.rlib'C:\Rust\bin\rustlib\x86_64 -p
c-windows -gnu \lib\libcore-4e7c5e5c.rlib''-L''C:\Users\jay\projects\hello_world\target''-L''C:\Users\jay\\ \\ projects \hel
lo_world\t arget\deps''-L''C:\Rust\\\\\\\\\\'''''''''''''''''' \hello_world\.rust
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ pc-windows-gnu''-Wl, - whole-archive''-W
l,-Bstatic''-Wl, - no-whole-archive''-Wl,-Bdynamic''-lglfw3' '-lopengl32''-lgdi32''-lws2_32''-lcompiler-rt'
注意:ld:找不到-lglfw3

错误:由于之前的错误而中止
可能不编译`hello_world`。

(试图格式化它,但是..?)

我相信问题是我的gcc.exe,它说无论什么时候运行它都找不到输入文件。有没有一个gcc.exe可以替换它? 尝试下载。我将 lib-mingw 目录中的文件复制到我的Rust项目中。在我的32位Windows VM上,我将它们放在 hello-glfw \ bin\i686-pc-windows-gnu 中,但它看起来像是你想的 hello_world\bin\x86_64-PC-Windows的GNU 。这使我可以运行。


I'm running Rust on Windows (probably my first mistake, but i'm not giving up) with mingw. I downloaded 64bit everything and when I build my project I get

error: linking with `gcc` failed: exit code: 1
note: gcc '-Wl,--enable-long-section-names' '-fno-use-linker-plugin' '-Wl,--nxcompat' '-static-libgcc' '-m64' '-L' 'C:\R
ust\bin\rustlib\x86_64-pc-windows-gnu\lib' '-o' 'C:\Users\jay\projects\hello_world\target\hello_world.exe' 'C:\Users\jay
\projects\hello_world\target\hello_world.o' '-Wl,--gc-sections' 'C:\Users\jay\projects\hello_world\target\deps\libglfw-5
007f9fddc425da6.rlib' 'C:\Users\jay\projects\hello_world\target\deps\libbitflags-57b03d5337bba57b.rlib' 'C:\Users\jay\pr
ojects\hello_world\target\deps\libsemver-693b3d5412b8e4b9.rlib' 'C:\Users\jay\projects\hello_world\target\deps\liblog-4e
79c2d7625e8c6f.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libstd-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc
-windows-gnu\lib\libcollections-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libunicode-4e7c5e5c.rlib'
'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\librand-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\lib
alloc-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\liblibc-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-p
c-windows-gnu\lib\libcore-4e7c5e5c.rlib' '-L' 'C:\Users\jay\projects\hello_world\target' '-L' 'C:\Users\jay\projects\hel
lo_world\target\deps' '-L' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib' '-L' 'C:\Users\jay\projects\hello_world\.rust
\bin\x86_64-pc-windows-gnu' '-L' 'C:\Users\jay\projects\hello_world\bin\x86_64-pc-windows-gnu' '-Wl,--whole-archive' '-W
l,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lglfw3' '-lopengl32' '-lgdi32' '-lws2_32' '-lcompiler-rt'
note: ld: cannot find -lglfw3

    error: aborting due to previous error
    Could not compile `hello_world`.

(Tried to format it but..?)

I believe the problem is my gcc.exe, it says cannot find input file whenever i run it. Is there a gcc.exe i can replace it with?

解决方案

Try downloading the precompiled GLFW libraries. I copied the files from the lib-mingw directory into my Rust project. On my 32-bit Windows VM, I put them in hello-glfw\bin\i686-pc-windows-gnu, but it looks like you want hello_world\bin\x86_64-pc-windows-gnu. This allowed me to run the example from the glfw-rs README.

这篇关于使用glfw-rs时,gcc.exe找不到-lglfw3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 17:18