使用VS17上的LINK1181链接库失败

问题描述 投票:1回答:2

我正在尝试在我的项目中使用ADTF流库。当我包含lib时,出现LNK1181错误。该库带有标头,lib文件和dll文件。

我已经在C / C ++中添加了路径->常规->其他包含目录。

enter image description here

此外,我已经在链接器中添加了库->输入->其他依赖项。

enter image description here

这里也是错误屏幕截图。

enter image description here

Update:我将dll和libs的位置更改为我的项目路径,并再次包含它。它现在没有抱怨lib本身。现在我收到一个错误LNK2001。我相信这也是一个链接器错误。

enter image description here

这里一切都出错了!

enter image description here

更新2:我看到了构建的完整日志。我认为这似乎表明,链接器找不到我的库。是吗?

enter image description here

主要应用代码如下:

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

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

}

并且试图读取/导入我的库的头文件是

#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_
c++ visual-studio-2017 libraries visual-studio-2017-build-tools adtf
2个回答
1
投票

您需要在链接器属性中指定其他库目录,以设置具有lib文件的目录。您不需要在其他依赖项中包含这些库,因为在调试中编译应用程序时,它们是在库头文件#pragma comment( lib, "adtfstreamingD_290.lib" )中进行的;而在发行版中则是在#pragma comment( lib, "adtfstreaming_290.lib" )中进行此操作的。但是您需要在“其他库目录”中指定这些库在哪里。

如果看到lib包含文件,则会看到,如果定义了STREAMINGLIB_EXPORTS宏,则所有带有DOEXPORT修饰符的函数都是导出的函数#define DOEXPORT __declspec( dllexport )。但是,如果未定义此宏#define DOEXPORT __declspec( dllimport ),则将相同的功能导入。这是因为dll需要指定此函数为导出函数,因此有人在dll代码中定义了此宏。因为在您的代码中您没有(也不必这样做)定义此宏,所以此函数是导入的函数。


0
投票

ADTF流库需要VS 2010,并且与其他版本不兼容!因此,请确保将其与v100构建工具一起使用。或更改为IFHD的ADTF文件库,也称为IFHD,它是v141兼容的后继产品,并且也可以与ADTF 2.x和ADTF 3.x一起使用。请注意,Lib完全开源。有关概述,请参见ADTF .dat trace file reader。>

© www.soinside.com 2019 - 2024. All rights reserved.