如何使用Shell脚本为c编译器创建别名?

时间:2016-11-23 00:26:03

标签: bash shell

我想知道是否可以使用Shell脚本创建一个别名,这样可以轻松实现我的C编译。

我尝试将其添加到我的.bashrc文件中,但它没有按照我的意愿工作,返回一条错误消息,表示不存在任何命令。

alias xpto='gcc prototipo.c -o prototipo.exe $(pkg-config –cflags –libs allegro-5) -lallegro -lallegro_main -lallegro_image -lallegro_ttf -lallegro_font -lallegro_primitives -lallegro_audio -lallegro_acodec -std=c99'

1 个答案:

答案 0 :(得分:0)

错误消息可能与命令本身有关。以下命令对我有用,但是对于丢失的文件给出了错误。

machine1:/u/user1>cat .bashrc
alias xpto='gcc prototipo.c -o prototipo.exe $(pkg-config –cflags –libs allegro-5) -lallegro -lallegro_main -lallegro_image -lallegro_ttf -lallegro_font -lallegro_primitives -lallegro_audio -lallegro_acodec -std=c99'
machine1:/u/user1>bash
machine1:/u/user1>xpto
gcc: prototipo.c: No such file or directory
machine1:/u/user1>