Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unrecognized command line option ‘-pthread’ in Cygwin

I'm trying to build a C implementation of the April Tags project inside Cygwin, but I get the following error on running make (I've installed the gcc-core and make packages from the devel section of Cygwin):

apriltag.o
gcc: error: unrecognized command line option ‘-pthread’
Makefile:23: recipe for target 'apriltag.o' failed
make: *** [apriltag.o] Error 1

The contents of the makefile are:

CC = gcc
AR = ar

CFLAGS = -std=gnu99 -Wall -Wno-unused-parameter -Wno-unused-function -pthread -I. -Icommon -O1
LDFLAGS = -lpthread -lm

APRILTAG_OBJS = apriltag.o apriltag_quad_thresh.o tag16h5.o tag25h7.o tag25h9.o tag36h10.o tag36h11.o tag36artoolkit.o g2d.o common/zarray.o common/zhash.o common/zmaxheap.o common/unionfind.o common/matd.o common/image_u8.o common/pnm.o common/image_f32.o common/image_u32.o common/workerpool.o common/time_util.o common/svd22.o common/homography.o common/string_util.o common/getopt.o

LIBAPRILTAG := libapriltag.a

all: $(LIBAPRILTAG) apriltag_demo


$(LIBAPRILTAG): $(APRILTAG_OBJS)
    @echo "   [$@]"
    @$(AR) -cq $@ $(APRILTAG_OBJS)

apriltag_demo: apriltag_demo.o
    @echo "   [$@]"
    @$(CC) -o $@ apriltag_demo.o $(APRILTAG_OBJS) $(LDFLAGS)

%.o: %.c
    @echo "   $@"
    @$(CC) -o $@ -c $< $(CFLAGS)

clean:
    @rm -rf *.o common/*.o $(LIBAPRILTAG) apriltag_demo 

I've read that cygwin supports posix threads so I'm unsure why this doesn't work. I also came across a patch supposed to enable setting -pthreads in cygwin but I don't know how to use it. How could I resolve this error?

like image 774
prestojunkie Avatar asked Feb 02 '15 13:02

prestojunkie


1 Answers

Use -lpthread. If you remove the flag completly you might fall back on a stub implementation of the pthread functions (effectivly disabling the threaded functionality). which is obviously not recommended. see https://stackoverflow.com/a/48365044/8979940

like image 76
Omer Dagan Avatar answered Nov 19 '22 12:11

Omer Dagan