Skip to content
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

Link fails with msys2/multirust #42

Closed
ghost opened this issue May 15, 2016 · 5 comments
Closed

Link fails with msys2/multirust #42

ghost opened this issue May 15, 2016 · 5 comments

Comments

@ghost
Copy link

ghost commented May 15, 2016

I can't get an executable to link using either back end.

With miniz, __assert_func can't be found:

error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\crt2.o" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "-L" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "D:\\Projects\\aurum\\draw\\target\\debug\\examples\\image.0.o" "-o" "D:\\Projects\\aurum\\draw\\target\\debug\\examples\\image.exe" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "D:\\Projects\\aurum\\draw\\target\\debug" "-L" "D:\\Projects\\aurum\\draw\\target\\debug\\deps" "-L" "D:\\Projects\\aurum\\draw\\target\\debug\\build\\miniz-sys-d03126dbc9ee0074\\out" "-L" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "D:\\Projects\\aurum\\draw\\target\\debug\\libaurum_draw.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_display-c2219c7625040322.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libuser32-5b257a594df68a77.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libgdi32-69e315c17a3908b1.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libbitflags-69448112f0ca8232.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_image-635c95e01fa05f6d.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_unicode-abd69641aec3f6e4.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_color-45538d7570a142be.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_linear-e1b0e372e378fd33.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_numeric-02eca3f26ddef8a6.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\liblog-30a8a27ec161f1be.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libflate2-c4ffd8a47aabab9a.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libcrc-84833374161e9fc4.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\liblazy_static-e69e55dcc7527931.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_winutil-bd9d94ddcf37bec3.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libkernel32-72bc68efd3a36233.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libwinapi-6fc61f3c438a06cc.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libminiz_sys-d03126dbc9ee0074.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\liblibc-7f0d63b960234050.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcollections-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_unicode-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librand-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc_system-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-4fda350b.rlib" "-l" "user32" "-l" "gdi32" "-l" "kernel32" "-l" "gcc_eh" "-l" "ws2_32" "-l" "userenv" "-l" "shell32" "-l" "advapi32" "-l" "compiler-rt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
note: D:\Projects\aurum\draw\target\debug\deps\libminiz_sys-d03126dbc9ee0074.rlib(miniz.o): In function `tinfl_decompress':
/home/Daggerbot/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/miniz-sys-0.1.7/miniz.c:1707: undefined reference to `__assert_func'
D:\Projects\aurum\draw\target\debug\deps\libminiz_sys-d03126dbc9ee0074.rlib(miniz.o): In function `tdefl_start_dynamic_block':
/home/Daggerbot/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/miniz-sys-0.1.7/miniz.c:2024: undefined reference to `__assert_func'
/home/Daggerbot/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/miniz-sys-0.1.7/miniz.c:2026: undefined reference to `__assert_func'
/home/Daggerbot/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/miniz-sys-0.1.7/miniz.c:2027: undefined reference to `__assert_func'
/home/Daggerbot/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/miniz-sys-0.1.7/miniz.c:2030: undefined reference to `__assert_func'
D:\Projects\aurum\draw\target\debug\deps\libminiz_sys-d03126dbc9ee0074.rlib(miniz.o):/home/Daggerbot/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/miniz-sys-0.1.7/miniz.c:2031: more undefined references to `__assert_func' follow

And with zlib, the linker can't find -lz even though '/usr/lib/libz.a' exists:

error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\crt2.o" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "-L" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "D:\\Projects\\aurum\\draw\\target\\debug\\examples\\image.0.o" "-o" "D:\\Projects\\aurum\\draw\\target\\debug\\examples\\image.exe" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "D:\\Projects\\aurum\\draw\\target\\debug" "-L" "D:\\Projects\\aurum\\draw\\target\\debug\\deps" "-L" "/usr/lib" "-L" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "D:\\Projects\\aurum\\draw\\target\\debug\\libaurum_draw.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_display-c2219c7625040322.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libuser32-5b257a594df68a77.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libgdi32-69e315c17a3908b1.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libbitflags-69448112f0ca8232.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_image-635c95e01fa05f6d.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_unicode-abd69641aec3f6e4.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_color-45538d7570a142be.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_linear-e1b0e372e378fd33.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_numeric-02eca3f26ddef8a6.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\liblog-30a8a27ec161f1be.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libflate2-c4ffd8a47aabab9a.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libcrc-84833374161e9fc4.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\liblazy_static-e69e55dcc7527931.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libaurum_winutil-bd9d94ddcf37bec3.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libkernel32-72bc68efd3a36233.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\libwinapi-6fc61f3c438a06cc.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\liblibz_sys-e9c5285337e33905.rlib" "D:\\Projects\\aurum\\draw\\target\\debug\\deps\\liblibc-7f0d63b960234050.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcollections-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_unicode-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librand-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc_system-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-4fda350b.rlib" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-4fda350b.rlib" "-l" "user32" "-l" "gdi32" "-l" "kernel32" "-l" "z" "-l" "gcc_eh" "-l" "ws2_32" "-l" "userenv" "-l" "shell32" "-l" "advapi32" "-l" "compiler-rt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "D:\\MSYS\\home\\Daggerbot\\.multirust\\toolchains\\stable\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
note: ld: cannot find -lz

I'm not sure whether these problems are related to flate2's build script or msys2, but I'll try using an msvc toolchain in the meantime.

@alexcrichton
Copy link
Member

Yeah unfortunately I'd recommend MSVC for now. This is an unfortunate interaction where the linker that we're bundling is incompatible with the system linker. Specifically, the miniz library is getting compiled with the system gcc, but we're linking with the bundled gcc, and those two libraries are incompatible, causing this link error.

I'm surprised though that the libz.a feature didn't work? Maybe the installed version is for the wrong architecture?

You can fix this with a few methods:

  1. Use the MSVC host compilers with a MSVC target
  2. Use the MSVC host compilers with a mingw target

The latter should allow you to run in the same environment you currently are and target executables for mingw.

@seanmonstar
Copy link

I just hit this trying to add in gzip decoding into reqwest. I'm not sure I could make a release that no longer works on mingw Windows... Is this something that cannot be fixed in this crate?

@alexcrichton
Copy link
Member

At least for now I know of nothing this crate can do. My "solution" is to install MSVC rust and then add a MinGW target, but it's definitely not a great solution.

@alexcrichton
Copy link
Member

This hasn't come up in quite awhile, so I'm going to close this. There's only so much a crate like this can do to "fix" the environment, but in a situation like this I don't think there's much more we can do.

@mallochine
Copy link

FYI: I ran into similar problem on another crate, but it's related -- MSVC rust wouldn't work for me because one of the crate dependencies uses pkg-config which bails out on MSVC. I used the GNU to work around it, but now I don't know what to do about linking problem.

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

3 participants