C源文件在Linux系统上的编译

首先

yum install gcc

安装完成后

gcc -o 指定文件名 文件(gcc -o hello hello.c)

另外

对pthread_create未定义的引用

pthread库不是Linux系统默认的库,连接时需要使用库libpthread.a,在编译中要加-lpthread(放在命令最后)。

例如

 

gcc -o 指定文件名 文件 -lpthread (gcc -o hello hello.c -lpthread )

 

值得注意的是,

上面 的 -o name 选项是告诉编译器可执行程序的名字,就是后面生成的hello文件,如果你忘记提这个,那么编译器会把程序放在一个名为:a.out 的文件里(a.out的含义是seeember output,即汇编输出)。如果你确信编译了一个程序但又找不到它,别忘了看看有没有a.out文件。

 

posted @ 2022-04-27 18:26  hack747  阅读(92)  评论(0编辑  收藏  举报