zoukankan      html  css  js  c++  java
  • cmake中的zlib的设置方法----Target "xxxxx" links to target "ZLIB::ZLIB" but the target was not found

    问题:
      AUTOGEN: No valid Qt version found for target opencv_opencl.  AUTOMOC,
      AUTOUIC and AUTORCC disabled.  Consider adding:
    
        find_package(Qt<QTVERSION> COMPONENTS Widgets)
    
      to your CMakeLists.txt file.
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    CMake Error at AppNLP/CMakeLists.txt:255 (add_executable):
      Target "xxxxxxx" links to target "ZLIB::ZLIB" but the target was not
      found.  Perhaps a find_package() call is missing for an IMPORTED target, or
      an ALIAS target is missing?
    
    
    Generating done
    CMake Warning:
      Manually-specified variables were not used by the project:
    
        QT_QMAKE_EXECUTABLE
    
    
    CMake Project parsing failed.
    D:AwsOneDriveraStudioLkAeolusPterosaurPlatAppNLPCMakeLists.txt:255: error: Target "appNLP_my" links to target "ZLIB::ZLIB" 
    but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?
    :-1: error: Failed to compute build system.

    当前的makefile写法:

    find_package(ZLIB )
    include_directories( "D:/win10/aspDep/zlib1211/x64/include")
    link_directories( "D:/win10/aspDep/zlib1211/x64/lib")
    ADD_DEFINITIONS (${ZLIB_DEFINITIONS})

    问题的解决办法:

    set( ZLIB_ROOT    "D:/win10/aspDep/zlib1211/x64" )
    find_package(ZLIB )
    include_directories( "D:/win10/aspDep/zlib1211/x64/include")
    link_directories( "D:/win10/aspDep/zlib1211/x64/lib")
    ADD_DEFINITIONS (${ZLIB_DEFINITIONS})

    是的,只需要加一行代码即可。

    问题总结:

    出现这个问题的原因不是由于protobuf库是否静态库,也不是由于zlib库是否静态库,而仅仅是因为没有找到zlib的根目录,由此导致找不到zlib的一些定义。

    附官网资料:

    官网说明:https://cmake.org/cmake/help/latest/module/FindZLIB.html

    FindZLIB

    Find the native ZLIB includes and library.

    IMPORTED Targets

    This module defines IMPORTED target ZLIB::ZLIB, if ZLIB has been found.

    Result Variables

    This module defines the following variables:

    ZLIB_INCLUDE_DIRS   - where to find zlib.h, etc.
    ZLIB_LIBRARIES      - List of libraries when using zlib.
    ZLIB_FOUND          - True if zlib found.
    
    ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
    ZLIB_VERSION_MAJOR  - The major version of zlib
    ZLIB_VERSION_MINOR  - The minor version of zlib
    ZLIB_VERSION_PATCH  - The patch version of zlib
    ZLIB_VERSION_TWEAK  - The tweak version of zlib
    

    Backward Compatibility

    The following variable are provided for backward compatibility

    ZLIB_MAJOR_VERSION  - The major version of zlib
    ZLIB_MINOR_VERSION  - The minor version of zlib
    ZLIB_PATCH_VERSION  - The patch version of zlib
    

    Hints

    A user may set ZLIB_ROOT to a zlib installation root to tell this module where to look.

  • 相关阅读:
    常用作图与图片处理工具
    在博客园中配置MathJax
    Make Eudict for reviewing example sentences
    使用AltSearch格式化Kindle读书笔记
    Deep Learning基础--理解LSTM/RNN中的Attention机制
    Deep Learning基础--理解LSTM网络
    Deep Learning基础--SVD奇异值分解
    常见面试之机器学习算法思想简单梳理
    Deep Learning基础--CNN的反向求导及练习
    Deep Learning基础--线性解码器、卷积、池化
  • 原文地址:https://www.cnblogs.com/leoking01/p/13599939.html
Copyright © 2011-2022 走看看