Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用cmake变量提供自定义库位置(使用cmake编译SYSTRAN/fuzzy match项目)? 我以前从来没有使用过CMake和C++,我正在尝试编译这个项目: 安装依赖项后,我遵循了编译部分中的步骤: mkdir build cd build cmake .. make_C++_Cmake_Compilation - Fatal编程技术网

如何使用cmake变量提供自定义库位置(使用cmake编译SYSTRAN/fuzzy match项目)? 我以前从来没有使用过CMake和C++,我正在尝试编译这个项目: 安装依赖项后,我遵循了编译部分中的步骤: mkdir build cd build cmake .. make

如何使用cmake变量提供自定义库位置(使用cmake编译SYSTRAN/fuzzy match项目)? 我以前从来没有使用过CMake和C++,我正在尝试编译这个项目: 安装依赖项后,我遵循了编译部分中的步骤: mkdir build cd build cmake .. make,c++,cmake,compilation,C++,Cmake,Compilation,那么我在cmake上有这个错误。。命令: -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: serialization iostreams system -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/Boos

那么我在cmake上有这个错误。。命令:

-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: serialization iostreams system 
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: program_options 
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: filesystem 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
/home/paul/Documents/proj_tansv/fuzzy-match-master/src/OPENNMT_TOKENIZER_INCLUDE
   used as include directory in directory /home/paul/Documents/proj_tansv/fuzzy-match-master/src
OPENNMT_TOKENIZER_LIB
    linked by target "FuzzyMatch" in directory /home/paul/Documents/proj_tansv/fuzzy-match-master/src

-- Configuring incomplete, errors occurred!
See also "/home/paul/Documents/proj_tansv/fuzzy-match-master/build/CMakeFiles/CMakeOutput.log".
See also "/home/paul/Documents/proj_tansv/fuzzy-match-master/build/CMakeFiles/CMakeError.log".
我知道这是因为我必须用cmake变量提供自定义库位置

OPENNMT_TOKENIZER_ROOT for OpenNMT_Tokenize path.
CMAKE_PREFIX_PATH for ICU path, prefer this over ICU_ROOT as it will properly use your path over system paths.
BOOST_ROOT for Boost path.
GTEST_ROOT for Google Test path.
就像github上说的,但我不知道怎么做。。。 我想我必须编辑CMakeLists.txt文件,但我仍然不知道如何编辑

谢谢你的帮助

编辑:

我没有以正确的方式安装OpenNMT/Tokenizer,所以我克隆了这个存储库,并按照编译部分中的说明进行了操作。现在我有一个错误:

-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: serialization iostreams system 
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: program_options 
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: filesystem 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
OPENNMT_TOKENIZER_LIB
    linked by target "FuzzyMatch" in directory /home/paul/Documents/proj_tansv/fuzzy-match-master/src

-- Configuring incomplete, errors occurred!
See also "/home/paul/Documents/proj_tansv/fuzzy-match-master/build/CMakeFiles/CMakeOutput.log".
See also "/home/paul/Documents/proj_tansv/fuzzy-match-master/build/CMakeFiles/CMakeError.log".
问题似乎与CMakeLists.txt文件有关:

 project(FuzzyMatch)                                                                                                                                                                          
                                                                                                                                                                                              
 cmake_minimum_required(VERSION 3.5.1)                                                                                                                                                        
                                                                                                                                                                                              
 set(CMAKE_CXX_STANDARD 11)                                                                                                                                                                   
 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")                                                                                                                                   
                                                                                                                                                                                              
 add_compile_options(-pedantic -ansi)                                                                                                                                                         
                                                                                                                                                                                              
 if(TARGET OpenNMTTokenizer)                                                                                                                                                                  
   set(OPENNMT_TOKENIZER_LIB OpenNMTTokenizer)                                                                                                                                                
   set(OPENNMT_TOKENIZER_INCLUDE "")  # Resolved via the target.                                                                                                                              
 else()                                                                                                                                                                                       
   find_library(OPENNMT_TOKENIZER_LIB OpenNMTTokenizer REQUIRED HINTS ${OPENNMT_TOKENIZER_ROOT}/lib)                                                                                          
   find_path(OPENNMT_TOKENIZER_INCLUDE onmt/Tokenizer.h REQUIRED HINTS ${OPENNMT_TOKENIZER_ROOT}/include)                                                                                     
 endif()                                                                                                                                                                                      
                                                                                                                                                                                              
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)                                                                                                                                     
                                                                                                                                                                                              
 add_subdirectory(src)                                                                                                                                                                        
                                                                                                                                                                                              
 if (NOT LIB_ONLY)                                                                                                                                                                            
   add_subdirectory(cli)                                                                                                                                                                      
 endif()                                                                                                                                                                                      
                                                                                                                                                                                              
 if (NOT CLI_ONLY AND NOT LIB_ONLY)                                                                                                                                                           
   add_subdirectory(test)                                                                                                                                                                     
 endif()  

我仍然不知道如何修复它…

可以使用
cmake
-D
选项传递变量。例如,
cmake-DOPENNMT\u TOKENIZER\u ROOT=/path/to/TOKENIZER-DGTEST\u ROOT=/path/to/googletest
。好的,谢谢@Tsyvarev,路径应该是什么?它是我放置依赖项的一般路径还是包含某些特定文件的子存储库?在大多数情况下,
*\u ROOT
变量表示安装前缀。例如,如果依赖项是使用CMake构建和安装的,那么它就是您指定的
-DCMAKE\u INSTALL\u PREFIX=…
参数。请注意,仅当您为依赖项指定了自定义安装前缀时,通常才需要设置
*\u ROOT
变量。如果未指定此前缀,则会使用某个默认目录进行安装,默认情况下,CMake会搜索该目录。如果设置某个变量没有帮助,则显示您的确切尝试,并描述您是如何安装相应的依赖项的。在
/home/paul/Tokenizer
目录下的文件结构是否与参考中的类似:?如果是,那么您只有标记器项目的源代码,并且没有按照fuzzy match项目的要求安装它。(安装由
makeinstall
执行)。