Skip to content
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

Link error with CompareObjectHandles #781

Open
jdm opened this issue Jul 3, 2019 · 5 comments
Open

Link error with CompareObjectHandles #781

jdm opened this issue Jul 3, 2019 · 5 comments
Labels
blocked by rust Blocked on a feature being implemented or bug being fixed in Rust

Comments

@jdm
Copy link
Contributor

jdm commented Jul 3, 2019

Using winapi::um::handleapi::CompareObjectHandles causes a link error to appear:

 = note: lld-link: error: undefined symbol: CompareObjectHandles
          >>> referenced by C:\git-mozilla\servo_ipc-channel\ipc-channel\src\platform\windows\mod.rs:349
          >>>               C:\git-mozilla\servo_ipc-channel\ipc-channel\target\debug\deps\ipc_channel-d21c39ad54b8c1b9.grgdvyw18xi6bb.rcgu.o:(_ZN82_$LT$ipc_channel..platform..windows..WinHandle$u20$as$u20$core..cmp..PartialEq$GT$2eq17h4f6b02f15a66ad57E)

I suspect this is because it's provided from kernelbase.lib instead of kernel32.lib, per https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-compareobjecthandles.

@angelortiz1007
Copy link

A potential fix has been identified.

According to Microsoft, the CompareObjectHandles () api is included in the WindowsApp.lib library. See:

https://docs.microsoft.com/en-us/uwp/win32-and-com/win32-apis

Based on this, I modified winapi-rs version 3's mod.rs file. I searched for handleapi feature and found that the library being used was kernel32. I changed it to WindowsApp" and my unresolved issue went away.

  • ("handleapi", &["minwindef", "winnt"], &["kernel32"]),
  • ("handleapi", &["minwindef", "winnt"], &["WindowsApp"]),

Note, there are many references to other APS using kernel32. These other APIs should be checked to see if the same change in their respective feature is required.

@retep998
Copy link
Owner

retep998 commented Jul 5, 2019

WindowsApp has a very significant effect on which dll a given symbol comes from and can affect the program's ability to run on older versions of windows. I'll have to verify what is actually affected before merging a PR for this.

@Xanewok
Copy link

Xanewok commented Jul 15, 2019

Can we somehow conditionally compile the definition at https://docs.rs/winapi/0.3.7/src/winapi/um/handleapi.rs.html#23-26? Is there some mechanism already in the crate here to conditionally compile the newer parts of some previously-available interface?

@retep998
Copy link
Owner

retep998 commented Jul 17, 2019

@Xanewok Extern functions are not linked to unless used, so there is no need to have conditional compilation in winapi based on the targeted Windows version. If nothing uses CompareObjectHandles then no linker errors can occur involving it.

@angelortiz1007
Copy link

angelortiz1007 commented Jul 17, 2019 via email

@retep998 retep998 added blocked by rust Blocked on a feature being implemented or bug being fixed in Rust wontfix This issue won't or can't be fixed and removed wontfix This issue won't or can't be fixed labels Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by rust Blocked on a feature being implemented or bug being fixed in Rust
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants