コンパイルする必要がある小さなプロジェクトがあります。作成した 1 つのヘッダーと 1 つのソース、およびヘッダーを含むほぼ空の driver.c があります。
観察:
// iol.h
#ifndef __IOL_HEADER
#define __IOL_HEADER
/* program: iol.h
date: 5 October 2010
*/
#define UNIX 1
#define WINDOWS 2
#define OS UNIX
#if OS == UNIX
#include <ncurses.h>
#elif OS == WINDOWS
#include <conio.h>
#include <windows.h>
// Function declarations!
#endif
void iol_init(void);
#endif
今私の実装ファイル:
// iol.c
#include <string.h>
#include <stdlib.h>
#include "iol.h"
void iol_init(void) {
#if OS == WINDOWS
/* no startup required for windows */
#elif OS == UNIX
initscr();
noecho();
cbreak();
keypad(stdscr, 1);
// Implmntn continues....
これで、ヘッダーを含み、メイン () を提供するドライバー:
//main.c
#include "iol.h"
私のbashコマンド:
gcc iol.c driver.c -l"ncurses"
私は戻ってきます:
/tmp/ccmmW6hQ.o:iol.c:(.text+0x83f): first defined here
/tmp/ccwIKUaT.o: In function 'isEscaping':
driver.c:(.text+0xbab): multiple definition of 'isEscaping'
/tmp/ccmmW6hQ.o:iol.c:(.text+0xbab): first defined here
/tmp/ccwIKUaT.o: In function 'initSeq':
..
driver.c:(.text+0x149): undefined reference to 'iol_prnstr'
driver.c:(.text+0x178): undefined reference to 'iol_putch'
..
driver.c:(.text+0x726): undefined reference to 'iol_display'
collect2: ld returned 1 exit status
これをコンパイルできる場所に到達し、すべてのセグ フォールトのために髪を引き裂き始めたいだけです。私のセットアップの問題は何ですか?私は Gnu C コンパイラで RTFM を実行しているようです。つまり、 iol.h で何かを宣言し、iol.cで定義し、driver.cで使用します。 2番目の目のセット:S
実際にはエラーの長いリストを取得しています.誰かがそれが関連していると思われる場合は、ソース全体を投稿させていただきます.