Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HELP - statically link to Iphlpapi.lib?

366 views
Skip to first unread message

Adam Guy

unread,
Sep 25, 2004, 8:47:14 PM9/25/04
to
Hi,

I have a project that uses GetAdaptersInfo() inside Iphlpapi.lib.

The project includes Iphlpapi.lib, and includes Iphlpapi.h for the
definition. On my development system of course it works fine.

Yet - It will not statically link to the library because when I go to run it
on an NT system, (which doesn't include the iphlpapi.dll), I get an
unresolved external.

Is there no way to statically link to this library? or am I doing something
wrong?

Please Help

BCB6 patched.

TIA.
Adam.


Liz Albin

unread,
Sep 25, 2004, 8:46:23 PM9/25/04
to
On Sat, 25 Sep 2004 17:47:14 -0700, Adam Guy wrote:

> Is there no way to statically link to this library? or am I doing something
> wrong?

have you tried
Project | options | linker undcheck Use dynamic RTL
Project | options | packages uncheck Build with runtime packages
--
Good luck,

liz

Liz Albin

unread,
Sep 25, 2004, 9:19:49 PM9/25/04
to
On Sat, 25 Sep 2004 18:20:25 -0700, Adam Guy wrote:

> Yes - these options are set correctly.

The point is that you need to uncheck those to build a standalone EXE
(and you need to rebuild completely). If you're still attempting to
load in DLLs then perhaps you should rebuild all.

Otherwise, you'll have to create an installation that includes the
DLLs your EXE needs.
--
Good luck,

liz

Adam Guy

unread,
Sep 25, 2004, 9:56:57 PM9/25/04
to

"Liz Albin" <liza...@yahooNotThis.com> wrote

> > Yes - these options are set correctly.
>
> The point is that you need to uncheck those to build a standalone EXE
> (and you need to rebuild completely). If you're still attempting to
> load in DLLs then perhaps you should rebuild all.

I understand you point, I already knew this, and - as I explained in my last
email these options (of course) do not affect this problem. I still require
the dll.

To prove my point, try this:

Create a new blank app, add a button, add an event handler for its click,
add the code:

IP_ADAPTER_INFO AdapterInfo[16];
DWORD dwBufLen = sizeof(AdapterInfo);
DWORD dwStatus = GetAdaptersInfo( AdapterInfo, &dwBufLen);

At the top of the unit include the headers:

#include "Iptypes.h"
#include "Iphlpapi.h"

Add the LIB to the app, (project, add to project) the Iphlpapi.lib. This
file is located in $(BCB)\Lib\Psdk.

Project Options - UNCHECK Dynamic RTL, UNCHECK runtime packages. (not that
it matters here)

Build all.

Now - have a look at the EXE in dependency walker - just like I said - It
dynamically links to Iphlapai.dll! If you don't believe it - temporarily
rename your Iphlpapi.dll and try to run it.

If anyone can help me please.

Adam.


Liz Albin

unread,
Sep 25, 2004, 10:27:40 PM9/25/04
to
On Sat, 25 Sep 2004 18:56:57 -0700, Adam Guy wrote:

> To prove my point, try this:
>
> Create a new blank app, add a button, add an event handler for its click,
> add the code:

Just curiously, why don't you have the DLL in system32 ? (that's
where I've seen it)
--
Good luck,

liz

Adam Guy

unread,
Sep 25, 2004, 10:47:27 PM9/25/04
to

"Liz Albin" <liza...@yahooNotThis.com> wrote

> Just curiously, why don't you have the DLL in system32 ? (that's
> where I've seen it)

The DLL *is* inside System32 - the import library (.lib) is in the lib\psdk
folder.

A.


Torsten Franz

unread,
Sep 27, 2004, 6:51:21 AM9/27/04
to
Hi,

> The project includes Iphlpapi.lib, and includes Iphlpapi.h for the
> definition. On my development system of course it works fine.
>
> Yet - It will not statically link to the library because when I go to
> run it
> on an NT system, (which doesn't include the iphlpapi.dll), I get an
> unresolved external.
>
> Is there no way to statically link to this library? or am I doing
> something
> wrong?

No you can't. This DLL is a system Microsoft DLL for which you
don't have the code (either source or precompiled as a .lib).
So the provided lib is just an import library.

If you have to distribute your app to an OS that doesn't
provide the DLL you have several choices

1. Provide the DLL along with your installation. This may be forbidden
by the creator of the DLL (Microsoft)

2. Don't use the import library but load the DLL at runtime and check
for the required function (LoadLibrary -> GetProcAddress -> FreeLibrary)
and use workarounds for systems where the DLL isn't available.

Torsten

0 new messages