-
Notifications
You must be signed in to change notification settings - Fork 119
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
Unable to link a static library with a C program #330
Comments
I tested with different features, but I still have the same issues. |
enigo
) with a C program
Thank you for opening an issue. I haven't tried statically linking with The warning you see in the log is not important. Even though the |
I tried to reproduce the linking issue on my computer. Please keep in mind that I never tried statically linking before, so I might state a few things that are incorrect or obvious to someone who did this before. :-) The build also fails for me but I get a different error: ...
Copying byproducts `libservice.a` to /var/home/penta/Documents/Code/ibus-afrim/build/src
[ 0%] Built target _cargo-build_service
[ 0%] Built target cargo-build_service
[ 33%] Linking C executable ibus-engine-afrim
/usr/bin/ld: ../src/libservice.a(enigo-b9a8a5e54903c186.enigo.f1a4e1800866da4b-cgu.0.rcgu.o): in function `enigo::platform::x11::Con::new':
/var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:111:(.text._ZN5enigo8platform3x113Con3new17hc622aad86ccaf3e8E+0x143): undefined reference to `xdo_new'
/usr/bin/ld: /var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:109:(.text._ZN5enigo8platform3x113Con3new17hc622aad86ccaf3e8E+0x2d0): undefined reference to `xdo_new'
/usr/bin/ld: ../src/libservice.a(enigo-b9a8a5e54903c186.enigo.f1a4e1800866da4b-cgu.0.rcgu.o): in function `<enigo::platform::x11::Con as core::ops::drop::Drop>::drop':
/var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:140:(.text._ZN67_$LT$enigo..platform..x11..Con$u20$as$u20$core..ops..drop..Drop$GT$4drop17ha10ef69ca5f6c75dE+0xa): undefined reference to `xdo_free'
/usr/bin/ld: ../src/libservice.a(enigo-b9a8a5e54903c186.enigo.f1a4e1800866da4b-cgu.0.rcgu.o): in function `<enigo::platform::x11::Con as enigo::Keyboard>::fast_text':
/var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:157:(.text._ZN61_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Keyboard$GT$9fast_text17h5aa35979197a6c7dE+0x3d5): undefined reference to `xdo_enter_text_window'
/usr/bin/ld: ../src/libservice.a(enigo-b9a8a5e54903c186.enigo.f1a4e1800866da4b-cgu.0.rcgu.o): in function `<enigo::platform::x11::Con as enigo::Keyboard>::key':
/var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:206:(.text._ZN61_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Keyboard$GT$3key17haf81df5b3a19524eE+0x5bf): undefined reference to `xdo_send_keysequence_window_down'
/usr/bin/ld: /var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:220:(.text._ZN61_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Keyboard$GT$3key17haf81df5b3a19524eE+0x832): undefined reference to `xdo_send_keysequence_window_up'
/usr/bin/ld: /var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:192:(.text._ZN61_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Keyboard$GT$3key17haf81df5b3a19524eE+0xa97): undefined reference to `xdo_send_keysequence_window'
/usr/bin/ld: ../src/libservice.a(enigo-b9a8a5e54903c186.enigo.f1a4e1800866da4b-cgu.0.rcgu.o): in function `<enigo::platform::x11::Con as enigo::Mouse>::button':
/var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:249:(.text._ZN58_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Mouse$GT$6button17h2014797c142590e3E+0xe8): undefined reference to `xdo_mouse_down'
/usr/bin/ld: /var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:253:(.text._ZN58_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Mouse$GT$6button17h2014797c142590e3E+0x24f): undefined reference to `xdo_mouse_up'
/usr/bin/ld: /var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:257:(.text._ZN58_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Mouse$GT$6button17h2014797c142590e3E+0x3bb): undefined reference to `xdo_click_window'
/usr/bin/ld: ../src/libservice.a(enigo-b9a8a5e54903c186.enigo.f1a4e1800866da4b-cgu.0.rcgu.o): in function `<enigo::platform::x11::Con as enigo::Mouse>::move_mouse':
/var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:274:(.text._ZN58_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Mouse$GT$10move_mouse17hdf1e880f3f4515d4E+0x9f): undefined reference to `xdo_move_mouse'
/usr/bin/ld: /var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:270:(.text._ZN58_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Mouse$GT$10move_mouse17hdf1e880f3f4515d4E+0x2a2): undefined reference to `xdo_move_mouse_relative'
/usr/bin/ld: ../src/libservice.a(enigo-b9a8a5e54903c186.enigo.f1a4e1800866da4b-cgu.0.rcgu.o): in function `<enigo::platform::x11::Con as enigo::Mouse>::main_display':
/var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:310:(.text._ZN58_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Mouse$GT$12main_display17h9f4d4b3cbfd3ab5bE+0x61): undefined reference to `xdo_get_viewport_dimensions'
/usr/bin/ld: ../src/libservice.a(enigo-b9a8a5e54903c186.enigo.f1a4e1800866da4b-cgu.0.rcgu.o): in function `<enigo::platform::x11::Con as enigo::Mouse>::location':
/var/home/penta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/enigo-0.2.1/src/linux/xdo.rs:325:(.text._ZN58_$LT$enigo..platform..x11..Con$u20$as$u20$enigo..Mouse$GT$8location17h64c3a568bbc4bbeaE+0x7a): undefined reference to `xdo_get_mouse_location2'
collect2: error: ld returned 1 exit status
gmake[2]: *** [apps/CMakeFiles/ibus-engine-afrim.dir/build.make:114: apps/ibus-engine-afrim] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:295: apps/CMakeFiles/ibus-engine-afrim.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2 I think my error happens because I do not have the static library files for [penta@toolbox ibus-afrim]$ sudo find /usr -name "libxdo.so"
/usr/lib64/libxdo.so
[penta@toolbox ibus-afrim]$ sudo find /usr -name "libxdo.a"
[penta@toolbox ibus-afrim]$ Do you have the static library files for When I compare my error with your error, it looks like the I was surprised that you are having these problems because I remembered that you use enigo in another project of yours (afrim). When I looked it up again, I noticed that you use enigo version 1.3 in that project. That version did not depend on While investigating this, I found the crate xkbcommon-rs. It is a Rust re-implementation of |
In order to debug your other issue, could you please try to run the
The example should enter the text "Hello World! here is a lot of text ❤️" and select everything. If something was entered when running the example using the default feature, but not with the x11rb feature, we can be sure that the bug is in enigo's code. If that's the case, could you please provide me with more information:
|
Also, using the default feature (xdo) is pretty reliable, but I hope it won't happen, but there is also the chance that your keymap gets changed incorrectly. A restart of your computer fixes it. |
I tested only use enigo::{Enigo, Key, Keyboard};
use std::thread;
use std::time::Duration;
fn main() {
thread::sleep(Duration::from_secs(5));
let mut enigo = Enigo::new(&Default::default()).unwrap();
// write text
enigo.text("kə̀cɔ̀ nə̀tǐ' !");
} It works on some applications and others not:
Note: With/without the wayland feature, I have the same behavior. OS Environment |
@pentamassiv, thanks, I succeed to build.
But I still have this problem of I think, I can close it now. |
TLDR: Your other problem can only be solved either by simulating hardware input (not yet implemented in enigo), updating to a more recent version of Gnome (at least 45) or only using X11. I am glad you were able to find a solution to the linking issue. Your other issue can't be solved (with enigo) for now. Unfortunately simulating input on Linux became a mess starting with the transition to Wayland. For a time there was no solution but now we actually have multiple competing solutions. At the beginning there was no Wayland protocol to do it. People resorted to simulating low -level hardware input. Then some compositors created their own protocols such as The only way you can simulate input in your version of Gnome is to simulate hardware input e.g with uinput. Unfortunately I did not get to implementing that yet (I am happy about PRs). It is lower level and I am not sure how you can enter chars like "kə̀cɔ̀ nə̀tǐ' !" with it. I think it is only possible to enter keys with it but if you figure out how to change the keymap that could work. The reason why enigo works for some of your applications is that some of them are X11 applications and the others natively use Wayland. Firefox can use X11 or Wayland but the default on your version is to use X11. If you start Firefox with this command I am sorry that I don't have a solution for you for now, but the future for input simulation on Linux looks bright ;-) |
BTW, what does "kə̀cɔ̀ nə̀tǐ' !" mean and which language is it? |
I am working with |
It's an exclamation in Bamileke language to express the surprise. |
I didn't know about ibus. I have to look into it. I created an issue to remind me: #334 |
Describe the bug
When I try to link my static rust library to a C program, I got a link error.
cargo
build the library without error.corrosion-rs
build the library without errorCMake
is not able to do the linking with the C program.Without
enigo
, everything is working.To Reproduce
Expected behavior
Build successfully
Environment:
Additional context
The text was updated successfully, but these errors were encountered: