• 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.

  • 相关阅读:
    eureka 注册中心(单机版)
    金蝶实际成本培训01
    查看WIN10内核
    金蝶K3 WISE 15.0 GUID
    win10卸载系统自带office365
    金蝶K3wise15.0BOM维护默认只能查看登录账户作为建立人的BOM清单
    阿里云邮箱代收邮件
    金蝶寄售业务流程
    转-商品流通企业代销商品核算方法
    转-ERP待检仓、代管仓、赠品仓
  • 原文地址:https://www.cnblogs.com/leoking01/p/13599939.html
Copyright © 2020-2023  润新知