1

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_
ayo
  • 57
  • 1
  • 8
  • 3
    1. do the libs really exist at that location? 2. Did you set the paths and files for all project configurations? e.g. release and debug? You may have set it for one project configuration but not the other, a common oversight when release is configured but debug is not – EdChum Oct 29 '19 at 09:58
  • Yes the libraries are there and I set all the paths indeed, for each debug and release on x64 and x86. Now I have changed the location of the libs, I am getting a LNK2001 error. I have updated the post already. – ayo Oct 29 '19 at 10:43
  • 2
    You're only supposed to add either the release or debug libs to each configuration, not both release and debug. So add release lib for release config, and debug lib for debug configuration – EdChum Oct 29 '19 at 10:47
  • Hi, I did what you have advised. It doesn't resolve the issue. I still have the LNK2001 error. – ayo Oct 29 '19 at 10:51
  • 1
    does it compile OK in release/debug or both fail? You need to look at your related error as your question has now moved on to a different issue. Also, it's going to be difficult for myself and others to help you without code to reproduce your error. You can add the flag `/VERBOSE' to your linker advanced options to get the full output from your linker to check if the paths, etc. are really correct – EdChum Oct 29 '19 at 10:56
  • I have shared the log file and the piece of code. As I see, the linker can't find the lib. Is that right? – ayo Oct 29 '19 at 11:16
  • 3
    You should add your lib-folder path to Linker -> General -> "Additional Library Directories" and not to the "Additional Include Directories". – Julian Oct 29 '19 at 11:22
  • 3
    You've added your lib path to your include path, your lib path is located under 'C/C++->Linker->General' under this page is an entry for 'Additional Library Directories' add your lib path to this – EdChum Oct 29 '19 at 11:22

3 Answers3

2

You need to specify the Additional Library Directories, in Linker properties, to set the directory where you have the lib file. You don't need to include the libs in Additional Dependencies because you are doing it in the lib header file #pragma comment( lib, "adtfstreamingD_290.lib" ) when you compile your app in debug or #pragma comment( lib, "adtfstreaming_290.lib" ) when you compile in release. But you need to specify where are these libs in Additional Library Directories.

If you see the lib include file, you see that if STREAMINGLIB_EXPORTS macro is defined all functions with DOEXPORT modifier are exported functions #define DOEXPORT __declspec( dllexport ). But if this macro is not defined #define DOEXPORT __declspec( dllimport ), the same functions are imported functions. It is because the dll needs to specify that this functions are exported functions, so in the dll code someone has defined this macro. Because in your code you have not (and you must not do) define this macro, this functions are imported functions.

SuperG280
  • 271
  • 3
  • 9
1

ADTF Streaming Library requires VS 2010 and is not compatible with other versions! So make sure to use it with v100 build tools. Or change to ADTF File Library a.k.a. IFHD, which is the v141 compatible successor and works with ADTF 2.x and ADTF 3.x as well. Note that the Lib comes completely open source licensed. See ADTF .dat trace file reader for some overview

C-3PFLO
  • 311
  • 2
  • 4
  • 1
    Thank you @C-3PFLO for the answer! The link you have provided contains a very old version of the library. – ayo Nov 05 '19 at 09:23
0

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.

ayo
  • 57
  • 1
  • 8