Windows编译fastText遇Makefile错误(e=2)及WSL新编译问题
编译fastText遇到的问题
Windows原生环境编译错误
在Windows电脑上安装Make v3.81后,执行make命令编译fastText项目时出现如下错误:
c++ -pthread -std=c++11 -march=native -O3 -funroll-loops -DNDEBUG -c src/args.cc process_begin: CreateProcess(NULL, c++ -pthread -std=c++11 -march=native -O3 -funroll-loops -DNDEBUG -c src/args.cc, ...) failed. make (e=2): The system cannot find the file specified. make: *** [args.o] Error 2
我完全不熟悉make和Makefile,以下是该Makefile的开头内容:
# # Copyright (c) 2016-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # CXX = c++ CXXFLAGS = -pthread -std=c++11 -march=native OBJS = args.o autotune.o matrix.o dictionary.o loss.o productquantizer.o densematrix.o quantmatrix.o vector.o model.o utils.o meter.o fasttext.o INCLUDES = -I. opt: CXXFLAGS += -O3 -funroll-loops -DNDEBUG opt: fasttext coverage: CXXFLAGS += -O0 -fno-inline -fprofile-arcs --coverage coverage: fasttext debug: CXXFLAGS += -g -O0 -fno-inline debug: fasttext wasm: webassembly/fasttext_wasm.js wasmdebug: export EMCC_DEBUG=1 wasmdebug: webassembly/fasttext_wasm.js
查阅过类似错误的相关话题,但这些错误的特殊情况似乎不适用于我的问题。
WSL Ubuntu环境编译错误(2023年1月11日更新)
根据建议改用WSL在Ubuntu上运行程序,当前环境为Python 3.10.12、g++ 11.4.0,且已安装编译fastText所需的numpy和scipy。但在Ubuntu的fastText目录下执行make命令时出现新错误,错误开头如下:
c++ -pthread -std=c++11 -march=native -O3 -funroll-loops -DNDEBUG args.o autotune.o matrix.o dictionary.o loss.o productquantizer.o densematrix.o quantmatrix.o vector.o model.o utils.o meter.o fasttext.o src/main.cc -o fasttext /usr/bin/ld: i386 architecture of input file `args.o' is incompatible with i386:x86-64 output /usr/bin/ld: args.o:args.cc:(.text.unlikely+0x36): undefined reference to `__ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERjj' /usr/bin/ld: args.o:args.cc:(.text.unlikely+0x7f): undefined reference to `__ZSt19__throw_logic_errorPKc' /usr/bin/ld: autotune.o: in function `fasttext::Autotune::printArgs(fasttext::Args const&, fasttext::Args const&)': autotune.cc:(.text+0x123b): undefined reference to `fasttext::Args::lossToString[abi:cxx11](fasttext::loss_name) const' /usr/bin/ld: autotune.o: in function `fasttext::Autotune::quantize(fasttext::Args&, fasttext::Args const&)': autotune.cc:(.text+0x1c8d): undefined reference to `fasttext::Args::getAutotuneModelSize() const' /usr/bin/ld: autotune.cc:(.text+0x1d6b): undefined reference to `fasttext::Args::getAutotuneModelSize() const' /usr/bin/ld: autotune.o: in function `fasttext::AutotuneStrategy::AutotuneStrategy(fasttext::Args const&, unsigned long)': autotune.cc:(.text+0x2196): undefined reference to `fasttext::Args::Args()' /usr/bin/ld: autotune.o: in function `fasttext::AutotuneStrategy::ask(double)':
错误结尾如下:
/usr/bin/ld: args.o:args.cc:(.eh_frame$_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_RKS8_+0x13): undefined reference to `___gxx_personality_v0' /usr/bin/ld: args.o:args.cc:(.eh_frame$_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_SaIS5_ENSt8__detail9_IdentityESt8equal_toIS5_ESt4hashIS5_ENS7_18_Mod_range_hashingENS7_20_Default_ranged_hashENS7_20_Prime_rehash_policyENS7_17_Hashtable_traitsILb1ELb1ELb1EEEE5countERKS5_+0x13): undefined reference to `___gxx_personality_v0' /usr/bin/ld: args.o:args.cc:(.eh_frame$_ZNSt10_HashtableIcSt4pairIKciESaIS2_ENSt8__detail10_Select1stESt8equal_toIcESt4hashIcENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE9_M_rehashEjRKj+0x13): undefined reference to `___gxx_personality_v0' /usr/bin/ld: args.o:args.cc:(.eh_frame$_ZNSt10_HashtableIcSt4pairIKciESaIS2_ENSt8__detail10_Select1stESt8equal_toIcESt4hashIcENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeEjjPNS4_10_Hash_nodeIS2_Lb0EEE+0x13): undefined reference to `___gxx_personality_v0' /usr/bin/ld: args.o:args.cc:(.eh_frame$_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_SaIS5_ENSt8__detail9_IdentityESt8equal_toIS5_ESt4hashIS5_ENS7_18_Mod_range_hashingENS7_20_Default_ranged_hashENS7_20_Prime_rehash_policyENS7_17_Hashtable_traitsILb1ELb1ELb1EEEE9_M_rehashEjRKj+0x13): more undefined references to `___gxx_personality_v0' follow collect2: error: ld returned 1 exit status
中间还有大量“未定义引用”的错误信息。
内容的提问来源于stack exchange,提问作者JS1
相关产品推荐
相关产品推荐

