imgui-rs icon indicating copy to clipboard operation
imgui-rs copied to clipboard

Unresolved symbol with dynamic linking (dylib crate-type)

Open SparkyPotato opened this issue 4 years ago • 5 comments
trafficstars

The complete error:

error LNK2019: unresolved external symbol igTextUnformatted referenced in function_ZN5imgui6widget4text27_$LT$impl$u20$imgui..Ui$GT$4text17h2046f112a25bb173E

To Reproduce

Window::new(im_str!("Hello world"))
  .build(ui, ||
  {
    ui.text("Hello");
  });

Expected behavior It should compile and work as intended.

Please describe your environment

  • imgui-rs version 0.70
  • Windows 10 20H2

Other information It seems like the library is not linking with cimgui correctly. This only happens if a library is a dylib, but both the executable and library depend on imgui-rs.

Also, are there any plans to switch to the docking branch?

SparkyPotato avatar Feb 27 '21 14:02 SparkyPotato

HMM. I have absolutely no idea! Can you tell us more about your dylib?

Also the docking branch is a larger conversation, but please comment on https://github.com/imgui-rs/imgui-rs/issues/435 to help us get in a state where we can have multiple branches

sanbox-irl avatar Mar 01 '21 06:03 sanbox-irl

I have a dylib crate that depends on imgui-rs, and reexports it for users. It handles all the backend stuff. When I link it with an executable, and access the reexported functions, the cimgui functions don't link. However, even if I link the executable crate directly with imgui-rs, the undefined symbols still don't go away.

SparkyPotato avatar Mar 01 '21 11:03 SparkyPotato

I think this happens with Linux+gcc+ld also

We have a similar sounding setup - basically an application composed of various crates, multiple of which use imgui

I tried making one of the crates by a dylib (to see if it has much impact on development build times, by reducing the amount of things to be statically linked into the main application),

[lib]
crate-type = ["dylib"]

but this results in a screen full of errors along the line of undefined reference to 'igBeginPopup'

dbr avatar Jan 24 '22 07:01 dbr

I'll try and put together a complete reproduction-example for this, but I think it should just be:

  1. crate_util which uses imgui-rs, and sets crate-type = ["dylib"]
  2. crate_main which uses imgui-rs and crate_util

dbr avatar Jan 24 '22 07:01 dbr