警告:新手的Ubuntu /克++ /生成文件的用戶生成文件錯誤導致未定義的參考符號 'GOMP_parallel @@ GOMP_4.0'
我試圖建立一個C++程序(C++ 11,OpenMP的,OpenCV3,實驗文件系統),如果我直接構建,則工作,但如果我使用帶有鏈接器錯誤的makefile
,則失敗。
這工作:
g++ \
-std=c++11 -std=c++1y -fopenmp -DNDEBUG \
-O3 -fprofile-generate -march=native -fomit-frame-pointer \
docproc.cpp \
-flto -L/usr/local/lib -lstdc++fs \
-lpthread -lboost_thread -lboost_system \
-lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_calib3d -lopencv_ccalib -lopencv_core -lopencv_datasets -lopencv_dnn -lopencv_dpm -lopencv_face -lopencv_features2d -lopencv_flann -lopencv_fuzzy -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_line_descriptor -lopencv_ml -lopencv_objdetect -lopencv_optflow -lopencv_photo -lopencv_plot -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_shape -lopencv_stereo -lopencv_stitching -lopencv_structured_light -lopencv_superres -lopencv_surface_matching -lopencv_text -lopencv_tracking -lopencv_xfeatures2d -lopencv_ximgproc -lopencv_xobjdetect -lopencv_xphoto
但我makefile
產生這一點,失敗:
g++ -g -L/usr/local/lib -o docproc docproc.o taina.o logging.o \
-lpthread -lboost_thread -lboost_system \
-lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_calib3d -lopencv_ccalib -lopencv_core -lopencv_datasets -lopencv_dnn -lopencv_dpm -lopencv_face -lopencv_features2d -lopencv_flann -lopencv_fuzzy -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_line_descriptor -lopencv_ml -lopencv_objdetect -lopencv_optflow -lopencv_photo -lopencv_plot -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_shape -lopencv_stereo -lopencv_stitching -lopencv_structured_light -lopencv_superres -lopencv_surface_matching -lopencv_text -lopencv_tracking -lopencv_xfeatures2d -lopencv_ximgproc -lopencv_xobjdetect -lopencv_xphoto
/usr/bin/ld: /tmp/ccNDMpfK.ltrans2.ltrans.o: undefined reference to symbol '[email protected]@GOMP_4.0'
//usr/lib/x86_64-linux-gnu/libgomp.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
這裏是我的makefile
CC=gcc
CXX=g++
RM=rm -f
CPPCONFIG=-std=c++11 -std=c++1y -fopenmp -flto -lstdc++fs -DNDEBUG
CPP_OPT=-O3 -fprofile-generate -march=native -fomit-frame-pointer
CPPFLAGS=-g $(CPPCONFIG) $(CPP_OPT)
THREAD_LIBS=-lpthread -lboost_thread -lboost_system
OPENCV_LIBS=-lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_calib3d -lopencv_ccalib -lopencv_core -lopencv_datasets -lopencv_dnn -lopencv_dpm -lopencv_face -lopencv_features2d -lopencv_flann -lopencv_fuzzy -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_line_descriptor -lopencv_ml -lopencv_objdetect -lopencv_optflow -lopencv_photo -lopencv_plot -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_shape -lopencv_stereo -lopencv_stitching -lopencv_structured_light -lopencv_superres -lopencv_surface_matching -lopencv_text -lopencv_tracking -lopencv_xfeatures2d -lopencv_ximgproc -lopencv_xobjdetect -lopencv_xphoto
LDFLAGS=-g -L/usr/local/lib
LDLIBS=$(THREAD_LIBS) $(OPENCV_LIBS)
SRCS=docproc.cpp taina.cpp logging.cpp
OBJS=$(subst .cpp,.o,$(SRCS))
all: docproc
docproc: $(OBJS)
$(CXX) $(LDFLAGS) -o docproc $(OBJS) $(LDLIBS)
depend: .depend
.depend: $(SRCS)
rm -f ./.depend
$(CXX) $(CPPFLAGS) -MM $^>>./.depend;
clean:
$(RM) $(OBJS)
dist-clean: clean
$(RM) *~ .depend
include .depend
您應該注意,排列庫的順序對於鏈接 –