私は、<pthread.h>
ライブラリを使用するCファイルのセットをコンパイルするはずのmakefileを持っています。私の以前のLinuxインストールでmakefileが実行されましたが、今は実行できません。誰もこれで私を助けることができますか?Makefileがエラーを返す
CC=gcc
CFLAGS=-c -std=c99
LDFLAGS= -lpthread
SOURCES=pc_0.c stak.h
OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=pcths
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o [email protected]
.c.o:
$(CC) $< -o [email protected] $(CFLAGS)
clean:
rm -f *.o core
シェルプロンプトで「make」と入力したときに表示されるエラーメッセージは次のとおりです。私は手動で次の手順を実行した場合
gcc pc_0.c -o pc_0.o -c -std=c99
pc_0.c: In function ‘main’:
pc_0.c:25:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void (*)()’
pc_0.c:29:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void (*)()’
pc_0.c:33:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default]
/usr/include/pthread.h:225:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void (*)()’
gcc -lpthread pc_0.o stak.h -o pcths
pc_0.o: In function `main':
pc_0.c:(.text+0x100): undefined reference to `pthread_create'
pc_0.c:(.text+0x15d): undefined reference to `pthread_create'
pc_0.c:(.text+0x1ba): undefined reference to `pthread_create'
pc_0.c:(.text+0x206): undefined reference to `pthread_join'
pc_0.c:(.text+0x21a): undefined reference to `pthread_join'
pc_0.c:(.text+0x22e): undefined reference to `pthread_join'
collect2: ld returned 1 exit status
make: *** [pcths] Error 1
しかし、ソースがコンパイルされています
cc pc_0.c -o pc_0.o -c -std=c99
cc pc_0.o -o pcths -lpthread
エラーメッセージも投稿できますか? – Martijn
'stak.h 'の扱いが間違っています。両方のシステムで同じバージョンのgccを使用していますか? – Beta
エラーなしで、ちょうど推測ですが、libc-devがインストールされていますか? – Marc