我是在liunx环境下编译这个文件,由于我在别的地方拷贝过来的文件,编译运行的时候出现bash提示。
我之前写的makefile和这个一样的
不能运行,经过这位仁兄的提示找到了原因
gcc -c file1.c -o file
- 1
-c 是只编译,不链接。
-c 只编译并生成目标文件。
不加 -c 就应该可以了
https://blog.csdn.net/u011730792/article/details/45286587
然后我又根据下面这位仁兄的提示重写了makefile文件
https://blog.csdn.net/ktigerhero3/article/details/64129783
- #helloworld is a binary file
- helloworld: hello.o
- gcc -o helloworld hello.o
- hello.o: hello.c
- gcc -c -o hello.o hello.c
- clean:
- rm -f *.all *.o
最终:
搞定