0

i have a probleme when i try to build this tapi3 c++ example using mingGw w64 compiler in eclipse, i have followed the ewample from msdn step by step

#include <iostream>
#include <tapi3.h>

using namespace std;

int main() {
    // Initialize COM.
    HRESULT hr = CoInitializeEx(
    NULL, COINIT_MULTITHREADED);
    if (hr != S_OK)
        cout << "CoInitializeEx Failed !!!" << endl;

    // Create a TAPI entry point object.
    ITTAPI *gpTapi;    // globally allocated
    hr = CoCreateInstance(CLSID_TAPI, NULL, CLSCTX_INPROC_SERVER, IID_ITTAPI,
        (LPVOID *) &gpTapi);
    if (hr != S_OK)
        cout << "CoCreateInstance Failed !!!" << endl;

    // Initialize TAPI.
    hr = gpTapi->Initialize();
    if (hr != S_OK)
        cout << "gpTapi->Initialize() Failed !!!" << endl;

    // Declare the interfaces used to select an address.
    IEnumAddress * pIEnumAddress;
    ITAddress * pAddress;
    ITMediaSupport * pMediaSupport;
    VARIANT_BOOL bSupport;

    // Use the TAPI object to enumerate available addresses.
    hr = gpTapi->EnumerateAddresses(&pIEnumAddress);
    // If (hr != S_OK) process the error here.

    // Locate an address that can support the media type the application needs.
    while ( S_OK == pIEnumAddress->Next(1, &pAddress, NULL)) {
        // Determine the media support.
        hr = pAddress->QueryInterface(IID_ITMediaSupport,
            (void **) &pMediaSupport);
        if (hr != S_OK)
        cout << "pAddress->QueryInterface() Failed !!!" << endl;

        // In this example, the required media type is already known.
        // The application can also use the address object to
        // enumerate the media supported, then choose from there.
        hr = pMediaSupport->QueryMediaType(TAPIMEDIATYPE_AUDIO | TAPIMEDIATYPE_VIDEO, &bSupport);
        if (hr != S_OK)
            cout << "pMediaSupport->QueryMediaType() Failed !!!" << endl;

        if (bSupport) {
            break;
        }
    }
    // pAddress is now a usable address.

    return 0;
}

I have aded the lib ole32 and old32 but when i build this example it return this eror evry time but when i compil using visual c++ it work

 src\main.o:main.cpp (.rdata$.refptr.IID_ITMediaSupport[.refptr.IID_ITMediaSupport]+0x0): undefined reference to `IID_ITMediaSupport'
src\main.o:main.cpp:(.rdata$.refptr.CLSID_TAPI[.refptr.CLSID_TAPI]+0x0): undefined reference to `CLSID_TAPI'
src\main.o:main.cpp:(.rdata$.refptr.IID_ITTAPI[.refptr.IID_ITTAPI]+0x0): undefined reference to `IID_ITTAPI'
collect2.exe: error: ld returned 1 exit status

please can you help me to solve this, sorry for my english

user820688
  • 719
  • 2
  • 13
  • 27

1 Answers1

-1

Make sure to have these lib files added:

version.lib ole32.lib oleaut32.lib uuid.lib

(source: http://microsoft.public.win32.programmer.tapi.narkive.com/e4h0yQcj/com-and-tapi-initialize-error)

CLSID_TAPI and IID_ITMediaSupport are external symbols therefore the libs are needed. IID_ITTAPI is known, and could also be added directly as a header declaration, like so:

const IID IID_ITTAPI = {0xB1EFC382,0x9355,0x11d0,{0x83,0x5C,0x00,0xAA,0x00,0x3C,0xCA,0xBD}};
Cee McSharpface
  • 8,493
  • 3
  • 36
  • 77
  • I have no probleme when i build using visual studio c++, i have probleme when traying to build using migw w64 g++ builder – user820688 Jan 18 '16 at 10:47
  • aware of that. does your library search path include the directory where uuid.lib resides? any libraries added with the -L switch? – Cee McSharpface Jan 18 '16 at 11:10
  • [this](http://stackoverflow.com/questions/27429055/mingw-w64-compilation-errors-in-libraries?rq=1) might apply: make sure you don't have both include and library directories of 32 and 64 in path at the same time – Cee McSharpface Jan 18 '16 at 11:40
  • The config is ok, the compiler find the libs but i alleready have error any idea? – user820688 Jan 18 '16 at 16:27
  • When i use VSC++ lib i have d:/MinGW/mingw64/x86_64-5.3.0-win32-sjlj/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib/version.lib when searching for -lversion – user820688 Jan 18 '16 at 16:48
  • according to [this link](http://www.mingw.org/wiki/the_linker_consistently_giving_undefined_references), the libraries must be specified to the mingw compiler in order of their dependency. try adding -luuid to your command line and see if at least the CLSID_TAPI disappears. – Cee McSharpface Jan 19 '16 at 11:01