Hi,
How to add lpthread option to my makefile?
My make command output is as bellow:
the content of my makefile:Code:huangyingw@laptop:/media/volgrp/myproject/git/cplusplus/linux/fundamental/semaphore$ make g++ -ansi -W -Wall -lstdc++ -I../test -lpthread test.o -o test.exe test.o: In function `main': test.cc:(.text+0xbc): undefined reference to `pthread_create' test.cc:(.text+0xd7): undefined reference to `pthread_create' test.cc:(.text+0xe8): undefined reference to `pthread_join' test.cc:(.text+0xf9): undefined reference to `pthread_join' collect2: error: ld returned 1 exit status make: *** [test.exe] Error 1the content of /home/huangyingw/myproject/git/makefile/GNU_makefile_template:Code:huangyingw@laptop:/media/volgrp/myproject/git/cplusplus/linux/fundamental/semaphore$ cat makefile OBJECTS = test.exe include /home/huangyingw/myproject/git/makefile/GNU_makefile_template LOCFLAGS = -I../test LOCFLAGS += -lpthreadCode:huangyingw@laptop:/media/volgrp/myproject/git/cplusplus/linux/fundamental/semaphore$ cat /home/huangyingw/myproject/git/makefile/GNU_makefile_template CC = g++ CCFLAGS = -ansi -W -Wall -lstdc++ LOCFLAGS = all: $(OBJECTS) %.o: %.cc %.cpp $(CC) $(CCFLAGS) $(LOCFLAGS) -c $< -o $@ %.exe: %.o $(CC) $(CCFLAGS) $(LOCFLAGS) $< -o $@ clean: rm -rf *.o core *.stackdump clobber: clean rm -rf *.exe



Adv Reply


Bookmarks