使用cmake将LLVM添加到项目 [英] Add LLVM to project using cmake
问题描述
我正在尝试使用cygwin作为编译器将LLVM添加到cmake项目.我从cygwin的安装程序中下载了LLVM(只安装了所有与llvm相关的软件包).文件在那里,但是我不能在项目中包含LLVM.我尝试使用3.5.2(安装的版本)的官方指南,而我的CMakeLists.txt看起来像
I'm trying to add LLVM to a cmake project, using cygwin as a compiler. I downloaded LLVM from cygwin's installer (just installed all of the llvm related packages). The files are there, however I cannot include LLVM in my project. I tried using the official guide for 3.5.2 (the version it installed) and my CMakeLists.txt looks like
cmake_minimum_required(VERSION 3.2)
project(Lang)
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(Lang ${SOURCE_FILES})
llvm_map_components_to_libnames(llvm_libs support core irreader)
# Link against LLVM libraries
target_link_libraries(Lang ${llvm_libs})
但是,我遇到了很多这样的错误
However, I get a bunch of errors like these
我做错什么了吗?我要做的就是在项目中使用LLVM.
Am I doing something wrong? All I want to do is to use LLVM in my project.
推荐答案
正如Marco A.在评论中指出的,问题出在缺少库.此链接有助于解决此问题,现在一切似乎都可以正常工作. https://stackoverflow.com/a/25783251/1938163
As indicated by Marco A. in the comments, the problem were missing libraries. This link helped resolve the issue, and everything seems to be working normally now. https://stackoverflow.com/a/25783251/1938163
谢谢.
这篇关于使用cmake将LLVM添加到项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!