How to compile the multithread code with gcc

后端 未结 4 1428
耶瑟儿~
耶瑟儿~ 2021-01-16 06:43

I have seen the given two makefiles as follows:

all: thread1 thread2 thread3

CFLAGS=-I/usr/include/nptl -D_REENTRANT
LDFLAGS=-L/usr/lib/nptl -lpthread

clea         


        
4条回答
  •  天涯浪人
    2021-01-16 07:23

    Your question is answered here

    gcc: Do I need -D_REENTRANT with pthreads?

    Essentially all you need is

    gcc thread1.c -o thread1 -pthread

    and gcc will handle all the defines for you.

提交回复
热议问题