Skip to content

Compile error on MSYS2 64 bit #620

Closed
@jhasse

Description

@jhasse

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions