Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding -lpthread

Status
Not open for further replies.

13sio

Technical User
May 21, 2003
141
MO
now i'm programming GUI by GTK+, and also use pthread_create. i don't know how to add -lpthread in my makefile (see below). pthread_create() is used in callback.c.

------------
CC = gcc

app: window.o dialog.o callback.o simset.o filesel.o
$(CC) window.o dialog.o callback.o simset.o filesel.o -o app -lpthread `pkg-config --libs gtk+-2.0`

window.o: window.c dialog.h callback.h filesel.h
$(CC) -c window.c -o window.o `pkg-config gtk+-2.0 --cflags`

dialog.o: dialog.c dialog.h
$(CC) -c dialog.c -o dialog.o `pkg-config gtk+-2.0 --cflags`

callback.o: callback.c callback.h simset.h filesel.h
$(CC) -c callback.c -o callback.o -lpthread `pkg-config gtk+-2.0 --cflags`

simset.o: simset.c simset.h callback.h filesel.h
$(CC) -c simset.c -o simset.o `pkg-config gtk+-2.0 --cflags`

filesel.o: filesel.c filesel.h
$(CC) -c filesel.c -o filesel.o `pkg-config gtk+-2.0 --cflags`

clean:
rm -f *.o
------------

and the results are shown below.

gcc -c callback.c -o callback.o -lpthread `pkg-config gtk+-2.0 --cflags`
gcc: -lpthread: linker input file unused because linking not done
gcc -c simset.c -o simset.o `pkg-config gtk+-2.0 --cflags`
gcc -c filesel.c -o filesel.o `pkg-config gtk+-2.0 --cflags`
gcc window.o dialog.o callback.o simset.o filesel.o -o app -lpthread `pkg-config --libs gtk+-2.0`
 
Add

Code:
LDFLAGS="-lpthread"

close to where you define CC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top