LLVM错误:无法解析外部函数 [英] LLVM Error : External function could not be resolved

查看:1438
本文介绍了LLVM错误:无法解析外部函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读LLVM的万花筒教程( http://llvm.org/docs/tutorial/ index.html )。

I am reading the LLVM's Kaleidoscope tutorial (http://llvm.org/docs/tutorial/index.html).

我想编译和测试语言。在一些编译器的错误(EngineBuilder和Module的构造函数,链接libs ...)之后,构建了示例程序。然后,我尝试了语言。我有一些问题与InitializeNativeTargets,DataLayoutPass ...但我设法更正了他们。

I wanted to compile and test the language. After some compiler's errors (EngineBuilder and Module's constructor, linking libs...), the example program was built. Then, I tried the language. I got a few problems with InitializeNativeTargets, DataLayoutPass... But I managed to correct them.

怎么,我不设法解决一个错误。当我写 extern printd(x); printd(5); ,程序不工作:LLVM ERROR:程序使用外部函数'printd',无法解决。

Howewer, I don't manage to resolve one error. When I write extern printd(x); printd(5);, the program doesn't work : "LLVM ERROR : Program used external function 'printd' which could not be resolved".

我在网上寻找解决方案。我读了很多网页,但没有什么工作。

I looked for the solution on the net. I read a lot of webpages, but nothing worked.

如何解决这个问题?为什么LLVM找不到外部函数'printd',它包含在程序中?先感谢您的回答。

How can I resolve this problem ? Why LLVM can't find the external function 'printd', which is included in the program ? Thanks in advance for your answer.

使用的代码: https://docs.google.com/document/d/1Qb-zUGaUUIF354uFCXv1iuq8n_rjya6IHDW4WCPWN_4/edit?usp=sharing

.pro文件(Qt Creator):

The .pro file (Qt Creator) :

QT       += core
QT       -= gui
TARGET = Kaleidoscope
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /home/alainetflo/Documents/me/C++/LLVM/llvm-3.5.0.src/include
DEPENDPATH += /home/alainetflo/Documents/me/C++/LLVM/llvm-3.5.0.src/include

LIBS += `llvm-config --ldflags --libs all --system-libs` -Wl,-no-as-needed

QMAKE_CFLAGS += -m32
QMAKE_CXXFLAGS += -rdynamic -std=c++11 -O3



我使用GCC 4.8.2,最后,我在网上找到了一个很好的链接:

I use GCC 4.8.2, LLVM 3.5 and Qt 5.3.1 on Ubuntu 14.04 32bits.

推荐答案

href =http://koichitamura.blogspot.fr/2011/01/since-i-went-to-held-several-weeks-ago.html =nofollow> http://koichitamura.blogspot.fr /2011/01/since-i-went-to-held-several-weeks-ago.html

Finally, I found a great link on the net : http://koichitamura.blogspot.fr/2011/01/since-i-went-to-held-several-weeks-ago.html.

错误来自错误的地方.pro文件中的 -rdynamic 参数( -rdynamic 必须在链接选项之后)。你需要这个参数,因为(GCC手册页):

The error came from the wrong place of the -rdynamic argument in the .pro file (-rdynamic must be after the linking options). You need this argument because (GCC man page) :


这指示链接器添加所有符号,符号表。

This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table.

我更改了.pro文件:

I changed the .pro file :

QT       += core    
QT       -= gui    
TARGET = Test01
CONFIG   += console
CONFIG   -= app_bundle    
TEMPLATE = app   
SOURCES += main.cpp    
INCLUDEPATH += /home/alainetflo/Documents/me/C++/LLVM/llvm-3.5.0.src/include
DEPENDPATH += /home/alainetflo/Documents/me/C++/LLVM/llvm-3.5.0.src/include
INCLUDEPATH += /usr/include/i386-linux-gnu/c++/4.8 \
/usr/include/c++/4.8

LIBS += `llvm-config --ldflags --libs all --system-libs` -Wl,-no-as-needed -rdynamic

QMAKE_CFLAGS += -m32

QMAKE_CXXFLAGS += -g -std=c++11 -O3

这样,程序工作没有错误! (本教程的示例运行( http://llvm.org/docs/tutorial) /LangImpl6.html#kicking-the-tires ))

In this way, the program works with no error ! (The tutorial's example runs (http://llvm.org/docs/tutorial/LangImpl6.html#kicking-the-tires))

这篇关于LLVM错误:无法解析外部函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