找不到 libNrrdIO link 库

Cannot find libNrrdIO link library

此问题是以下问题的延伸:

Tsyvarev 给出的解决方案适用于 lNrrdIO.a,从 NrrdIO 版本 1.9.0 编译,但是当我从 NrrdIO 版本 1.11.0 尝试同样的事情时,它生成了一个库 libNrrdIO.a。我对两者做了完全相同的事情,只是修改了 LINK_LIBRARIES 行中的 cmakelists.txt,将 NrrdIO 更改为 ibNrrdIO。但这给出了以下错误:

[  7%] Linking CXX executable ijkmcube
/usr/bin/ld: cannot find -libNrrdIO
collect2: error: ld returned 1 exit status
CMakeFiles/ijkmcube.dir/build.make:406: recipe for target 'ijkmcube' 
failed
make[2]: *** [ijkmcube] Error 1
CMakeFiles/Makefile2:131: recipe for target 
'CMakeFiles/ijkmcube.dir/all' failed
make[1]: *** [CMakeFiles/ijkmcube.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

CMakeLists.txt如下:

PROJECT(IJKMCUBE)    

#---------------------------------------------------------    

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)    

IF (NOT DEFINED ${IJK_DIR})
  GET_FILENAME_COMPONENT(IJK_ABSOLUTE_PATH "../.." ABSOLUTE)
  SET(IJK_DIR ${IJK_ABSOLUTE_PATH} CACHE PATH "IJK directory")
ENDIF (NOT DEFINED ${IJK_DIR})    

SET(CMAKE_INSTALL_PREFIX "${IJK_DIR}/")
SET(LIBRARY_OUTPUT_PATH ${IJK_DIR}/lib CACHE PATH "Library directory")
SET(IJKMCUBE_DIR "src/ijkmcube")
SET(NRRD_LIBDIR "${IJK_DIR}/lib")
SET(IJK_ISOTABLE_DIR "${IJK_DIR}/isotable" CACHE PATH "Isotable directory")    

#---------------------------------------------------------    

IF (NOT CMAKE_BUILD_TYPE)
  SET (CMAKE_BUILD_TYPE Release CACHE STRING 
       "Default build type: Release" FORCE)
ENDIF (NOT CMAKE_BUILD_TYPE)    

