0
Lynda.com
課程編譯:C的基本訓練
çLynda.com教程文件不是在終端或者Eclipse
問題1:項目文件 - 00_04.c
- 終端:編譯和運行正常。
- Eclipse Neon:在控制檯中生成但不顯示輸出。 02_01.c
- 項目:
00_04.c
#include <stdio.h>
#include <stdlib.h>
int main(void) {
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
return EXIT_SUCCESS;
}
Eclipse控制檯輸出
15:49:04 **** Incremental Build of configuration Debug for project NewProject ****
make all
make: Nothing to be done for `all'.
15:49:04 Build Finished (took 99ms)
問題2:(MacOS X的GCC與工具鏈創建) - 終端:不識別包含的文件
02_01.c
#include <stdio.h> // Notice the library included in the header of this file
#include <stdlib.h>
#include "myLibrary.h" // Notice that myLibrary.h uses different include syntax
myLibrary.h
#ifndef MYLIBRARY_H_
#define MYLIBRARY_H_
void function1(void);
void function2(void);
#endif /* MYLIBRARY_H_ */
myLibrary.c
void function1(void){
puts("It works :)");
}
void function2(void){
//This function does nothing as well
}
端子輸出
Undefined symbols for architecture x86_64:
"_function1", referenced from:
_main in 02_01-7f91e4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
什麼是第一個例子使用的makefile?並在第二個你有一個鏈接器錯誤(也是'function1'在那裏定義?) – UnholySheep
@UnholySheep抱歉。複製爲myLibrary的錯誤代碼。在OP中修復。這就是function1()所在的位置。 – dbconfession
這只是函數的聲明。它的定義/實現在哪裏? – UnholySheep