static library imports static library

Hi,

I created a static library looking like this

#pragma once

#include "wininet.h"
#include "iphlpapi.h"
#include "ras.h"

class cNetInfo
{
public:
     cNetInfo(void);
     ~cNetInfo(void);

     bool IsConnected();
     bool IsLANConnected();

     int GetNumberOfAdapters(void);
     int GetNumberOfHWInterfaces(void);
     CString GetAdapterType(int nAdapter);
     CString GetAdapterIPAdress(int nAdapter);
     
     int GetInterfaceNumber(int nInterface);
     int GetInterfaceType(int nInterface);
     CString GetInterfaceName(int nInterface);

     unsigned long GetInterfaceDownUtilization(int nInterface);

private:
     char* pszAIBuffer; //AdapterInfoBuffer
     char* pszIFTBuffer; //IFTable Buffer
     PIP_ADAPTER_INFO pAdapterInfo; //enthält ALLE Adapter mit Name, Type, IP, Subnet, Gateway...
     PMIB_IFTABLE pIFTable;
     PMIB_IFROW pIFRow;
     unsigned long nBuffSize;

     void AdaptersInfo(void);
     void IFTableInfo(void);

     bool GetInterfaceInformation(int nInterface);

     struct InterfaceInfoEx
     {
          int nNumber;
          int nType;
          char* szName;
          int nNameLen;
          unsigned long nSpeed;
          unsigned long BytesReceived;
          unsigned long BytesSent;

     }InterfaceInfo;

};

the only problem now is, that I get this error:
netspeed error LNK2019: unresolved external symbol _GetAdaptersInfo@8 referenced in function "private: void __thiscall cNetInfo::AdaptersInfo(void)" (?AdaptersInfo@cNetInfo@@AAEXXZ)

when I try "cNetInfo cNi;" in my main-prog.

The function AdaptersInfo() is called by the Constructor

void cNetInfo::AdaptersInfo(void)
{
     unsigned long nRetCode = -1;

     nRetCode = GetAdaptersInfo(pAdapterInfo,&nBuffSize);
     while (nRetCode != NO_ERROR)
     {
          pszAIBuffer = new char[nBuffSize];
          pAdapterInfo = (PIP_ADAPTER_INFO)pszAIBuffer;
          nRetCode = GetAdaptersInfo(pAdapterInfo,&nBuffSize);
          delete [] pszAIBuffer;
     }
     
     nBuffSize = 0;
}

The Problem is the GetAdaptersInfo(pAdapter....) call.

Plz help
YnoCAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

codez80Commented:
ok,

first things first,
are u linking your app (or DLL) to that library (.lib file)?

second:
make sure that you have implemented that function in a cpp file.


codez80
0
YnoCAuthor Commented:
I added the .lib to the main-app-project, sorry 4 holding back that information :)
Then I added the .h to my project.

The function is implemented in a cpp file.
The Class itself compiles without error.

in the main-app-project i try to initialize the class using this code

cNetInfo* cNI = new cNetInfo();
0
codez80Commented:
you have not defined:
void cNetInfo::AdaptersInfo(void)
{
}

in your cpp file!

check again,

codez80
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

YnoCAuthor Commented:
void cNetInfo::AdaptersInfo(void)
{
    unsigned long nRetCode = -1;

    nRetCode = GetAdaptersInfo(pAdapterInfo,&nBuffSize);
    while (nRetCode != NO_ERROR)
    {
         pszAIBuffer = new char[nBuffSize];
         pAdapterInfo = (PIP_ADAPTER_INFO)pszAIBuffer;
         nRetCode = GetAdaptersInfo(pAdapterInfo,&nBuffSize);
         delete [] pszAIBuffer;
    }
   
    nBuffSize = 0;
}

thats the definition... It is defined.
0
codez80Commented:
GOT IT!!!

u need to link your application or dll (not the static library) to "Iphlpapi.lib".

good luck

codez80
0
YnoCAuthor Commented:
I tried it before.

Do you mean I should add the include "iphlpapi.h" to the main-prog or my cNetInfo class?
The cNetInfo Class already includes the iphlpapi.h
0
YnoCAuthor Commented:
I tried it before.

Do you mean I should add the include "iphlpapi.h" to the main-prog or my cNetInfo class?
The cNetInfo Class already includes the iphlpapi.h
0
codez80Commented:
no, you need to link to the import library
"iphlpapi.lib" (look at the extension)

if you are using VC++ go to link tab and add the library to the objects/modules list,

if not choose a cpp file and add this to it (make sure you do this to a cpp file)
#pragma comment(linker, "iphlpapi.lib")

codez80

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
YnoCAuthor Commented:
i added all the other 2 libraries - the iphlpapi.lib not

sometimes you don't see the obvious.

thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.