码迷,mamicode.com
首页 > 其他好文 > 详细

cmake中的zlib的设置方法----Target "xxxxx" links to target "ZLIB::ZLIB" but the target was not found

时间:2020-09-15 21:09:32      阅读:39      评论:0      收藏:0      [点我收藏+]

标签:sid   tgt   and   问题   err   strong   edr   exe   erro   

问题:
  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:\AwsOneDriver\aStudioLk\AeolusPterosaurPlat\AppNLP\CMakeLists.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.

 

 

 

 

 

cmake中的zlib的设置方法----Target "xxxxx" links to target "ZLIB::ZLIB" but the target was not found

标签:sid   tgt   and   问题   err   strong   edr   exe   erro   

原文地址:https://www.cnblogs.com/leoking01/p/13599939.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!