Solved

Win CE GetIpAddrTable() Linker error

Posted on 2003-11-11
6
1,085 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

828 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