undefined reference to CLSID_ConnectionManager & IID_INetConnectionManager

This is a discussion on undefined reference to CLSID_ConnectionManager & IID_INetConnectionManager within the Windows Programming forums, part of the Platform Specific Boards category; Hi all, I am trying to build a simple application that consist of a function that disable and enable connection.I ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    4

    undefined reference to CLSID_ConnectionManager & IID_INetConnectionManager

    Hi all,

    I am trying to build a simple application that consist of a function that disable and enable connection.I am using Qtcreator to code.with mingw.I've found some online code which I've used for understanding and to test if it works in Qt:

    Code:
    #include <windows.h>
    #include <iphlpapi.h>    
    #include <objbase.h>
    #include <netcon.h>     
    #include <stdio.h>
    #include <iostream>
    #include <stdlib.h>
    #include <string.h> 
    ...
    ...
    bool EnableConnection(LPCWSTR wszName, bool bEnable)
    {
        bool result = false;
    
        typedef void (__stdcall * LPNcFreeNetconProperties)(NETCON_PROPERTIES* pProps);
    
        HMODULE hmod = LoadLibraryA("netshell.dll");
    
        if (!hmod) 
            return false; 
    
        LPNcFreeNetconProperties NcFreeNetconProperties = (LPNcFreeNetconProperties)GetProcAddress(hmod, "NcFreeNetconProperties"); 
    
        if (!NcFreeNetconProperties ) 
            return false;  
    
        INetConnectionManager * pMan = 0; 
    
        HRESULT hres = CoCreateInstance(CLSID_ConnectionManager, 
                                        0, 
                                        CLSCTX_ALL, 
                                        __uuidof(INetConnectionManager), 
                                        (void**)&pMan); 
    
        if (SUCCEEDED(hres)) 
        { 
            IEnumNetConnection * pEnum = 0;  
    
            hres = pMan->EnumConnections(NCME_DEFAULT, &pEnum); 
    
            if (SUCCEEDED(hres)) 
            { 
    
                INetConnection * pCon = 0; 
                ULONG count; 
                bool done = false; 
                while (pEnum->Next(1, &pCon, &count) == S_OK && !done) 
                { 
                    NETCON_PROPERTIES * pProps = 0; 
                    hres = pCon->GetProperties(&pProps); 
    
                    if (SUCCEEDED(hres)) 
                    { 
                        if (wcscmp(pProps->pszwName,wszName) == 0) 
                        { 
                            if (bEnable) 
                                result = (pCon->Connect() == S_OK); 
                            else 
                                result = (pCon->Disconnect() == S_OK); 
    
                            done = true; 
                        } 
                        NcFreeNetconProperties(pProps);
                    } 
                    pCon->Release(); 
                } 
                pEnum->Release(); 
            } 
            pMan->Release(); 
        }  
        FreeLibrary(hmod); 
        return result; 
    
    }
    fyi,
    I have tried to link them up with these:
    Code:
    win32:LIBS += -Lc:/Path/Lib  -liphlpapi -lole32 -lnetshell
    win32:INCLUDEPATH += c:/Path/Include
    My Lib folder contains:
    libiphlpapi.a
    libole32.a
    netshell.dll

    My Include folder contains:
    netcon.h (found this file online)

    However when i tried to build my application i get errors like:
    1. undefined reference to CLSID_ConnectionManager or IID_INetConnectionManager and
    2. __uuidof not declared.
    3. and I think there is something wrong with the statement for __stdcall

    Is there anything I've missed here???

    I am new to programming in windows and have been unable to find any solution for this.Have encountered several errors like this already...How can I include all the dependent files and libs once and for all?I am unable to use visual studio although I have Visual C++ 08 installed because it is a requirement for me to use Qt in this project.

    Will appreciate any valuable advice.
    Thanks in advanced.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4
    noone knows what the problem is?

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    You need to install the platform SDK. The compiler and the basic Windows headers aren't enough.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    tjb
    tjb is offline
    Registered User
    Join Date
    Jan 2009
    Posts
    31
    Quote Originally Posted by remy06 View Post
    1. undefined reference to CLSID_ConnectionManager or IID_INetConnectionManager and
    Well, you could possibly get around not having the SDK by manually defining these. Most GUID's are defined in libuuid.a in MinGW, but since those headers aren't from the mingw win32api, they wouldn't be defined there. You'd have to find the values for these through a bit of research.

    2. __uuidof not declared.
    That keyword is only supported by MSVC. You'll need to replace __uuidof(INetConnectionManager) with &IID_INetConnectionManager.

    3. and I think there is something wrong with the statement for __stdcall
    For GCC, I believe the __stdcall needs to be outside of the parenthesis, while MSVC requires it to be inside.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 12:45 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 05:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21