Я сейчас пытаюсь скомпилировать программу, включающую #include <clang-c/Index.h>
с помощью cmake
cmake_minimum_required(VERSION 3.4.3)
project(ast-dump)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(LLVM REQUIRED CONFIG)
find_package(Clang REQUIRED)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
include_directories(${CLANG_INCLUDE_DIRS})
add_definitions(${CLANG_DEFINITIONS})
add_executable(ast-dump ast-dump.cpp)
llvm_map_components_to_libnames(llvm_libs all)
target_link_libraries(ast-dump ${llvm_libs})
set_target_properties(ast-dump PROPERTIES
CXX_STANDARD 14
)
, и я получил следующие ошибки:
Undefined symbols for architecture x86_64:
"_clang_Cursor_isNull", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_Location_isInSystemHeader", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_createIndex", referenced from:
_main in ast-dump.cpp.o
"_clang_disposeIndex", referenced from:
_main in ast-dump.cpp.o
"_clang_disposeString", referenced from:
toString(CXString) in ast-dump.cpp.o
"_clang_disposeTranslationUnit", referenced from:
_main in ast-dump.cpp.o
"_clang_equalCursors", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_getCString", referenced from:
toString(CXString) in ast-dump.cpp.o
"_clang_getCursorDefinition", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_getCursorExtent", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_getCursorKind", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
traverse(CXTranslationUnitImpl*) in ast-dump.cpp.o
"_clang_getCursorLocation", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_getCursorSpelling", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_getCursorType", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_getRangeEnd", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_getRangeStart", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_getSpellingLocation", referenced from:
toLineColumn(CXSourceLocation) in ast-dump.cpp.o
"_clang_getTokenSpelling", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_getTranslationUnitCursor", referenced from:
traverse(CXTranslationUnitImpl*) in ast-dump.cpp.o
"_clang_getTypeSpelling", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_parseTranslationUnit", referenced from:
_main in ast-dump.cpp.o
"_clang_tokenize", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
"_clang_visitChildren", referenced from:
visit(CXCursor, CXCursor, void*) in ast-dump.cpp.o
traverse(CXTranslationUnitImpl*) in ast-dump.cpp.o
Однако, когда я пытаюсь использовать Следующая командная строка для компиляции, она работает нормально:
c++ -isystem /usr/local/opt/llvm/include -L/usr/local/opt/llvm/lib/ -std=c++14 ast-dump.cpp -lclang -o ast-dump
Но с помощью командной строки, если я пытаюсь добавить #include <cmath>
в ast-dump.cpp
, возникает ошибка catalina <cmath>
, и я не знаю, как чтобы решить это.
Любая помощь с благодарностью! Заранее большое спасибо.