vowstar / k210-linux-nommu

K210 run linux nommu (From Damien Le Moal's patch)
155 stars 34 forks source link

How to use TCC to compile complex programs #13

Closed Edward-Elric233 closed 3 years ago

Edward-Elric233 commented 3 years ago

I am a novice, and when I followed the README, I found that I could not compile using the following command image When I modify the program name and add the -nostdlib parameter, the program runs successfully image But when I wanted to make the program more complex, I found that I couldn't do it.It seemed like I should include a header file, but I didn't know how to do it, and I tried for a long time without success.Any help will be greatly appreciated image

Edward-Elric233 commented 3 years ago

I am a novice, and when I followed the README, I found that I could not compile using the following command image When I modify the program name and add the -nostdlib parameter, the program runs successfully image But when I wanted to make the program more complex, I found that I couldn't do it.It seemed like I should include a header file, but I didn't know how to do it, and I tried for a long time without success.Any help will be greatly appreciated image

突然看到作者是中国人,膜拜大神,我刚才在closed的问题里面看到有人也有这个问题,但是不知道他是怎么解决的。刚开始学习嵌入式,烦请大神指点。

vowstar commented 3 years ago

@Edward-Elric233 由于k210的内存实在是太小了,导致tcc编译器是被魔改后才能在k210上用起来,而且为了让rootfs足够小,我拼命的裁减了c库,导致很多引用的头文件都找不到。不过如果你想引用其他c函数的话,是有一个办法: https://github.com/vowstar/k210-linux-nommu/blob/master/k210_lib 直接在这里面加,加完后重新按照文档的流程编译这个k210_lib就可以了

cd "$PROJ_ROOT/k210_lib"    
make    
make DESTDIR=$(pwd)/../rootfs_k210 install

比如printfstdio.h也被我裁减了,我制作了一个假的放在了这里: https://github.com/vowstar/k210-linux-nommu/blob/master/k210_lib/printf.c 你可以用类似的方式添加需要的函数和“头文件”。

Edward-Elric233 commented 3 years ago

@Edward-Elric233 由于k210的内存实在是太小了,导致tcc编译器是被魔改后才能在k210上用起来,而且为了让rootfs足够小,我拼命的裁减了c库,导致很多引用的头文件都找不到。不过如果你想引用其他c函数的话,是有一个办法: https://github.com/vowstar/k210-linux-nommu/blob/master/k210_lib 直接在这里面加,加完后重新按照文档的流程编译这个k210_lib就可以了

cd "$PROJ_ROOT/k210_lib"    
make    
make DESTDIR=$(pwd)/../rootfs_k210 install

比如printfstdio.h也被我裁减了,我制作了一个假的放在了这里: https://github.com/vowstar/k210-linux-nommu/blob/master/k210_lib/printf.c 你可以用类似的方式添加需要的函数和“头文件”。

好的,我尝试一下,非常感谢您的帮助