Search code examples
c++visual-studio-2017librariesvisual-studio-2017-build-toolsadtf

Linking a library fails with LINK1181 on VS17


I am trying to use the ADTF streaming library in my project. When I am including the lib, I get the LNK1181 error. The library comes with the headers, the lib files and dll files.

I have added the path inside the C/C++ -> General -> Additional Include Directories.

enter image description here

In addition, I have added the library inside the Linker -> Input -> Additional Dependencies.

enter image description here

Here is also the error screenshot.

enter image description here

Update: I have changed the location of the dll and the libs to my project path and include it again. It does not complain now about the lib itself. Now I am getting an error LNK2001. I believe it is also a linker error.

enter image description here

And here where it all goes wrong!

enter image description here

Update 2: After I see the full log of the build. This appears, I think this means, the linker can't find my lib. Is that right?

enter image description here

The main application code is as this:

#include "pch.h"
#include <iostream>
#include "adtf_streaming.h"
using namespace adtfstreaming;

int main()
{
    std::cout << "Hello World!\n"; 
    IADTFFileReader *pFileReader = IADTFFileReader::Create();

}

and the header file which is trying to read/ import my lib is

#ifndef _ADTF_STREAMING_LIBRARY_DLL_ 
#define _ADTF_STREAMING_LIBRARY_DLL_

#ifdef WIN32
    #ifdef STREAMINGLIB_EXPORTS
        #pragma message ("Create ADTF Streaming Library ")
        // export symbols
        #define DOEXPORT __declspec( dllexport )
    #else
        #pragma message ("Use dynamic ADTF Streaming Library ")
        #ifdef _DEBUG
            #pragma comment( lib, "adtfstreamingD_290.lib" )
        #else
            #pragma comment( lib, "adtfstreaming_290.lib" )
        #endif

        #define DOEXPORT __declspec( dllimport )
    #endif
#else
    #ifdef STREAMINGLIB_EXPORTS
        #define DOEXPORT __attribute__ ((visibility("default")))
    #else
        #pragma comment( lib, "adtfstreaming_290.lib" )
        #define DOEXPORT __declspec( dllimport )
    #endif
#endif

//standard includes 
#include <stdlib.h>
#include <string.h>

//adtf base types and errors
#include "adtf_base_ref.h"

//streaming lib version
#include "adtf_streaming_version.h"

//adtf streaming lib package headers
#include "adtf_streaming_pkg.h"

#endif //_ADTF_STREAMING_LIBRARY_DLL_

Solution

  • I found the answer to the problem. Well, a combination of problems.

    The library was built to support 0x86 machines only. I have built it again to support 0x64 and it worked.

    P.S. It worked on Visual Studio 2017 too, unfortunately the documentation is poor and lacks information.