c - 如何修复 Build TinyCCompiler(TCC) from Source 中的 Error of crt1.o,crti.o?

标签 c gcc cmake crt tcc

如何修复 Build TinyCCompiler(TCC) from Source 中 crt1.o,crti.o 的错误?

https://github.com/LuaDist/tcc

我正在我的桌面系统 (ubuntu) 上测试这个,也在服务器 (centos) 上测试。 在两个操作系统上,都显示错误。

错误:

tcc: file '/usr/lib/crt1.o' not found
tcc: file '/usr/lib/crti.o' not found

详情:

guest@Base:~/Gits/tcc-compiler$ ./configure --prefix=build

Binary  directory   build/bin
TinyCC directory    build/lib/tcc
Library directory   build/lib
Include directory   build/include
Manual directory    build/man
Doc directory       build/share/doc/tcc
Target root prefix  
Source path      /home/guest/Gits/tcc-compiler
C compiler       gcc
CPU              x86-64
Big Endian       no
gprof enabled    no
cross compilers  no
use libgcc       no
Creating config.mak and config.h
config.h is unchanged

guest@Base:~/Gits/tcc-compiler$ sudo make

....
....

guest@Base:~/Gits/tcc-compiler$ sudo make install

mkdir -p "build/bin"
install -s -m755 tcc "build/bin"
mkdir -p "build/man/man1"
install tcc.1 "build/man/man1"
mkdir -p "build/lib/tcc"
mkdir -p "build/lib/tcc/include"
install -m644 libtcc1.a "build/lib/tcc"
install -m644 include/stdarg.h include/stddef.h include/stdbool.h include/float.h include/varargs.h include/tcclib.h "build/lib/tcc/include"
mkdir -p "build/share/doc/tcc"
install -m644 tcc-doc.html "build/share/doc/tcc"
mkdir -p "build/lib"
install -m644 libtcc.a "build/lib"
mkdir -p "build/include"
install -m644 libtcc.h "build/include"

guest@Base:~/Gits/tcc-compiler$cat test2.c

#include <tcclib.h>

int main()
{
    printf("Hello World\n");
    return 0;
}

错误:

guest@Base:~/Gits/tcc-compiler$ build/bin/tcc test2.c

tcc: file '/usr/lib/crt1.o' not found
tcc: file '/usr/lib/crti.o' not found

$ 查找/usr/-name crti*

/usr/mipsel-linux-gnu/lib/crti.o
/usr/lib32/crti.o
/usr/libx32/crti.o
/usr/lib/i386-linux-gnu/crti.o
/usr/lib/x86_64-linux-gnu/crti.o

$ 查找/usr/-name crt1*

/usr/mipsel-linux-gnu/lib/crt1.o
/usr/lib32/crt1.o
/usr/libx32/crt1.o
/usr/x86_64-w64-mingw32/lib/crt1.o
/usr/x86_64-w64-mingw32/lib/crt1u.o
/usr/i686-w64-mingw32/lib/crt1.o
/usr/i686-w64-mingw32/lib/crt1u.o
/usr/lib/i386-linux-gnu/crt1.o
/usr/lib/x86_64-linux-gnu/crt1.o

(完整命令可在 https://pastebin.ubuntu.com/26211506/ 获得)

如何修复错误?


我可以使用 sudo apt install tcc 安装 tcc。(没有错误和错误)

但我想从源代码安装 tcc。(这有错误)


新更新

在 tcc.h 文件中:

#define CONFIG_TCC_CRT_PREFIX CONFIG_SYSROOT "/usr/lib"

我正在将 /usr/lib 更改为 /usr/lib/x86_64-linux-gnu

$ build/bin/tcc test.c -run

Hello World

$/build/bin/tcc 测试.c

tcc: undefined symbol '__libc_csu_fini'
tcc: undefined symbol '__libc_csu_init'
tcc: undefined symbol '__libc_start_main'
tcc: undefined symbol 'printf'

新更新

#include <tcclib.h>
int main()
{
    printf("Hello World\n");
    return 0;
}

guest@Base:~/Gits/tcc-try/_build/_install/bin$ ./tcc test.c

test.c:1: include file 'tcclib.h' not found

如何修复找不到包含文件的错误?!

相关问题:How fix Error of error of include files in TinyCCompiler(TCC)?

最佳答案

LuaDist 项目旨在使用 CMake 构建完整的 Lua 生态系统。所以你应该使用 CMake 构建系统而不是原始的 makefile。通常,您会执行以下 CMake 调用。

$ mkdir _build && cd _build
$ cmake .. -DCMAKE_INSTALL_PREFIX=_install
$ cmake --build . --target install

在此之后你应该在 _install/bin 中运行 tcc

关于c - 如何修复 Build TinyCCompiler(TCC) from Source 中的 Error of crt1.o,crti.o?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47877533/

相关文章:

c++ - 如何在回溯中显示 lambda 函数?

c++ - 在 VS 2005(8) IDE 中使用 GCC

cmake - 如何在CMAKE中打包安装的文件

cmake - 生成器表达式将 WIN32 变量计算为真,即使不在 Windows 上也是如此

c - 如果我不能在 if 条件中定义一个变量,我怎样才能减少在这段代码中多次搜索我的数组?

c - 按升序插入节点

c - 打乱 SSE 寄存器中的偶数和奇数值

c - 在C中读取txt时如何删除多余的换行符

c++ - Boost.test找不到main

cmake - CMake:将库链接到库