您的位置:首页 > 其它

ubuntu下 llvm-gcc cannot find crti.o: No such file or directory解决办法

2014-01-11 20:19 513 查看
ubuntu下当执行 llvm-gcc hello.c -o hello 命令,若出现

/usr/bin/ld: cannot find crt1.o: No such file or directory

/usr/bin/ld: cannot find crti.o: No such file or directory

collect2: ld returned 1 exit status

解决方法如下:

1.在系统中查找crti.o

sudo find /usr/ -name crti*

将得到结果:

(32位)/usr/lib/i386-linux-gnu/crti.o
(64位)/usr/lib/x86_64-linux-gnu/crti.o

2.将该路径添加到LIBRARY_PATH 

方法一:(仅当前shell生效,关闭shell将失效)

(32位)
LIBRARY_PATH=/usr/lib/i386-linux-gnu:$LIBRARY_PATH
export LIBRARY_PATH

(64位)
LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH
export LIBRARY_PATH

方法二:(永久生效)

(32位)
$ echo "export LIBRARY_PATH=/usr/lib/i386-linux-gnu" >> ~/.bashrc
$ source ~/.bashrc

(64位)
$ echo "export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu" >> ~/.bashrc
$ source ~/.bashrc

3.再次执行,顺利编译

4.查看LIBRARY_PATH

echo $LIBRARY_PATH
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息