分类: C/C++
2015-01-08 21:14:34
- int sum(int a,int b)
- {
- return a+b;
- }
- #include
- using namespace std;
- int sum(int a,int b);
- int main(){
- cout<
- return 0;
- }
- g++ -o main main.cpp
- /tmp/xxxx.o: In function `main':
- main.cpp:(.text+0xf): undefined reference to `sum(int, int)'
- collect2: ld returned 1 exit status
- g++ -c -o main.o main.cpp
- g++ -c -o sum.o sum.cpp
- g++ -o main main.o sum.o
- ./main
- 11