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

Static linking not working with features such as ttf or image #1395

Open
mario-hess opened this issue Apr 30, 2024 · 1 comment
Open

Static linking not working with features such as ttf or image #1395

mario-hess opened this issue Apr 30, 2024 · 1 comment

Comments

@mario-hess
Copy link

I need to include the sdl2 library and the features ttf and image in my executable.
Guided by the readme, I used the static-link feature and either the bundled, or use-pkgconfig.
Using it with use-pkgconfig, it does not work, the library files are not included in the executable (bug?).
Using it with bundled, it errors out. Error:

error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/mario/.cargo/bin:/home/mario/go/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcABAUbl/symbols.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.0.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.1.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.10.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.11.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.12.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.13.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.14.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.15.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.2.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.3.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.4.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.5.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.6.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.7.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.8.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.9.rcgu.o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.3hmf4m0cvigh3l7q.rcgu.o" "-Wl,--as-needed" "-L" "/home/mario/dev/gaemboi/target/release/deps" "-L" "/home/mario/dev/gaemboi/target/release/build/sdl2-sys-29aa5deac462e868/out/lib" "-L" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/mario/dev/gaemboi/target/release/deps/librfd-575de581cb390144.rlib" "/home/mario/dev/gaemboi/target/release/deps/libraw_window_handle-4953b3df70fca321.rlib" "/home/mario/dev/gaemboi/target/release/deps/libgtk_sys-02fd55af77b1abc7.rlib" "/home/mario/dev/gaemboi/target/release/deps/libatk_sys-e42e0a651c4b37a8.rlib" "/home/mario/dev/gaemboi/target/release/deps/libgdk_sys-0e47ad84cf099bde.rlib" "/home/mario/dev/gaemboi/target/release/deps/libpango_sys-e4cfb113861506e3.rlib" "/home/mario/dev/gaemboi/target/release/deps/libgdk_pixbuf_sys-ae07e51f44f6a083.rlib" "/home/mario/dev/gaemboi/target/release/deps/libgio_sys-9a521f3d2c7297e4.rlib" "/home/mario/dev/gaemboi/target/release/deps/libcairo_sys-924d9f61d3de9444.rlib" "/home/mario/dev/gaemboi/target/release/deps/libgobject_sys-7e78b987473e8627.rlib" "/home/mario/dev/gaemboi/target/release/deps/libglib_sys-d520f8ff4f71ded3.rlib" "/home/mario/dev/gaemboi/target/release/deps/libsdl2-8d1878e8cd542e62.rlib" "/home/mario/dev/gaemboi/target/release/deps/libsdl2_sys-d69dbe0bd38c7f56.rlib" "/home/mario/dev/gaemboi/target/release/deps/libbitflags-0c90388e62645a4b.rlib" "/home/mario/dev/gaemboi/target/release/deps/liblazy_static-9e94bf42d38961bf.rlib" "/home/mario/dev/gaemboi/target/release/deps/liblibc-9bd89074bdc3d561.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-edb03adabf0b22c8.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-56c2a42cc2d7381f.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-fd705a60736c3357.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-c0ff7ddb2987d8da.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-c459f8b0a64f04e1.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-c2d64f918d4b26ad.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-d22c51811a78dc80.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-d8ba7f24f3cb57da.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-2a372fbb5b41c14b.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-45ff23c614a38f1d.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-6b9410c3805b4c08.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-6deb8c633abe47e3.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-57df4eca7d5785df.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-0b7d1529f62927c0.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-69a45ab5967387b5.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-c2c050aec00eb6da.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-522518611024dce5.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-35b8a4bd2de4e62e.rlib" "-Wl,-Bdynamic" "-lgdk-3" "-lz" "-lharfbuzz" "-lpangocairo-1.0" "-lpango-1.0" "-latk-1.0" "-lcairo" "-lcairo-gobject" "-lgdk_pixbuf-2.0" "-lgio-2.0" "-lglib-2.0" "-lgobject-2.0" "-lgtk-3" "-lgobject-2.0" "-lglib-2.0" "-latk-1.0" "-lharfbuzz" "-lpangocairo-1.0" "-lpango-1.0" "-lgdk_pixbuf-2.0" "-lcairo-gobject" "-lcairo" "-lglib-2.0" "-lgobject-2.0" "-lgdk-3" "-lz" "-lgobject-2.0" "-lglib-2.0" "-lharfbuzz" "-lpango-1.0" "-lgobject-2.0" "-lglib-2.0" "-lgdk_pixbuf-2.0" "-lgobject-2.0" "-lglib-2.0" "-lgio-2.0" "-lcairo" "-lglib-2.0" "-lgobject-2.0" "-lglib-2.0" "-lgobject-2.0" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/mario/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.15.rcgu.o: in function `sdl2::ttf::font::PartialRendering::blended':
          gaemboi.e7829b0afb4eb9b-cgu.15:(.text._ZN4sdl23ttf4font16PartialRendering7blended17hf6b642f2b907f4cbE+0x7b): undefined reference to `TTF_RenderText_Blended'
          /usr/bin/ld: gaemboi.e7829b0afb4eb9b-cgu.15:(.text._ZN4sdl23ttf4font16PartialRendering7blended17hf6b642f2b907f4cbE+0x91): undefined reference to `TTF_RenderUTF8_Blended'
          /usr/bin/ld: /home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.15.rcgu.o: in function `gaemboi::menu::run':
          gaemboi.e7829b0afb4eb9b-cgu.15:(.text._ZN7gaemboi4menu3run17hb80cf0c106c09a9fE+0x43): undefined reference to `IMG_LoadTexture_RW'
          /usr/bin/ld: /home/mario/dev/gaemboi/target/release/deps/gaemboi-a87d2ac4800b0c23.gaemboi.e7829b0afb4eb9b-cgu.6.rcgu.o: in function `gaemboi::boot_sequence::run':
          gaemboi.e7829b0afb4eb9b-cgu.6:(.text._ZN7gaemboi13boot_sequence3run17h9a435b7cca8ce7f0E+0x45): undefined reference to `IMG_LoadTexture_RW'
          /usr/bin/ld: /home/mario/dev/gaemboi/target/release/deps/libsdl2-8d1878e8cd542e62.rlib(sdl2-8d1878e8cd542e62.sdl2.fd9889eede20d70c-cgu.14.rcgu.o): in function `<sdl2::ttf::font::Font as core::ops::drop::Drop>::drop':
          sdl2.fd9889eede20d70c-cgu.14:(.text._ZN63_$LT$sdl2..ttf..font..Font$u20$as$u20$core..ops..drop..Drop$GT$4drop17ha115a88b7cb77674E+0x6): undefined reference to `TTF_WasInit'
          /usr/bin/ld: sdl2.fd9889eede20d70c-cgu.14:(.text._ZN63_$LT$sdl2..ttf..font..Font$u20$as$u20$core..ops..drop..Drop$GT$4drop17ha115a88b7cb77674E+0x16): undefined reference to `TTF_CloseFont'
          /usr/bin/ld: /home/mario/dev/gaemboi/target/release/deps/libsdl2-8d1878e8cd542e62.rlib(sdl2-8d1878e8cd542e62.sdl2.fd9889eede20d70c-cgu.8.rcgu.o): in function `<sdl2::ttf::context::Sdl2TtfContext as core::ops::drop::Drop>::drop':
          sdl2.fd9889eede20d70c-cgu.8:(.text._ZN76_$LT$sdl2..ttf..context..Sdl2TtfContext$u20$as$u20$core..ops..drop..Drop$GT$4drop17h841eea3975401b7dE+0x2): undefined reference to `TTF_Quit'
          /usr/bin/ld: /home/mario/dev/gaemboi/target/release/deps/libsdl2-8d1878e8cd542e62.rlib(sdl2-8d1878e8cd542e62.sdl2.fd9889eede20d70c-cgu.8.rcgu.o): in function `sdl2::ttf::context::Sdl2TtfContext::load_font_from_rwops':
          sdl2.fd9889eede20d70c-cgu.8:(.text._ZN4sdl23ttf7context14Sdl2TtfContext20load_font_from_rwops17h1429c6222eee620eE+0x1c): undefined reference to `TTF_OpenFontRW'
          /usr/bin/ld: /home/mario/dev/gaemboi/target/release/deps/libsdl2-8d1878e8cd542e62.rlib(sdl2-8d1878e8cd542e62.sdl2.fd9889eede20d70c-cgu.8.rcgu.o): in function `sdl2::ttf::context::init':
          sdl2.fd9889eede20d70c-cgu.8:(.text._ZN4sdl23ttf7context4init17h3e9064bb9777f17bE+0x3): undefined reference to `TTF_WasInit'
          /usr/bin/ld: sdl2.fd9889eede20d70c-cgu.8:(.text._ZN4sdl23ttf7context4init17h3e9064bb9777f17bE+0x1a): undefined reference to `TTF_Init'
          collect2: error: ld returned 1 exit status

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

Is there any way to statically link sdl2 with ttf and image feature?

@Cobrand
Copy link
Member

Cobrand commented Apr 30, 2024

For bundled, it's not currently supported with ttf, image, gfx, mixer.

For static-link with those, I do not remember whether it was supported or not, but probably not. Pull requests are always welcome, be it either for documentation or anything build process related.

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