我试图在Cygwin中构建April Tags项目的C实现,但是在运行make时遇到以下错误(我已经安装了gcc-core并从中创建了包Cygwin的开发部分):
apriltag.o
gcc: error: unrecognized command line option ‘-pthread’
Makefile:23: recipe for target 'apriltag.o' failed
make: *** [apriltag.o] Error 1
makefile的内容是:
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
我已经读过cygwin支持posix线程所以我不确定为什么这不起作用。我也遇到了patch应该在cygwin中设置-pthreads但我不知道如何使用它。 我怎么能解决这个错误?
答案 0 :(得分:0)
使用-lpthread
。如果你完全删除标志,你可能会回到pthread
函数的存根实现(有效地禁用线程功能)。这显然不推荐。
见https://stackoverflow.com/a/48365044/8979940