gpt4 book ai didi

windows - CMake 在 Windows 上找不到库

转载 作者:可可西里 更新时间:2023-11-01 10:34:57 24 4
gpt4 key购买 nike

我有这个 CMake 脚本来查找库:

#  FANN_FOUND - system has fann
# FANN_INCLUDE_DIRS - the fann include directory
# FANN_LIBRARIES - Link these to use fann
# FANN_DEFINITIONS - Compiler switches required for using fann
if(FANN_LIBRARIES AND FANN_INCLUDE_DIRS)
set(FANN_FOUND TRUE)
else()

find_path(FANN_INCLUDE_DIR NAMES fann.h PATHS ${CMAKE_CURRENT_SOURCE_DIR}/FANN/include)
set( _libraries doublefann fixedfann floatfann )

foreach( _lib ${_libraries} )
string( TOUPPER ${_lib} _name )
find_library(${_name}_LIBRARY NAMES ${_lib} PATHS "${CMAKE_CURRENT_SOURCE_DIR}/FANN/lib")
endforeach()

set(FANN_INCLUDE_DIRS ${FANN_INCLUDE_DIR})
message("${FANN_INCLUDE_DIR}")
set(FANN_LIBRARIES ${FANN_LIBRARIES} ${DOUBLEFANN_LIBRARY}
${FIXEDFANN_LIBRARY} ${FLOATFANN_LIBRARY} )

if( UNIX )
set( FANN_LIBRARIES ${FANN_LIBRARIES} m )
endif()

if(FANN_INCLUDE_DIRS AND FANN_LIBRARIES)
set(FANN_FOUND TRUE)
endif()

if(FANN_FOUND)
if(NOT FANN_FIND_QUIETLY)
message(STATUS "Found FANN:")
message(STATUS "FANN_INCLUDE_DIRS: ${FANN_INCLUDE_DIRS}")
message(STATUS "FANN_LIBRARIES: ${FANN_LIBRARIES}")
endif()
else()
if(FANN_FIND_REQUIRED)
message(FATAL_ERROR "Could not find FANN")
endif()
endif()

mark_as_advanced(FANN_INCLUDE_DIRS FANN_LIBRARIES)
endif()

该脚本名为 FindFANN.cmake,我的主脚本使用 find_package() 命令调用它。现在我还打印了目录 "${CMAKE_CURRENT_SOURCE_DIR}/FANN/lib""${CMAKE_CURRENT_SOURCE_DIR}/FANN/include",它们是正确的。但是找不到库,我不明白为什么。在 "${CMAKE_CURRENT_SOURCE_DIR}/FANN/lib" 我有:

fanndouble.dll
fanndouble.lib
fannfixed.dll
fannfixed.lib
fannfloat.dll
fannfloat.lib

"${CMAKE_CURRENT_SOURCE_DIR}/FANN/include" 中,我有 fann.h 以及其他 header 。

我知道这不是最好的可移植脚本,但现在我只需要它正常工作...

这是准确的输出

$ cmake . -G "CodeBlocks - Unix Makefiles" 
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: c:/MinGW/bin/cc.exe
-- Check for working C compiler: c:/MinGW/bin/cc.exe
-- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: c:/MinGW/bin/c++.exe
-- Check for working CXX compiler: c:/MinGW/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at cmake/Modules/FindFANN.cmake:91 (message):
Could not find FANN
Call Stack (most recent call first):
CMakeLists.txt:30 (find_package)

-- Configuring incomplete, errors occurred!
See also "C:/Users/Manuele/Documents/TicTacToe/CMakeFiles/CMakeOutput.log".

这是我的 grep FANN CMakeCache.txt:

$ grep FANN CMakeCache.txt
DOUBLEFANN.LIB_LIBRARY:FILEPATH=DOUBLEFANN.LIB_LIBRARY-NOTFOUND
DOUBLEFANN_LIBRARY:FILEPATH=DOUBLEFANN_LIBRARY-NOTFOUND
FANN_DIR:UNINITIALIZED=C:/Users/Manuele/Documents/TicTacToe/FANN/
FANN_INCLUDE_DIR:PATH=c:/Users/Manuele/Documents/TicTacToe/FANN/include
FIXEDFANN.LIB_LIBRARY:FILEPATH=FIXEDFANN.LIB_LIBRARY-NOTFOUND
FIXEDFANN_LIBRARY:FILEPATH=FIXEDFANN_LIBRARY-NOTFOUND
FLOATFANN.LIB_LIBRARY:FILEPATH=FLOATFANN.LIB_LIBRARY-NOTFOUND
FLOATFANN_LIBRARY:FILEPATH=FLOATFANN_LIBRARY-NOTFOUND.

最佳答案

好吧...它一直就在眼前,但我直到最后一个 message() 输出才真正意识到它。

set( _libraries doublefann fixedfann floatfann )

和:

fanndouble.dll
fanndouble.lib
fannfixed.dll
fannfixed.lib
fannfloat.dll
fannfloat.lib

你看到问题了吗?您正在寻找错误的图书馆名称。 (fanndoubledoublefann 等)

关于windows - CMake 在 Windows 上找不到库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32458965/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com