我试图编译typescript, tsx和python解析器以用于neovim,但是当我按照tree-sitter tracking issue的指示运行gcc -o parser.so -shared src/parser.c -Os -I./src
时,我得到:
Undefined symbols for architecture x86_64:
"_tree_sitter_tsx_external_scanner_create", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.o
"_tree_sitter_tsx_external_scanner_deserialize", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.o
"_tree_sitter_tsx_external_scanner_destroy", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.o
"_tree_sitter_tsx_external_scanner_scan", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.o
"_tree_sitter_tsx_external_scanner_serialize", referenced from:
_tree_sitter_tsx.language in parser-eb4e9b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
字符串
我已经运行了npm构建步骤,并尝试了build中的make文件,但我无法获得最终的.so
文件。
3条答案
按热度按时间q0qdq0h21#
有些语法有外部扫描器-手写的C/C++源文件,按照惯例称为
scanner.c
或scanner.cc
,需要与parser.c
一起沿着编译。yftpprvb2#
当解析器名和函数名不匹配时,也会出现错误
undefined symbol: tree_sitter_parsername_external_scanner_create
个字符
quickfix:替换扫描程序源中的名称
型
w46czmvw3#
nvim-treesitter使用的是这个,它与c++有一点不同。
字符串
如果你有一个旧版本的GCC,你可以尝试添加
--std=c99
和-fPIC
。el 7附带了gcc
4.8.5,这对我的几个解析器都有效。型
题外话,但相关:如果您想在旧编译器中使用nvim-treesitter,请参阅Modifies to work with gcc 4.8 for el7 #5847