杂七杂八Linux 2

GCC

  • postfix 意义
    -c 只编译不链接,生成目标文件".o"
    -S 只编译不汇编,生成汇编代码
    -E 只进行预编译,不做其他处理
    -o xxx 链接
    -o file 把输出文件输出到file中
    -I dir 在头文件的搜索路径列表中加入dir目录
    -L dir 在库文件的搜索路径列表中加入dir目录
    -static 链接为静态库
    -library 链接为library的库文件

no reference to XXX ld return 1 exit status

  • 链接的时候找不到库函数

  • 差pthread_create:去查pthread_create在哪——pthread.so中,增加-lpthread编译参数,告诉linker在link的时候使用pthread模块。

  • gcc -o q2.c q2
    
  • 改为

    • gcc -O2 -Wall -o q2 q2.c -lpthread
      
posted @ 2020-11-24 16:09  xxxuanei  阅读(46)  评论(0编辑  收藏  举报