rust-lang / socket2

Advanced configuration options for sockets.
https://docs.rs/socket2
Apache License 2.0
683 stars 227 forks source link

socket2 doesn't compile on ubuntu #527

Closed Merrick17 closed 3 days ago

Merrick17 commented 2 months ago

when I try to compile I get this error error[E0425]: cannot find functionset_msghdr_controlin modulesys --> src/lib.rs:714:14 | 714 | sys::set_msghdr_control(&mut self.inner, buf.as_mut_ptr().cast(), buf.len()); | ^^^^^^^^^^^^^^^^^^ not found insys`

error[E0425]: cannot find function msghdr_flags in module sys --> src/lib.rs:720:14 | 720 | sys::msghdr_flags(&self.inner) | ^^^^^^^^^^^^ not found in sys

error[E0425]: cannot find function msghdr_control_len in module sys --> src/lib.rs:729:14 | 729 | sys::msghdr_control_len(&self.inner) | ^^^^^^^^^^^^^^^^^^ not found in `sys``

Thomasdezeeuw commented 2 months ago

Can you share the command you're using to build socket2?

Because the functions are very much defined: https://github.com/rust-lang/socket2/blob/3a938932829ea6ee3025d2d7a86c7b095c76e6c3/src/sys/unix.rs#L741-L760.

Merrick17 commented 2 months ago
sorry I guess I didn't make my self clear , okayb first issue I'm using orao vrf which has socket2 as a depencies, if I follow the correct error stack it starts from here Compiling ring v0.17.8 Compiling socket2 v0.5.7 Compiling crunchy v0.2.2 Compiling digest v0.9.0 error[E0583]: file not found for modulesys` --> src/lib.rs:179:1 179 mod sys; ^^^^^^^^
= help: to create the module `sys`, create file "/home/safouane/.cargo/registry/src/index.crates.io-6f17d22bba15001f/socket2-0.5.7/src/sys.rs" or "/home/safouane/.cargo/registry/src/index.crates.io-6f17d22bba15001f/socket2-0.5.7/src/sys/mod.rs"
= note: if there is a `mod sys` elsewhere in the crate already, import it with `use crate::...` instead

error: Socket2 doesn't support the compile target --> src/lib.rs:182:1 | 182 | compile_error!("Socket2 doesn't support the compile target"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0432]: unresolved imports crate::sys::c_int, crate::sys::sa_family_t, crate::sys::sockaddr, crate::sys::sockaddr_in, crate::sys::sockaddr_in6, crate::sys::sockaddr_storage, crate::sys::socklen_t, crate::sys::AF_INET, crate::sys::AF_INET6, crate::sys::AF_UNIX --> src/sockaddr.rs:11:5 11 c_int, sa_family_t, sockaddr, sockaddr_in, sockaddr_in6, sockaddr_storage, socklen_t, AF_IN... ^^^^^ ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^^^ no AF_INET in sys
no socklen_t in sys
no sockaddr_storage in sys
no sockaddr_in6 in sys
no sockaddr_in in sys
no sockaddr in sys
no sa_family_t in sys
no c_int in sys
12 AF_INET6, AF_UNIX,
^^^^^^^^ ^^^^^^^ no AF_UNIX in sys
no AF_INET6 in sys

= help: consider importing one of these items instead: std::ffi::c_int std::os::raw::c_int core::ffi::c_int = help: consider importing this module instead: crate::sockaddr `

Thomasdezeeuw commented 2 months ago

I still need the command you're running, e.g. cargo build etc. If you are using a different target for example this might cause issues. This fact that you're hitting compile_error!("Socket2 doesn't support the compile target"); indicates your not compiling for Linux.

P.S. Can you put the output in between "```" (three backticks) on a separate line, that would make it more readable on GitHub.

Merrick17 commented 2 months ago

okay sorry , so basically what I'm doing is creating a solana/anchor program , I've added https://github.com/orao-network/solana-vrf which as it seems uses the socket2 as a dependency . I've runned "Anchor build" to build the program but it fails as shown

Thomasdezeeuw commented 2 months ago

I still don't know what OS you're targeting... can you enable some kind of debug/verbose logging? At some point anchor build should call cargo or rustc, I'll like to know what kind of flags are passed. Specifically --target.

Merrick17 commented 2 months ago
image image

hopefully this helps , can't find anything else that I can help even with Anchor commands , I've already opend same issue with VRF library

Thomasdezeeuw commented 2 months ago

I don't what anchor or solana are, so I don't know how they are using socket2. I think it would best if you open a ticket with the anchor project, maybe they can help you better.

Thomasdezeeuw commented 3 days ago

Closing based on activity.