Solved

Win CE GetIpAddrTable() Linker error

Posted on 2003-11-11
6
1,082 Views
Last Modified: 2007-12-19
Hi People,

I’m currently developing an Application in Embedded Visual C++ using API not MFC, for a pocket PC which is running Windows CE 3.0.

I’m trying to retrieve the Subnet mask from the pocket PCs network card.

I used the function GetIpAddrTable(), which is OK when I compile, but when I try to build the application I get the following LINKER errors

Linking...
   
Creating library MIPSRel/MTool.lib and object MIPSRel/MTool.exp
ScanNetwork.obj : error LNK2019: unresolved external symbol GetIpAddrTable referenced in function "int __cdecl scanNetworkNow(struct HWND__ *,char (* const)[512])" (?scanNetworkNow@@YAHPAUHWND__@@QAY0CAA@D@Z)

MIPSRel/MTool.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

MTool.dll - 2 error(s), 0 warning(s)

I have included the library file iphlpapi.lib in my project setting and have included the iphlpapi.h header file in my source code.

I have listed my source below:

char *  szTotResult;
char data[sizeof(MIB_IPADDRTABLE) + 32 * sizeof(MIB_IPADDRROW)];
ULONG len = sizeof(data);
IN_ADDR  inAddr;
PMIB_IPADDRTABLE ipAddr;
int ind;

// Find all interfaces
if(GetIpAddrTable((PMIB_IPADDRTABLE)data, &len, true ) == NO_ERROR)
{
             ipAddr = (PMIB_IPADDRTABLE)data;
      for(ind = 0; ind < (int)ipAddr->dwNumEntries; ind++)
      {
            if(ipAddr->table[ind].dwAddr != 0)
            {
                  // combind Addr and Sub net mask
                                      UINT bCast = ipAddr->table [ind].dwAddr  | ~ipAddr-table[ind].dwMask;

            inAddr.S_un.S_addr = bCast;
            szTotResult = inet_ntoa (inAddr);
            }
      }
}


Can any one help me please ? I have try the same soruce code in Visual C++ and it all works fine.

0
Comment
Question by:LPlate
6 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 9721650
When you say:

"I have included the library file iphlpapi.lib in my project setting"

what EXACTLY does that mean?  I think you have NOT included iphlpapi.lib in your LINKER input files.

Go to your PROJECT SETTINGS and the LINK tab there and add "iphlpapi.lib" to the "Object/libary modules" edit box there for ALL of your configurations.
0
 

Author Comment

by:LPlate
ID: 9721784
I have included iphlpapi.lib in my PROJECT SETTINGS -> LINK
0
 
LVL 32

Accepted Solution

by:
jhance earned 250 total points
ID: 9721786
For ALL your configurations?
0
 
LVL 86

Expert Comment

by:jkr
ID: 9722121
Or, alternatively, specify

#pragma comment ( lib, "iphlpapi.lib")

in one of your header files.
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10248955
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: jhance {http:#9721786}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question