enigo-rs / enigo

Cross platform input simulation in Rust
MIT License
1.03k stars 102 forks source link

Linking error `cannot find -lxdo` when trying to compile 0.0.12 on Linux #55

Closed 8176135 closed 6 years ago

8176135 commented 6 years ago

After upgrading to 0.0.12 from 0.0.11, when I try to compile on Linux (works fine on gnu Windows) it gives error: linking with `cc` failed: exit code: 1 and the reason note: /usr/bin/ld: cannot find -lxdo

The only change to dependencies in 0.0.12 that seem to affect linux is objc 0.2.2, but when I tried to compile that by itself, it compiled just fine.

I also installed xdo, but that didn't seem to change anything.

Any ideas?

jD91mZM2 commented 6 years ago

It now uses libxdo instead of X11 directly so we can use a well-known and therefore less buggy backend. To fix the linking error, install xdotool :)

8176135 commented 6 years ago

Ah, thank you, installed xdo before, not xdotool.

jim4067 commented 3 years ago

Hello :wave: I am still experiencing the same error error: linking with cc failed: exit status: 1 = note: /usr/bin/ld: cannot find -lxdo I do have xdotool installed and do not know what the problem is and any help will be greatly appreciated.

fynxiu commented 2 years ago

@jim4067 I don't know if the message came too late ­🛸 libxdo-dev

Red-exe-Engineer commented 1 year ago

It now uses libxdo instead of X11 directly so we can use a well-known and therefore less buggy backend. To fix the linking error, install xdotool :)

Thank you so much! I recently reinstalled Arch Linux and a Rust program I wrote was giving a huge error when I tried to compile it. \:D

ninjadev64 commented 5 months ago

Please add this stuff to the README!

pentamassiv commented 5 months ago

Do you mean something like this: https://github.com/enigo-rs/enigo?tab=readme-ov-file#runtime-dependencies? It's already there, right?

ninjadev64 commented 5 months ago

Oh, completely missed that, sorry!

pentamassiv commented 5 months ago

No problem, I am glad you find enigo useful and are trying it out :-)

ninjadev64 commented 5 months ago

Me again! I've switched to openSUSE Tumbleweed since my comment and am unable to find the libxdo package. I have libX11-devel, xdo, and xdotool installed, and none work.

pentamassiv commented 5 months ago

You can try activating the x11rb feature. If you do that, you won't need to install any dependencies. There might still be some bugs, that is why it is not the default yet. Please open an issue if you encounter a bug when enabling the feature

ninjadev64 commented 5 months ago

You can try activating the x11rb feature. If you do that, you won't need to install any dependencies. There might still be some bugs, that is why it is not the default yet. Please open an issue if you encounter a bug when enabling the feature

Hi, it links successfully if I enable this feature. However, this feature is only available in 0.2.0 to my understanding, but I depend on the existence of the DSL as my project relies on the user being able to easily create macros by providing input to a text box. Is there an easy way to obtain DSL-like functionality in v0.2.0?

pentamassiv commented 5 months ago

Yes, that should be no problem. Have a look at the serde example. You can just do the part that start with line 28. There no longer is a DSL because implementing it is much more complex and time consuming than using serde. It is also more flexible, because you can chose from whatever format serde can deserialize. In the example, ron is used. In the example, a few tokens are serialized and the resulting string is printed in the terminal. This should give you an idea on what users would have to enter into your text box.

For your convenience, here is the tokens that are getting serialized:

let tokens = vec![
        Token::Text("Hello World! ❤️".to_string()),
        Token::MoveMouse(10, 10, enigo::Coordinate::Rel),
        Token::Scroll(5, enigo::Axis::Vertical),
        Token::Button(Button::Left, enigo::Direction::Click),
        Token::Key(Key::Unicode('🔥'), enigo::Direction::Click),
        Token::Key(Key::Control, enigo::Direction::Press),
        Token::Key(Key::Unicode('a'), enigo::Direction::Click),
        Token::Key(Key::Control, enigo::Direction::Release),
    ];

and this is what the resulting string looks like:

[Text("Hello World! ❤\u{fe0f}"),MoveMouse(10,10,Rel),Scroll(5,Vertical),Button(Left,Click),Key(Unicode('🔥'),Click),Key(Control,Press),Key(Unicode('a'),Click),Key(Control,Release)]

Feel free to ask more, if that was not clear

ninjadev64 commented 5 months ago

Hi, yep, I'm aware of the serde features, but inputting macros in RON/JSON/whatever would be quite cumbersome for users, as opposed to the comparatively simple DSL.

pentamassiv commented 5 months ago

What do you think of this proposal?

ninjadev64 commented 5 months ago

It's better, but still not great. I could implement a custom deserialiser and publish to crates.io when I have time in a few weeks.

ninjadev64 commented 5 months ago

I ultimately solved it by using revision 390f69d with the x11rb feature activated, but this is a less than ideal solution. I would appreciate the re-addition of the DSL.

pentamassiv commented 5 months ago

I am not going to add the DSL again. It was a lot of code and very error prone. Each new key had to get added to it and it was incomplete because it is quite difficult to write. I have created a new PR for you to make the strings to deserialize from even less verbose https://github.com/enigo-rs/enigo/pull/283.

There is also the serde(untagged) attribute. That would make it even more concise, but there have been errors that I wasn't able to resolve in a timely manner. If you could get that to work, I'd merge it.

I'd advise against staying on an old commit. There are still a few bugs left that I'll fix in the coming months.