INCLUDE_DIRECTORIES("${IJK_DIR}/include")
LINK_DIRECTORIES("${NRRD_LIBDIR}")
LINK_LIBRARIES(expat ibNrrdIO z)
ADD_DEFINITIONS(-DIJK_ISOTABLE_DIR=\"${IJK_ISOTABLE_DIR}\")    

ADD_EXECUTABLE(ijkmcube ijkmcube_main.cxx ijkmcubeIO.cxx ijkmcube.cxx 
                        ijkmcube_datastruct.cxx ijkmcube_sub.cxx 
                        ijkmcube_extract.cxx ijkmcube_util.cxx ijksnapmc.cxx 
                        ijktable.cxx ijktable_poly.cxx ijktable_ambig.cxx
                        ijkoctree.cxx ijkxitIO.cxx)    

ADD_LIBRARY(ijkmcubeL STATIC EXCLUDE_FROM_ALL ijkmcubeIO.cxx ijkmcube.cxx ijkmcube_datastruct.cxx ijkmcube_sub.cxx ijkmcube_extract.cxx ijkmcube_util.cxx ijksnapmc.cxx ijktable.cxx ijkoctree.cxx ijkxitIO.cxx)
SET_TARGET_PROPERTIES(ijkmcubeL PROPERTIES OUTPUT_NAME ijkmcube)
ADD_CUSTOM_TARGET(lib DEPENDS ijkmcubeL)    

SET(CMAKE_INSTALL_PREFIX ${IJK_DIR})
INSTALL(TARGETS ijkmcube DESTINATION "bin/linux")    

ADD_CUSTOM_TARGET(tar WORKING_DIRECTORY ../.. COMMAND tar cvfh ${IJKMCUBE_DIR}/ijkmcube.tar ${IJKMCUBE_DIR}/README ${IJKMCUBE_DIR}/INSTALL ${IJKMCUBE_DIR}/RELEASE_NOTES ${IJKMCUBE_DIR}/*.cxx ${IJKMCUBE_DIR}/*.h ${IJKMCUBE_DIR}/*.txx ${IJKMCUBE_DIR}/CMakeLists.txt ${IJKMCUBE_DIR}/man/* ${IJKMCUBE_DIR}/ijkmcube_doxygen.config)    

ADD_CUSTOM_TARGET(doc COMMAND doxygen ijkmcube_doxygen.config)

有人可以帮助确定问题所在吗?是否可以让 cmake 搜索库 libNrrdIO.a?使用一些内置功能? 谢谢

问题终于解决了,在俄亥俄州立大学的Wenger博士的帮助下,他建议对NrrdIO 1.11.0版本的CMakeLists进行2次修改,将QNANHABIT值设置为1并取消注释行 ADD_DEFINITIONS(-DTEEM_ZLIB=1) 我附上了修改后的 CMakeLists 文件以供参考:

# NrrdIO: stand-alone code for basic nrrd functionality
# Copyright (C) 2011, 2010, 2009  University of Chicago
# Copyright (C) 2008, 2007, 2006, 2005  Gordon Kindlmann
# Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998  University of Utah
#
# This software is provided 'as-is', without any express or implied
# warranty.  In no event will the authors be held liable for any
# damages arising from the use of this software.
# 
# Permission is granted to anyone to use this software for any
# purpose, including commercial applications, and to alter it and
# redistribute it freely, subject to the following restrictions:
# 
# 1. The origin of this software must not be misrepresented; you must
#    not claim that you wrote the original software. If you use this
#    software in a product, an acknowledgment in the product
#    documentation would be appreciated but is not required.
#
#   2. Altered source versions must be plainly marked as such, and must
#    not be misrepresented as being the original software.
# 
# 3. This notice may not be removed or altered from any source distribution.
#    

CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
PROJECT(NrrdIO)
INCLUDE_REGULAR_EXPRESSION("^.*.h$")    

#
# This CMake file configures the NrrdIO library build.  NrrdIO
# is used by Insight/Code/IO/itkNrrdIO for reading/writing 
# "Nearly Raw Raster Data" within the open-source Teem software 
# package. See http://teem.sourceforge.net for more information.
#    

SET(nrrdio_SRCS comment.c enumsNrrd.c mop.c string.c 754.c defaultsNrrd.c
parseAir.c dio.c format.c parseNrrd.c formatEPS.c encoding.c
formatNRRD.c encodingAscii.c formatPNG.c encodingBzip2.c
formatPNM.c accessors.c encodingGzip.c formatText.c 
array.c encodingHex.c formatVTK.c read.c arraysNrrd.c encodingRaw.c 
gzio.c reorder.c write.c axis.c endianAir.c  keyvalue.c
biffbiff.c biffmsg.c endianNrrd.c methodsNrrd.c  sane.c enum.c
miscAir.c simple.c )    

# Turn on TEEM_BUILD so that the proper dll export def's are 
# used on windows builds.
ADD_DEFINITIONS(-DTEEM_BUILD=1)    

#The QNANHIBIT variable is configured by the root level CMakeLists.txt
IF(QNANHIBIT)
  ADD_DEFINITIONS(-DTEEM_QNANHIBIT=1)
ELSE(QNANHIBIT)
  ADD_DEFINITIONS(-DTEEM_QNANHIBIT=1)
ENDIF(QNANHIBIT)    

#DirectIO is the fast way to do multi-gigabyte I/O and currently only available
#for SGI platforms.  Use of DirectIO is enabled manually for now.
#OPTION(USE_DIRECTIO "Use DirectIO for Nrrd file IO.  Only valid on SGI systems." 0)
#MARK_AS_ADVANCED(USE_DIRECTIO)
#IF(USE_DIRECTIO)
#  ADD_DEFINITIONS(-DTEEM_DIO=1)
#ELSE(USE_DIRECTIO)
  ADD_DEFINITIONS(-DTEEM_DIO=0)
#ENDIF(USE_DIRECTIO)    

# Possibly turn on usage of zlib compression (requires linking with libz)
# (i.e., programs compiled with ITKNrrdIO must also be compiled with zlib)
ADD_DEFINITIONS(-DTEEM_ZLIB=1)    

ADD_LIBRARY(NrrdIO ${nrrdio_SRCS} )    

## These are ITK-specific
#TARGET_LINK_LIBRARIES(NrrdIO ${ITK_ZLIB_LIBRARIES} )
#INSTALL_TARGETS(/lib/InsightToolkit ITKNrrdIO)
#INSTALL_FILES(/include/InsightToolkit/Utilities/NrrdIO "(\.h)$")