Skip to content

Compile error on MSYS2 64 bit #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jhasse opened this issue Sep 22, 2014 · 4 comments
Closed

Compile error on MSYS2 64 bit #620

jhasse opened this issue Sep 22, 2014 · 4 comments

Comments

@jhasse
Copy link

jhasse commented Sep 22, 2014

I'm running latest Rust and Cargo through a MSYS2 mingw64 shell. When trying to compile my program I get this error:

~/git/rust-opengl-test (master %=) cargo run
   Compiling rust-opengl-test v0.1.0 (file:///C:/msys64/home/jhasse/git/rust-opengl-test)
error: linking with `gcc` failed: exit code: 1
note: gcc '-m64' '-L' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib' '-o' 'C:\msys64\home\jhasse\git\rust-opengl-test\target\rust-opengl-test.exe' 'C:\msys64\home\jhasse\git\rust-opengl-test\target\rust-opengl-test.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-fno-lto' '-fno-use-linker-plugin' '-Wl,--gc-sections' '-shared-libgcc' '-Wl,--enable-long-section-names' '-Wl,--nxcompat' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib' 'C:\msys64\home\jhasse\git\rust-opengl-test\target\deps\libglfw-9f6ea9f24181e05c.rlib' 'C:\msys64\home\jhasse\git\rust-opengl-test\target\deps\libsemver-588b3e8c2b1d977b.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\liblog-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libregex-4e7c5e5c.rlib' 'C:\msys64\home\jhasse\git\rust-opengl-test\target\deps\libgl-bb78cdc3bae0f4e0.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libstd-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libsync-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\librustrt-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libcollections-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\liballoc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\liblibc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\librand-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libunicode-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libcore-4e7c5e5c.rlib' '-L' 'C:\msys64\home\jhasse\git\rust-opengl-test\target' '-L' 'C:\msys64\home\jhasse\git\rust-opengl-test\target\deps' '-L' 'C:\msys64\home\jhasse\git\rust-opengl-test\target\native\glfw-sys-362ff9a8d4dbbbbe' '-L' 'C:\msys64\home\jhasse\git\rust-opengl-test\.rust' '-L' 'C:\msys64\home\jhasse\git\rust-opengl-test' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lws2_32' '-lopengl32' '-lgdi32' '-lgcc_s' '-lcompiler-rt'
note: ld: cannot find -lopengl32
ld: cannot find -lgdi32

error: aborting due to previous error
Could not compile `rust-opengl-test`.

To learn more, run the command again with --verbose.

The strange thing is, when I copy the build command and paste it into the shell, it compiles just fine and also the resulting .exe file works. Running with --verbose doesn't give any more information. What could cause this?

@alexcrichton
Copy link
Member

Hm interesting! The windows bots have been sporadically failing for a very similar problem. I've been quite curious as to why, and unable to ever replicate it!

Is this repository somewhere that I could play around with? Do I need to install any prerequisites to get it working?

@jhasse
Copy link
Author

jhasse commented Sep 22, 2014

It's here: https://github.com/jhasse/rust-opengl-test

You need to edit ~/.cargo/git/checkouts/glfw-4fd4342c6777c12d/cargo-3.0.4/makefile.cargo: Quote the variables and add -G "MSYS Makefiles" to the cmake command (the latter is a "bug" of MSYS2 which some people have discussed on the mailing list some time ago. I might bring that up again and hope I can fix it in MSYS2's cmake or upstream).

@alexcrichton
Copy link
Member

Sadly this is rust-lang/rust#17442, not the error I was looking for :(

@jhasse
Copy link
Author

jhasse commented Sep 22, 2014

I see. Thanks for looking into this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants