yang
July 5, 2023, 3:38pm
1
再次倾情奉献,现场开发调试工具-TinyCC
链接: https://pan.baidu.com/s/1K9RVYnv8Wc3Ln8yc0oxwdg 提取码: 9255
已存放百度网盘, 下载 milkv-duo-tinycc.zip 后按照下面说明操作
1. 将 milkv-duo-tinycc.zip 通过ssh上传到开发板系统安装
scp ./milkv-duo-tinycc.zip root@192.168.42.1:~/
2. 安装TinyCC
ssh root@192.168.42.1
cd ~/
unzip milkv-duo-tinycc.zip
cd milkv-duo-tinycc
./install.sh
cd ..
3. 编写上传测试程序
将下面代码保存到本机 test.c 文件
#!/usr/local/bin/tcc -run
#include <stdio.h>
int main(int argc, char **argv){
printf("%s---\n", "hello milk-v!");
return 0;
}
scp ./test.c root@192.168.42.1:~/
4. 编译运行测试程序
cd ~/
tcc -o test test.c
./test
5. 解析执行测试程序
tcc -run test.c
6. 脚本执行测试程序
chmod +x test.c
./test.c
7. 附上测试程序包 tcc-examples.zip
scp ./tcc-examples.zip root@192.168.42.1:~/
cd ~/
unzip tcc-examples.zip
cd ./tcc-examples
./test.c
注意此版本需在musl编译的内核上执行
5 Likes
Gusman
August 20, 2023, 3:41am
2
Hi.
Could you share the files on another host that is not Baidu?
Cheers.
2 Likes
nate
August 23, 2023, 9:12am
5
Thank you. Is there any chance we can also have the tcc-examples.zip file shared here as well?
I had to “chmod +x intsall.sh” for it to install … and then also “chmod +x /usr/lib/bin/tcc” and then it compiled test.c and produced executable output.
Great to have a c-compiler on milk-v duo.
Thanks!
1 Like
kilo
August 23, 2023, 11:30am
6
I’m not the original poster,so if u wanna share the examples.zip,maybe create a new post is better?
yang
August 23, 2023, 5:47pm
7
不好意思,之前的版本有点bug已更新,请重新下载安装。
moran
September 25, 2023, 3:52pm
8
你好,能否介绍一下具体是怎么编译的tinycc? 我尝试去为milkv-duo编译tinycc,出现了报错,我是这样做的:
在配置好交叉编译工具链后,
git clone https://github.com/mirror/tinycc.git
cd tinycc
./configure --prefix=$PWD/install --cpu=riscv64
结果如下:
Binary directory /mnt/d/MilkvDuo/XC/tinycc/install/bin
TinyCC directory /mnt/d/MilkvDuo/XC/tinycc/install/lib/tcc
Library directory /mnt/d/MilkvDuo/XC/tinycc/install/lib
Include directory /mnt/d/MilkvDuo/XC/tinycc/install/include
Manual directory /mnt/d/MilkvDuo/XC/tinycc/install/share/man
Info directory /mnt/d/MilkvDuo/XC/tinycc/install/share/info
Doc directory /mnt/d/MilkvDuo/XC/tinycc/install/share/doc
Source path /mnt/d/MilkvDuo/XC/tinycc
C compiler riscv64-unknown-linux-musl-gcc (.)
Target OS Linux
CPU riscv64
Creating config.mak and config.h
然后执行make
出现了以下报错:
riscv64-unknown-linux-musl-gcc -DC2STR conftest.c -o c2str.exe && ./c2str.exe include/tccdefs.h tccdefs_.h
/bin/sh: 1: ./c2str.exe: Exec format error
Makefile:265: recipe for target 'tccdefs_.h' failed
make: *** [tccdefs_.h] Error 2
请问是我哪里做错了么?正确的做法应该是?
顺便提一句,我是在wsl环境下进行编译的,已交叉编译了redis,验证交叉工具链是配置正确的
yang
October 9, 2023, 11:22pm
9
保存编译脚本build_tcc.sh
#!/bin/bash
sdk_root=/media/yxw/milkv/duo-buildroot-sdk
export PATH=${sdk_root}/host-tools/gcc/riscv64-linux-musl-arm64/bin:$PATH
if [ -d ./install ] ; then
echo "rm -rf ./install"
rm -rf ./install
fi
if [ -f ./Makefile ]; then
make clean
fi
./configure --prefix=$PWD/install --cpu=riscv64 --cross-prefix=riscv64-unknown-linux-musl- --triplet=riscv64-linux-gnu --enable-cross
gcc -DC2STR conftest.c -o c2str.exe && ./c2str.exe include/tccdefs.h tccdefs_.h
make cross-riscv64 riscv64-libtcc1-usegcc=yes && make install
执行脚本
./build_tcc.sh
1 Like
user1
August 17, 2024, 9:55am
10
博主 用你的 zip包安装后
libtcc1.a 有bug,这个库链接会找不到符号
tcc libtcc_test.c -I . -L /usr/local/lib/tcc/ -l tcc1 -o aaa
user1
August 17, 2024, 9:57am
11
按照你提供的 编译脚本 交叉编译后 我查了一下 libtcc1.a 确实缺少符号
user1
August 17, 2024, 9:58am
12
编译pc 上gcc环境的libtcc.a 是没有问题的 能找到符号