Linux 编译报错 -- undefined reference to 问题解决方法 (具体'pthread_create'和opencv看文章最后两条)

本文详细介绍了在Linux编程中遇到undefined reference错误的原因及解决方法,包括链接时缺失目标文件、缺少相关库文件等,并提供了多线程编程和使用OpenCV时遇到此类问题的具体解决方案。
最近在Linux下编程发现一个诡异的现象,就是在链接一个静态库的时候总是报错,类似下面这样的错误:
 
  1. (.text+0x13): undefined reference to `func'

    关于undefined reference这样的问题,大家其实经常会遇到,在此,我以详细地示例给出常见错误的各种原因以及解决方法,希望对初学者有所帮助。


(ps,1-5是针对自定义的函数,6针对线程,7针对opencv)


1.  链接时缺失了相关目标文件(.o)

    测试代码如下:

    然后编译。

 
  1. gcc -c test.c
  2. gcc –c main.c

    得到两个 .o 文件,一个是 main.o,一个是 test.o ,然后我们链接 .o 得到可执行程序:

 
  1. gcc -o main main.o

    这时,你会发现,报错了:

 
  1. main.o: In function `main':
  2. main.c:(.text+0x7): undefined reference to `test'
  3. collect2: ld returned 1 exit status

    这就是最典型的undefined reference错误,因为在链接时发现找不到某个函数的实现文件,本例中test.o文件中包含了test()函数的实现,所以如果按下面这种方式链接就没事了。

 
  1. gcc -o main main.o test.o

   【扩展】:其实上面为了让大家更加清楚底层原因,我把编译链接分开了,下面这样编译也会报undefined reference错,其实底层原因与上面是一样的。

 
  1. gcc -o main main.c //缺少test()的实现文件

需要改成如下形式才能成功,将test()函数的实现文件一起编译。

 
  1. gcc -o main main.c test.c //ok,没问题了

2.    链接时缺少相关的库文件(.a/.so)

    在此,只举个静态库的例子,假设源码如下。

    先把test.c编译成静态库(.a)文件

 
  1. gcc -c test.c
  2. ar -rc test.a test.o

    至此,我们得到了test.a文件。我们开始编译main.c

 
  1. gcc -c main.c

    这时,则生成了main.o文件,然后我们再通过如下命令进行链接希望得到可执行程序。

 
  1. gcc -o main main.o

    你会发现,编译器报错了:

 
  1. /tmp/ccCPA13l.o: In function `main':
  2. main.c:(.text+0x7): undefined reference to `test'
  3. collect2: ld returned 1 exit status

    其根本原因也是找不到test()函数的实现文件,由于该test()函数的实现在test.a这个静态库中的,故在链接的时候需要在其后加入test.a这个库,链接命令修改为如下形式即可。

 
  1. gcc -o main main.o ./test.a //注:./ 是给出了test.a的路径

     【扩展】:同样,为了把问题说清楚,上面我们把代码的编译链接分开了,如果希望一次性生成可执行程序,则可以对main.c和test.a执行如下命令。

 
  1. gcc -o main main.c ./test.a //同样,如果不加test.a也会报错

3.    链接的库文件中又使用了另一个库文件

    这种问题比较隐蔽,也是我最近遇到的与网上大家讨论的不同的问题,举例说明如下,首先,还是看看测试代码。

    从上图可以看出,main.c调用了test.c的函数,test.c中又调用了fun.c的函数。
    首先,我们先对fun.c,test.c,main.c进行编译,生成 .o文件。

 
  1. gcc -c func.c
  2. gcc -c test.c
  3. gcc -c main.c

    然后,将test.c和func.c各自打包成为静态库文件。

 
  1. ar –rc func.a func.o
  2. ar –rc test.a test.o

    这时,我们准备将main.o链接为可执行程序,由于我们的main.c中包含了对test()的调用,因此,应该在链接时将test.a作为我们的库文件,链接命令如下。

 
  1. gcc -o main main.o test.a

    这时,编译器仍然会报错,如下:

 
  1. test.a(test.o): In function `test':
  2. test.c:(.text+0x13): undefined reference to `func'
  3. collect2: ld returned 1 exit status

    就是说,链接的时候,发现我们的test.a调用了func()函数,找不到对应的实现。由此我们发现,原来我们还需要将test.a所引用到的库文件也加进来才能成功链接,因此命令如下。

 
  1. gcc -o main main.o test.a func.a

    ok,这样就可以成功得到最终的程序了。同样,如果我们的库或者程序中引用了第三方库(如pthread.a)则同样在链接的时候需要给出第三方库的路径和库文件,否则就会得到undefined reference的错误。

4 多个库文件链接顺序问题

    这种问题也非常的隐蔽,不仔细研究你可能会感到非常地莫名其妙。我们依然回到第3小节所讨论的问题中,在最后,如果我们把链接的库的顺序换一下,看看会发生什么结果?

 
  1. gcc -o main main.o func.a test.a

    我们会得到如下报错.

 
  1. test.a(test.o): In function `test':
  2. test.c:(.text+0x13): undefined reference to `func'
  3. collect2: ld returned 1 exit status

    因此,我们需要注意,在链接命令中给出所依赖的库时,需要注意库之间的依赖顺序,依赖其他库的库一定要放到被依赖库的前面,这样才能真正避免undefined reference的错误,完成编译链接。

5. 在c++代码中链接c语言的库

    如果你的库文件由c代码生成的,则在c++代码中链接库中的函数时,也会碰到undefined reference的问题。下面举例说明。

    首先,编写c语言版库文件:

    

    编译,打包为静态库:test.a

 
  1. gcc -c test.c
  2. ar -rc test.a test.o

    至此,我们得到了test.a文件。下面我们开始编写c++文件main.cpp

    

    然后编译main.cpp生成可执行程序:

 
  1. g++ -o main main.cpp test.a

    会发现报错:

 
  1. /tmp/ccJjiCoS.o: In function `main':
  2. main.cpp:(.text+0x7): undefined reference to `test()'
  3. collect2: ld returned 1 exit status

    原因就是main.cpp为c++代码,调用了c语言库的函数,因此链接的时候找不到,解决方法:即在main.cpp中,把与c语言库test.a相关的头文件包含添加一个extern "C"的声明即可。例如,修改后的main.cpp如下:

    

 
  1. g++ -o main main.cpp test.a

    再编译会发现,问题已经成功解决。

 

6. 多线程编程中 undefined reference to 'pthread_create' / 'pthread_join':

 

undefined reference to 'pthread_create'
undefined reference to 'pthread_join'

问题原因:
   pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。

问题解决:
    在编译中要加 -lpthread参数
    gcc thread.c -o thread -lpthread
    thread.c为你些的源文件,不要忘了加上头文件#include<pthread.h>

 

 7. opencv编程中 undefined reference to 'cv::dft':


./obj/local/armeabi/libopencv_imgproc.a(templmatch.cpp.o): In function `cv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Size_<int>, int, cv::Point_<int>, double, int)':
templmatch.cpp:(.text+0x47e): undefined reference to `cv::getOptimalDFTSize(int)'
templmatch.cpp:(.text+0x494): undefined reference to `cv::getOptimalDFTSize(int)'
templmatch.cpp:(.text+0x92c): undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
templmatch.cpp:(.text+0xfa4): undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
templmatch.cpp:(.text+0x1006): undefined reference to `cv::mulSpectrums(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, bool)'
templmatch.cpp:(.text+0x102e): undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
。。。。。。
问题原因:
   链接时缺少相关的库,或者库添加的先后顺序不满足依赖关系。

问题解决:
    在链接中添加相关的opencv库,比如opencv_features2d,opencv_flann,opencv_imgproc,opencv_core,opencv_highgui,opencv_calib3d等等。其次,添加的库要按照依赖关系排序,比如opencv_imgproc依赖opencv_core,opencv_features2d依赖opencv_imgproc,所以顺序就是opencv_feature2d,opencv_imgproc,opencv_core.

1-5  转自 http://blog.youkuaiyun.com/aiwoziji13/article/details/7330333       6 转自 http://blog.youkuaiyun.com/llqkk/article/details/2854558

7 参考 http://stackoverflow.com/questions/10234894/opencv-undefined-references

====================[ 构建 | C++OpenCV_rendering-to-QML | Debug ]================= "D:\CLion 2025.1.3\bin\cmake\win\x64\bin\cmake.exe" --build "E:\CLionc++lianxi\C++OpenCV_rendering to QML\cmake-build-debug" --target C++OpenCV_rendering-to-QML -j 4 [1/4] Automatic MOC for target C++OpenCV_rendering-to-QML [2/3] Building CXX object CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj [3/3] Linking CXX executable C++OpenCV_rendering-to-QML.exe FAILED: C++OpenCV_rendering-to-QML.exe C:\Windows\system32\cmd.exe /C "cd . && "D:\CLion 2025.1.3\bin\mingw\bin\g++.exe" -g -mwindows CMakeFiles/C++OpenCV_rendering-to-QML.dir/C++OpenCV_rendering-to-QML_autogen/mocs_compilation.cpp.obj CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj CMakeFiles/C++OpenCV_rendering-to-QML.dir/C++OpenCV_rendering-to-QML_autogen/DHU3A7JD2B/qrc_source.cpp.obj -o C++OpenCV_rendering-to-QML.exe -Wl,--out-implib,libC++OpenCV_rendering-to-QML.dll.a -Wl,--major-image-version,0,--minor-image-version,0 D:/Qt/6.8.3/msvc2022_64/lib/Qt6QuickControls2d.lib "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" "E:/CLionc++lianxi/C++OpenCV_rendering to QML/src/qml_opencv/lib/opencv/msvc/lib/opencv_world480d.lib" D:/Qt/6.8.3/msvc2022_64/lib/Qt6Quickd.lib D:/Qt/6.8.3/msvc2022_64/lib/Qt6QmlMetad.lib D:/Qt/6.8.3/msvc2022_64/lib/Qt6QmlWorkerScriptd.lib D:/Qt/6.8.3/msvc2022_64/lib/Qt6OpenGLd.lib -luser32 D:/Qt/6.8.3/msvc2022_64/lib/Qt6Guid.lib -ld3d11 -ldxgi -ldxguid -ld3d12 D:/Qt/6.8.3/msvc2022_64/lib/Qt6QmlModelsd.lib D:/Qt/6.8.3/msvc2022_64/lib/Qt6Qmld.lib D:/Qt/6.8.3/msvc2022_64/lib/Qt6Networkd.lib D:/Qt/6.8.3/msvc2022_64/lib/Qt6Cored.lib -lmpr -luserenv D:/Qt/6.8.3/msvc2022_64/lib/Qt6EntryPointd.lib -lws2_32 -lshell32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && C:\Windows\system32\cmd.exe /C "cd /D "E:\CLionc++lianxi\C++OpenCV_rendering to QML\cmake-build-debug" && D:\Qt\6.8.3\msvc2022_64\bin\windeployqt.exe "E:/CLionc++lianxi/C++OpenCV_rendering to QML/cmake-build-debug/C++OpenCV_rendering-to-QML.exe" --qmldir "E:/CLionc++lianxi/C++OpenCV_rendering to QML/UI_resource/qml""" D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj: in function `indexOfOwnClassInfo': D:/Qt/6.8.3/msvc2022_64/include/QtQml/qqmlprivate.h:809: undefined reference to `__imp__ZNK11QMetaObject15classInfoOffsetEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: D:/Qt/6.8.3/msvc2022_64/include/QtQml/qqmlprivate.h:811: undefined reference to `__imp__ZNK11QMetaObject14classInfoCountEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: D:/Qt/6.8.3/msvc2022_64/include/QtQml/qqmlprivate.h:814: undefined reference to `__imp__ZNK11QMetaObject9classInfoEi' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: D:/Qt/6.8.3/msvc2022_64/include/QtQml/qqmlprivate.h:814: undefined reference to `__imp__ZNK14QMetaClassInfo4nameEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: D:/Qt/6.8.3/msvc2022_64/include/QtQml/qqmlprivate.h:814: undefined reference to `__imp__Z7qstrcmpPKcS0_' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj: in function `main': E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:12: undefined reference to `__imp__ZN12QQuickWindow14setGraphicsApiEN20QSGRendererInterface11GraphicsApiE' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:19: undefined reference to `cv::VideoCapture::VideoCapture()' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:24: undefined reference to `__imp__ZN15QGuiApplicationC1ERiPPci' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:37: undefined reference to `__imp__ZN10QQmlEngineC1EP7QObject' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:41: undefined reference to `__imp__ZN13QQmlComponentC1EP10QQmlEngineP7QObject' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:55: undefined reference to `__imp__ZN4QUrlC1ERK7QStringNS_11ParsingModeE' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:55: undefined reference to `__imp__ZN13QQmlComponent7loadUrlERK4QUrl' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:55: undefined reference to `__imp__ZN4QUrlD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:58: undefined reference to `__imp__ZNK13QQmlComponent7isErrorEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:60: undefined reference to `__imp__ZNK14QMessageLogger5debugEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:60: undefined reference to `__imp__ZNK13QQmlComponent11errorStringEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:60: undefined reference to `__imp__ZN6QDebugD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:64: undefined reference to `__imp__ZN13QQmlComponent6createEP11QQmlContext' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:67: undefined reference to `__imp__ZNK13QQmlComponent7isErrorEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:69: undefined reference to `__imp__ZNK14QMessageLogger5debugEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:69: undefined reference to `__imp__ZNK13QQmlComponent11errorStringEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:69: undefined reference to `__imp__ZN6QDebugD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:71: undefined reference to `__imp__ZN15QGuiApplication4execEv' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:72: undefined reference to `__imp__ZN13QQmlComponentD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:72: undefined reference to `__imp__ZN10QQmlEngineD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:72: undefined reference to `__imp__ZN15QGuiApplicationD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:72: undefined reference to `cv::VideoCapture::~VideoCapture()' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:55: undefined reference to `__imp__ZN4QUrlD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:60: undefined reference to `__imp__ZN6QDebugD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:69: undefined reference to `__imp__ZN6QDebugD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:72: undefined reference to `__imp__ZN13QQmlComponentD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:72: undefined reference to `__imp__ZN10QQmlEngineD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:72: undefined reference to `__imp__ZN15QGuiApplicationD1Ev' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: E:/CLionc++lianxi/C++OpenCV_rendering to QML/main.cpp:72: undefined reference to `cv::VideoCapture::~VideoCapture()' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj: in function `QString::QString(char const*)': D:/Qt/6.8.3/msvc2022_64/include/QtCore/qstring.h:847: undefined reference to `__imp__ZN7QString8fromUtf8E14QByteArrayView' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj: in function `QString::data() const': D:/Qt/6.8.3/msvc2022_64/include/QtCore/qstring.h:1242: undefined reference to `__imp__ZN7QString6_emptyE' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj: in function `QDebug::maybeSpace()': D:/Qt/6.8.3/msvc2022_64/include/QtCore/qdebug.h:93: undefined reference to `__imp__ZN11QTextStreamlsEc' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj: in function `QDebug::operator<<(QString const&)': D:/Qt/6.8.3/msvc2022_64/include/QtCore/qdebug.h:127: undefined reference to `__imp__ZN6QDebug9putStringEPK5QChary' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj: in function `QByteArrayView::QByteArrayView<char, true>(char const*, long long)': D:/Qt/6.8.3/msvc2022_64/include/QtCore/qbytearrayview.h:147: undefined reference to `__imp__Z9qt_assertPKcS0_i' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: D:/Qt/6.8.3/msvc2022_64/include/QtCore/qbytearrayview.h:147: undefined reference to `__imp__Z9qt_assertPKcS0_i' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/main.cpp.obj: in function `QtPrivate::QPodArrayOps<char16_t>::destroyAll()': D:/Qt/6.8.3/msvc2022_64/include/QtCore/qarraydataops.h:98: undefined reference to `__imp__Z9qt_assertPKcS0_i' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: D:/Qt/6.8.3/msvc2022_64/include/QtCore/qarraydataops.h:99: undefined reference to `__imp__Z9qt_assertPKcS0_i' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/C++OpenCV_rendering-to-QML_autogen/DHU3A7JD2B/qrc_source.cpp.obj: in function `qInitResources_source()': E:/CLionc++lianxi/C++OpenCV_rendering to QML/cmake-build-debug/C++OpenCV_rendering-to-QML_autogen/DHU3A7JD2B/qrc_source.cpp:88: undefined reference to `qRegisterResourceData(int, unsigned char const*, unsigned char const*, unsigned char const*)' D:\CLion 2025.1.3\bin\mingw\bin/ld.exe: CMakeFiles/C++OpenCV_rendering-to-QML.dir/C++OpenCV_rendering-to-QML_autogen/DHU3A7JD2B/qrc_source.cpp.obj: in function `qCleanupResources_source()': E:/CLionc++lianxi/C++OpenCV_rendering to QML/cmake-build-debug/C++OpenCV_rendering-to-QML_autogen/DHU3A7JD2B/qrc_source.cpp:97: undefined reference to `qUnregisterResourceData(int, unsigned char const*, unsigned char const*, unsigned char const*)' collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
最新发布
07-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值