使用gcc静态编译文件时
gcc -static libhahahahahahaha.lib main.o -L .\ -lhahahahahahaha
出现如下报错:
libhahahahahahaha.lib: error adding symbols: Archive has no index; run ranlib to add one
collect2.exe: error: ld returned 1 exit status
原因是编译时使用的静态链接库libhahahahahahaha.lib
编译时有错误,写成了直接用源文件来生成
ar -rcs libhahahahahahaha.lib sayhello.c sayname.c
应该使用目标文件生成静态库
ar -rcs libhahahahahahaha.lib sayhello.o sayname.o