Skip to content

build: curl now attempts to use Iphlpapi on Windows - #3934

Closed
compnerd wants to merge 1 commit into
curl:masterfrom
compnerd:iphlpapi
Closed

compnerd wants to merge 1 commit into
curl:masterfrom
compnerd:iphlpapi

Conversation

@compnerd

Copy link
Copy Markdown
Contributor

Link against Iphlpapi on Windows. This is needed for if_nametoindex
which is now used on Windows.

Link against Iphlpapi on Windows.  This is needed for `if_nametoindex`
which is now used on Windows.
@bagder bagder added build Windows Windows-specific labels May 23, 2019
@bagder

bagder commented May 23, 2019

Copy link
Copy Markdown
Member

This certainly proves we should have at least one winbuild done in the appveyor CI!

@captain-caveman2k

Copy link
Copy Markdown
Contributor

What about all the Visual Studio project files and cmake builds?

We might want to consider the following instead, in curl-win32.h, as we can conditionally include the library then:

    #define HAVE_IF_NAMETOINDEX 1
    #pragma comment(lib, "iphlpapi.lib")

@bagder

bagder commented May 24, 2019

Copy link
Copy Markdown
Member

What about all the Visual Studio project files and cmake builds?

The current appveyor builds are all done with cmake so we can be fairly sure they work... But yeah, Visual Studio project file builds would be good to verify as well! Is that doable from command line?

Now if only appveyor.yml wasn't such a weird yaml format! 😿 But I suppose with enough number of tries we should be able to get something going...

We might want to consider the following instead

I'll defer to your (plural) windows knowledge on what the best take on this is.

@MarcelRaad

Copy link
Copy Markdown
Member

The current appveyor builds are all done with cmake so we can be fairly sure they work... But yeah, Visual Studio project file builds would be good to verify as well! Is that doable from command line?

Yes, msbuild can be used directly. I can look into adding VS project file and winbuild jobs on the weekend. I only hope the yaml file won't get too complex when adding other build systems.

@captain-caveman2k

Copy link
Copy Markdown
Contributor

What are peoples' thoughts on using #pragma comment?

I've never used #pragma for this specifically but then I haven't needed to conditionally include lib files before.

The drawback to me of hard coding a library in a project, makefile, etc... means the build will break if it is compiled on a system that doesn't have that library, and there is no condition for including it.

So whilst we are trying to detect that the Iphlpapi header files exists I would try and avoid hardcoding a library in the project files for example, unless someone knows a way to do this conditionally?

@MarcelRaad

Copy link
Copy Markdown
Member

What are peoples' thoughts on using #pragma comment?
I've never used #pragma for this specifically but then I haven't needed to conditionally include lib files before.

I've used it and I like it. However, I don't know if all compilers supported by config-win32.h support #pragma comment(lib).

@gvanem

gvanem commented May 24, 2019

Copy link
Copy Markdown
Contributor

I've used it and I like it. However, I don't know if all compilers supported by config-win32.h
support #pragma comment(lib).

That is correct. But what about:

X = Curl_load_library(TEXT("iphlpapi.dll"));
...
Y = GetProcAddress(X, "if_nametoindex")));
...

@compnerd

Copy link
Copy Markdown
Contributor Author

I know that clang/clang-cl and obviously cl will support it. I believe that it is supported Microsoft, Borland, and the clang compilers.

@bagder

bagder commented May 25, 2019

Copy link
Copy Markdown
Member

Whatever solution, it'd be great to have a working fix landed like no later than Monday 27th so that we can have a patch release release (7.65.1) including this fix done on May 29th.

We can always polish and improve the fix after that release as well.

@MarcelRaad

Copy link
Copy Markdown
Member

Is there any compiler except MSVC and clang that can be used with the Visual Studio project files or Winbuild? If not, I'd lean towards the pragma in an #ifdef for these two compilers.

@compnerd

compnerd commented May 25, 2019 •

Copy link
Copy Markdown
Contributor Author

@MarcelRaad #3943 should adjust the Visual Studio projects for the iphlpapi dependency. For the Visual Studio projects, I think that clang-cl and cl are the only two free options, with icc being a paid option - however, Microsoft did recently add a clang toolset as part of Visual Studio 2019.1, which does make gcc like drivers possible (e.g. glxc) to add.

@captain-caveman2k

captain-caveman2k commented May 25, 2019 •

Copy link
Copy Markdown
Contributor

I know I suggested the #pragma but I would lean towards dynamically loading the library as we do for ws2_32.dll and secur32.dll rather than introduce another mechanism.

Alternatively we could move away from dynamically loading libraries?

@compnerd

Copy link
Copy Markdown
Contributor Author

@captain-caveman2k - hmm, the CMake and VS projects (as well as nmake) seem to indicate that they are just linked against the library rather than dynamically loaded at runtime?

@compnerd

Copy link
Copy Markdown
Contributor Author

I think that we can close this now that curl is using the dynamic lookup.

@compnerd compnerd closed this May 30, 2019
@compnerd
compnerd deleted the iphlpapi branch May 30, 2019 18:39
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

build Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

5 participants