gpt4 book ai didi

c++ - Makefile 产生 undefined reference

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:08:54 26 4
gpt4 key购买 nike

我收到以下错误:

//usr/local/lib/libsmfitting.so: undefined reference to `VO_FaceParts::VO_GetOneFacePart(unsigned int) const'
//usr/local/lib/libsmfitting.so: undefined reference to `cv::estimateRigidTransform(cv::_InputArray const&, cv::_InputArray const&, bool)'
collect2: error: ld returned 1 exit status

从此生成文件生成:

Cxx=g++
CXXFLAGS = -I/usr/local/include/opencv -I/usr/local/include/opencv2 -I/usr/local/include/vosm/smfitting -I/usr/local/include/vosm/smbuilding -I/usr/local/include/vosm/comalgs -I/usr/local/include/vosm/cvcommon -I/usr/local/include/vosm/ensembletraining -I/usr/local/include/vosm/featureextraction -I/usr/local/include/vosm/integraltransform -I/usr/local/include/vosm/utils
LIBS = -lopencv_ml -lopencv_calib3d -lopencv_legacy -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_video -lopencv_objdetect -lcomalgs -lcvcommon -lensembletraining -lfeatureextraction -lintegraltransform -lsmbuilding -lutils -lboost_system -lboost_filesystem -lsmfitting

all: faceApp.cpp
$(Cxx) -o faceApp faceApp.cpp $(CXXFLAGS) $(LIBS)

代码似乎是正确的,库似乎是正确构建的,我认为错误出在 makefile 中。

最佳答案

链接时库的顺序很重要,应该是反向依赖顺序。因此,如果库 B 依赖于库 A,那么在链接时需要将 B 放在 A 之前。

在您的情况下,smfitting 库似乎依赖于 OpenCV 库之一以及其他一些库,因此您需要将它放在这些库之前。

关于c++ - Makefile 产生 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31935310/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com