Hello everyone,
I am having trouble building a simple program using some Windows API calls using the "windows" crate.
Issue : Bindgen fails to generate valid bindings.rs
I am looking to generate static bindings to resolve symbols within my Helix IDE which is not possible for the moment using the lastest version of the "windows" crate. So far, I downgraded the version to 0.52 which comes with imports out of the box.
The set-up is the following :
// Cargo.toml
[dependencies]
windows = "0.62.2"
[build-dependencies]
windows-bindgen = "0.65.0"
// bindings.rs
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let args = [
"--out",
"src/bindings.rs", // Path where bindings are stored,
"--filter", // Windows namespaces you want to generate
"Windows.Win32.System.Threading",
"Windows.Win32.Foundation",
"Windows.Win32.System.Console",
"Windows.Win32.System.Com",
];
// Generate bindings
windows_bindgen::bindgen(&args);
// Tell Cargo to re-run build.rs if you change the list
println!("cargo:rerun-if-changed=build.rs");
Ok(())
}
During the building phase, the rust compiler throws an large number of ' use of unresolved module or unlinked crate `windows_*'. Having skimmed though the changelog on the release section of the crate, I did notice that a lot reworking has been done between the 0.5X version to the 0.62 version, though I am not expirimented enough to fully understand that changes I need to apply to even make a single windows pop.
Here is an excerpt of the errors thrown :
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16426:21
|
16426 | windows_core::link!("ole32.dll" "system" fn CoTestCancel() -> windows_core::HRESULT);
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16434:21
|
16434 | windows_core::link!("ole32.dll" "system" fn CoTreatAsClass(clsidold : *const windows_core::GUID, clsidnew : *const windows_core::GUID) -> windows_core::HRESULT);
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16439:21
|
16439 | windows_core::link!("ole32.dll" "system" fn CoUninitialize());
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16448:21
|
16448 | ... windows_core::link!("ole32.dll" "system" fn CoWaitForMultipleHandles(dwflags : u32, dwtimeout : u32, chandles : u32, phandles : *const super::super::Foundation:: HANDLE, lpdwindex : *mut u32) -...
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16467:21
|
16467 | ... windows_core::link!("ole32.dll" "system" fn CoWaitForMultipleObjects(dwflags : u32, dwtimeout : u32, chandles : u32, phandles : *const super::super::Foundation:: HANDLE, lpdwindex : *mut u32) -...
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16482:21
|
16482 | windows_core::link!("ole32.dll" "system" fn CreateAntiMoniker(ppmk : *mut * mut core::ffi::c_void) -> windows_core::HRESULT);
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16491:21
|
16491 | windows_core::link!("ole32.dll" "system" fn CreateBindCtx(reserved : u32, ppbc : *mut * mut core::ffi::c_void) -> windows_core::HRESULT);
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16502:21
|
16502 | windows_core::link!("ole32.dll" "system" fn CreateClassMoniker(rclsid : *const windows_core::GUID, ppmk : *mut * mut core::ffi::c_void) -> windows_core::HRESULT);
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16511:21
|
16511 | windows_core::link!("ole32.dll" "system" fn CreateDataAdviseHolder(ppdaholder : *mut * mut core::ffi::c_void) -> windows_core::HRESULT);
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16527:21
|
16527 | ... windows_core::link!("ole32.dll" "system" fn CreateDataCache(punkouter : * mut core::ffi::c_void, rclsid : *const windows_core::GUID, iid : *const windows_core::GUID, ppv : *mut *mut core::ffi::...
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16541:21
|
16541 | windows_core::link!("ole32.dll" "system" fn CreateFileMoniker(lpszpathname : windows_core::PCWSTR, ppmk : *mut * mut core::ffi::c_void) -> windows_core::HRESULT);
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16557:21
|
16557 | ... windows_core::link!("ole32.dll" "system" fn CreateGenericComposite(pmkfirst : * mut core::ffi::c_void, pmkrest : * mut core::ffi::c_void, ppmkcomposite : *mut * mut core::ffi::c_void) -> window...
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `windows_core`
--> foo/src/bindings.rs:16577:21
|
16577 | ... windows_core::link!("urlmon.dll" "system" fn CreateIUriBuilder(piuri : * mut core::ffi::c_void, dwflags : u32, dwreserved : usize, ppiuribuilder : *mut * mut core::ffi::c_void) -> windows_core:...
| ^^^^^^^^^^^^ use of unresolved module or unlinked crate `windows_core`
Any advice is much appreciated for I am lost in limbo ...