我是C/C++新手,正在使用下面的make文件運行make hello
。我正在使用Ubuntu 14.04 64位操作系統。使用make文件時出錯
hello: main.o factorial.o hello.o
gcc main.o factorial.o hello.o -o hello -lstdc++
main.o: main.cpp functions.h
gcc -c main.cpp
factorial.o: factorial.cpp functions.h
gcc -c factorial.cpp
hello.o: hello.cpp functions.h
gcc -c hello.cpp
- 在make文件中,我指定了gcc,但是正在使用g ++,如下所示。爲什麼?
- 此外,在g ++命令-c
選項丟失,所以下面的錯誤。如何解決這個問題?
[email protected]:~/make$ make hello
g++ hello.cpp -o hello
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [hello] Error 1
你的makefile是命名爲'makefile'還是'Makefile'?還是你說了別的嗎? – twalberg
謝謝 - 將其更改爲makefile,它工作, –