Collect2.exe: error: ld returned 1 exit status

Hello

I have made a application using Gtk-rs. I was able to compile and run it on Windows multiple times, but suddenly (without changes in the code) I am not able to build it anymore.

This is the build-error I receive:

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\vboxuser\\AppData\\Local\\Temp\\rustcQu4fDi\\symbols.o" "Z:\\target\\debug\\build\\generic-array-3b4e6e3c674f5890\\build_script_build-3b4e6e3c674f5890.build_script_build.c8e12fd5fd92365d-cgu.0.rcgu.o" "Z:\\target\\debug\\build\\generic-array-3b4e6e3c674f5890\\build_script_build-3b4e6e3c674f5890.5f10m9538oxs6tw8.rcgu.o" "-L" "Z:\\target\\debug\\deps" "-L" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "\\\\VBoxSvr\\hellofood-receipt-client\\target\\debug\\deps\\libversion_check-e3606dd37dd6c5fc.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-04636370035c201d.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-c3b96808afaa6575.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-97d6320636f743d5.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-e5cbd9f0b9a5be70.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-c167a1b5cebaaeaf.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-ce7bb94521605250.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-a89d0cc3cf1c6748.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-02da591b0d3539d3.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-9be0888c6aa9a961.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-5d7b525fb13077ac.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libminiz_oxide-18ab6f7b3ad5c2d0.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libadler-e7d6d3ee0829f2da.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-0a1987609977f2ad.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-8f77c0b774284ca4.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-1913aeb298ab75c8.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-4514e0b5dd1cd669.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-18eb823c704f2f4d.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-53bb4c7fa8a9b445.rlib" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-2d5501d7dc8c802c.rlib" "-Wl,-Bdynamic" "-lkernel32" "-ladvapi32" "-lbcrypt" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-lkernel32" "-lws2_32" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-o" "Z:\\target\\debug\\build\\generic-array-3b4e6e3c674f5890\\build_script_build-3b4e6e3c674f5890.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\Users\\vboxuser\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find \\VBoxSvr\hellofood-receipt-client\target\debug\deps\libversion_check-e3606dd37dd6c5fc.rlib: Invalid argument
          collect2.exe: error: ld returned 1 exit status

I am building Gtk4 on Windows using msys. I am using stable-x86_64-pc-windows-gnu as a toolchain (this one worked before).

These are my PATH environment variables:

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Users\vboxuser\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\vboxuser\AppData\Local\Programs\Python\Python38\;C:\Users\vboxuser\AppData\Local\Programs\Python\Launcher\;C:\Users\vboxuser\.cargo\bin;C:\Users\vboxuser\AppData\Local\Microsoft\WindowsApps;C:\Users\vboxuser\AppData\Local\Programs\Microsoft VS Code\bin;C:\pkg-config-lite-0.28-1\bin;C:\gnome\bin;c:\users\vboxuser\appdata\roaming\python\python38\scripts;c:\users\vboxuser\.local\bin;C:\msys64\mingw64\include;C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;

Doing a cargo clean and trying to build it then does not work...

are you building inside an vm? your virtual machine settings have changed maybe?

1 Like

Yes, I am using a Virtualbox shared folder to access my project on the VM and run cargo run. It seems that shared folders are not allowed to run exe-files. Copying the files to my VM does work.

Is there a more efficient way to do this?

I'll look into a Docker container maybe.

It could also be that ld doesn't understand UNC paths (i.e. that \\VBoxSvr\... syntax). If that's the case, you might be able to get around that by mapping the share to a drive letter inside the VM. That said, I've never run Windows inside VirtualBox, and I don't know if the OS sees the shared folder as a network drive or not.

You can map network shares via Explorer (no idea where the button is these days), or via the NET USE command.

IIRC VirtualBox's shared filesystem driver is somewhat incomplete. It just about works as a method for simple file transfer but breaks in all sorts of other situations.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.