Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Symbols not found for architecture x86_64 MacOS Yosemite



  • Hi there!

    I'm really new in all of this, and I don't know anything about terminal and stuff... I (think) installed openCV 2.4.10 and qtCreator 3.3.0 using terminal commands:

    1. cd /Users/Sergio/Downloads/opencv-2.4.9
    2. mkdir build
    3. cd build
    4. cmake -G "Unix Makefiles" ..
    5. make -j8
    6. sudo make install

    It seems ok, folders appear on usr/local/... I don't know how to use QtCreator so I create a console project and add this to the .pro:

    @
    #-------------------------------------------------

    Project created by QtCreator 2015-02-18T09:40:59

    #-------------------------------------------------

    QT += core

    QT -= gui

    TARGET = cosa
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9

    SOURCES += main.cpp

    INCLUDEPATH += "/usr/local/include" \

    LIBS += -L"/usr/local/lib"
    -lopencv_core
    -lopencv_highgui

    @

    Then into the main.cpp added this (from an example i got online):

    @
    #include "opencv2/opencv.hpp"
    #include "opencv2/highgui/highgui.hpp"

    using namespace cv;

    int main( int argc, char **argv)
    {
    Mat image = imread( argv[1], CV_LOAD_IMAGE_COLOR );

    namedWindow( "Original", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED );
    imshow( "Original", image );

    // Sobel example from http://docs.opencv.org/doc/user_guide/ug_mat.html#visualizing-images
    Mat gray;

    cvtColor( image, gray, CV_BGR2GRAY );

    Mat sobelx;

    Sobel( gray, sobelx, CV_32F, 1, 0 );

    double minVal = 0.0;
    double maxVal = 0.0;

    minMaxLoc( sobelx, &minVal, &maxVal ); //find minimum and maximum intensities

    Mat draw;

    sobelx.convertTo( draw, CV_8U, 255.0/(maxVal - minVal), -minVal * 255.0/(maxVal - minVal) );

    namedWindow( "Sobel", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED );
    imshow( "Sobel", draw );

    while ( waitKey( 33 ) != 27 )
    ;

    return 0;
    }

    @

    When I click on Run (is that the way I should do that?) in the issue section displays:

    @error: symbol(s) not found for architecture x86_64
    error: linker command failed with exit code 1 (use -v to see invocation)@

    And the compile output shows this:

    @09:59:55: Running steps for project cosa...
    09:59:55: Configuration unchanged, skipping qmake step.
    09:59:55: Starting: "/usr/bin/make"
    /Users/Sergio/Qt5.4.0/5.4/clang_64/bin/qmake -spec macx-clang CONFIG+=debug CONFIG+=x86_64 -o Makefile ../cosa/cosa.pro
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -mmacosx-version-min=10.9 -Wl,-rpath,/Users/Sergio/Qt5.4.0/5.4/clang_64/lib -o cosa main.o -F/Users/Sergio/Qt5.4.0/5.4/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_highgui -framework QtCore -framework DiskArbitration -framework IOKit
    Undefined symbols for architecture x86_64:
    "cv::namedWindow(std::string const&, int)", referenced from:
    _main in main.o
    "cv::Sobel(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, double, double, int)", referenced from:
    _main in main.o
    "cv::imread(std::string const&, int)", referenced from:
    _main in main.o
    "cv::imshow(std::string const&, cv::_InputArray const&)", referenced from:
    _main in main.o
    "cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)", referenced from:
    _main in main.o
    "std::allocator<char>::allocator()", referenced from:
    _main in main.o
    "std::allocator<char>::~allocator()", referenced from:
    _main in main.o
    "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
    _main in main.o
    "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:
    _main in main.o
    "std::ios_base::Init::Init()", referenced from:
    ___cxx_global_var_init in main.o
    "std::ios_base::Init::~Init()", referenced from:
    ___cxx_global_var_init in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [cosa] Error 1
    09:59:55: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project cosa (kit: Desktop Qt 5.4.0 clang 64bit)
    When executing step "Make"
    09:59:55: Elapsed time: 00:00.@

    Why is that? can anybody help me, please? I read a lot about it but i can't understand a word :(

    I need to start using this programs in a class and i don't have any idea about anything!!

    Thank you :)


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you use you've built OpenCV for x86_64 ? (should be but who knows…)

    Call "file" one of the OpenCV libraries to check



  • I just downloaded the one suggested by the website on MacOS so i guess so... i don't know how to call file, how should I do that?


  • Lifetime Qt Champion

    @file /usr/local/lib/libopencv_core.dylib@

    Correct the library file name as needed



  • I faced the same error.
    checked the file and the architecture is correct:
    /usr/local/lib/libopencv_core.dylib: Mach-O 64-bit dynamically linked shared library x86_64

    But I get the same architecture error.
    Any Ideas?


  • Lifetime Qt Champion

    @saeedBaba Do you link against this lib?
    Can you show the linker call together with error message?
    Also, please show the pro file.



  • QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++11
    
    SOURCES += \
        main.cpp \
        dialog.cpp
    
    HEADERS += \
        dialog.h
    
    FORMS += \
        dialog.ui
    
    INCLUDEPATH += /usr/local/include/opencv4
    
    LIBS += -L/usr/local/lib \
         -lopencv_core \
         -lopencv_imgproc \
         -lopencv_features2d\
         -lopencv_highgui
    
    QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
    
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    ERROR SECTION:

    SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,/Users/apple/Qt6/6.1.1/clang_64/lib -o opencv_test.app/Contents/MacOS/opencv_test main.o dialog.o moc_dialog.o   -F/Users/apple/Qt6/6.1.1/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_features2d -lopencv_highgui -framework QtWidgets -framework QtGui -framework AppKit -framework ImageIO -framework Metal -framework QtCore -framework DiskArbitration -framework IOKit -framework AGL -framework OpenGL   
    
    
    Undefined symbols for architecture x86_64:
      "cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
          _main in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [opencv_test.app/Contents/MacOS/opencv_test] Error 1
    12:47:31: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project opencv_test (kit: Desktop Qt 6.1.1 clang 64bit)
    When executing step "Make"
    

  • Lifetime Qt Champion

    @saeedBaba Maybe you need to link agains opencv_imcodec?



  • @jsulm Please explain how to do that?

    I have been able to make it work with CMake but not qmake.
    is this correct that qmake caanot work with opencv without CMake?


  • Lifetime Qt Champion

    @saeedBaba said in Symbols not found for architecture x86_64 MacOS Yosemite:

    Please explain how to do that?

    In exact same way you do it for other opencv_* libs in your pro file. But I'm not sure there is actually libopencv_imcodec.
    "is this correct that qmake caanot work with opencv without CMake?" - not sure what you mean, qmake does not depend on CMake in any way.

    How did you install the OpenCV libs? Did you build them by yourself? Using same compiler?



  • @jsulm said in Symbols not found for architecture x86_64 MacOS Yosemite:

    build t

    I did not build anything. I just installed opencv and just includepath to the directory.
    Am I supposed to build libs? How one does that?

    Is not this supposed to be a straight forward process? Why cannot qt make it simpler?


  • Lifetime Qt Champion

    @saeedBaba said in Symbols not found for architecture x86_64 MacOS Yosemite:

    Why cannot qt make it simpler?

    What does Qt have to do with OpenCV?!

    I did not say you have to build it, I wanted to know how you installed it.
    The problem could be that the compiler used to build OpenCV isn't compatible with what was used to build Qt.



  • ok I still do not know how to solve this.

    How can I reinstall opencv to be compatible?


  • Lifetime Qt Champion

    @saeedBaba said in Symbols not found for architecture x86_64 MacOS Yosemite:

    How can I reinstall opencv to be compatible?

    You could build OpenCV by yourself using same compiler as you use for your Qt project.
    See https://docs.opencv.org/master/d0/db2/tutorial_macos_install.html for details.

    But maybe we should first clarify that this is really the issue.
    Can you post whole build log? At least the part where linker is called and its output. Usually linker would print a warning if it dismisses an incompatible library.



  • @jsulm said in Symbols not found for architecture x86_64 MacOS Yosemite:

    https://docs.opencv.org/master/d0/db2/tutorial_macos_install.html

    it this the whole build log?

    14:27:37: Running steps for project opencv_test_qmake...
    14:27:37: Configuration unchanged, skipping qmake step.
    14:27:37: Starting: "/usr/bin/make" -j8
    /Users/apple/Qt6/6.1.1/clang_64/bin/qmake -o Makefile ../opencv_test_qmake/opencv_test_qmake.pro -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
    /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,/Users/apple/Qt6/6.1.1/clang_64/lib -o opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake main.o dialog.o moc_dialog.o   -F/Users/apple/Qt6/6.1.1/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_features2d -lopencv_highgui -lopencv_calib3d -framework QtWidgets -framework QtGui -framework AppKit -framework ImageIO -framework Metal -framework QtCore -framework DiskArbitration -framework IOKit -framework AGL -framework OpenGL   
    Undefined symbols for architecture x86_64:
      "cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
          _main in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake] Error 1
    14:27:37: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project opencv_test_qmake (kit: Desktop Qt 6.1.1 clang 64bit)
    When executing step "Make"
    14:27:37: Elapsed time: 00:00.
    

    if not, where can I find it?


  • Lifetime Qt Champion

    @saeedBaba Looks good.
    Please try to add opencv_imcodec to LIBS as I suggested before. I think this is the lib where cv::imread is actually defined.



  • @jsulm said in Symbols not found for architecture x86_64 MacOS Yosemite:

    opencv_imcodec

    same error:

    15:19:32: Running steps for project opencv_test_qmake...
    15:19:33: Starting: "/Users/apple/Qt6/6.1.1/clang_64/bin/qmake" /usr/local/lib/C++Project/Qt6/opencv_test_qmake/opencv_test_qmake.pro -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
    Info: creating stash file /usr/local/lib/C++Project/Qt6/build-opencv_test_qmake-Desktop_Qt_6_1_1_clang_64bit-Debug/.qmake.stash
    15:19:33: The process "/Users/apple/Qt6/6.1.1/clang_64/bin/qmake" exited normally.
    15:19:33: Starting: "/usr/bin/make" -f /usr/local/lib/C++Project/Qt6/build-opencv_test_qmake-Desktop_Qt_6_1_1_clang_64bit-Debug/Makefile qmake_all
    make: Nothing to be done for `qmake_all'.
    15:19:33: The process "/usr/bin/make" exited normally.
    15:19:33: Starting: "/usr/bin/make" -j8
    /Users/apple/Qt6/6.1.1/clang_64/libexec/uic ../opencv_test_qmake/dialog.ui -o ui_dialog.h
    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../opencv_test_qmake -I. -I../../../../include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -F/Users/apple/Qt6/6.1.1/clang_64/lib -o main.o ../opencv_test_qmake/main.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../opencv_test_qmake -I. -I../../../../include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -F/Users/apple/Qt6/6.1.1/clang_64/lib -o dialog.o ../opencv_test_qmake/dialog.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -dM -E -o moc_predefs.h /Users/apple/Qt6/6.1.1/clang_64/mkspecs/features/data/dummy.cpp
    /Users/apple/Qt6/6.1.1/clang_64/libexec/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include /usr/local/lib/C++Project/Qt6/build-opencv_test_qmake-Desktop_Qt_6_1_1_clang_64bit-Debug/moc_predefs.h -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -I/usr/local/lib/C++Project/Qt6/opencv_test_qmake -I/usr/local/include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -I/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/usr/include -F/Users/apple/Qt6/6.1.1/clang_64/lib ../opencv_test_qmake/dialog.h -o moc_dialog.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../opencv_test_qmake -I. -I../../../../include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -F/Users/apple/Qt6/6.1.1/clang_64/lib -o moc_dialog.o moc_dialog.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,/Users/apple/Qt6/6.1.1/clang_64/lib -o opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake main.o dialog.o moc_dialog.o   -F/Users/apple/Qt6/6.1.1/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_features2d -lopencv_highgui -lopencv_calib3d -opencv_imcodec -framework QtWidgets -framework QtGui -framework AppKit -framework ImageIO -framework Metal -framework QtCore -framework DiskArbitration -framework IOKit -framework AGL -framework OpenGL   
    Undefined symbols for architecture x86_64:
      "cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
          _main in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake] Error 1
    15:19:36: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project opencv_test_qmake (kit: Desktop Qt 6.1.1 clang 64bit)
    When executing step "Make"
    15:19:36: Elapsed time: 00:03.
    

    Need Reputation to post more often.


  • Lifetime Qt Champion

    @saeedBaba Did you do a complete rebuild after changing pro file? Delete build folder, run qmake and build?



  • Need more reputation to post faster.

    15:19:32: Running steps for project opencv_test_qmake...
    15:19:33: Starting: "/Users/apple/Qt6/6.1.1/clang_64/bin/qmake" /usr/local/lib/C++Project/Qt6/opencv_test_qmake/opencv_test_qmake.pro -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
    Info: creating stash file /usr/local/lib/C++Project/Qt6/build-opencv_test_qmake-Desktop_Qt_6_1_1_clang_64bit-Debug/.qmake.stash
    15:19:33: The process "/Users/apple/Qt6/6.1.1/clang_64/bin/qmake" exited normally.
    15:19:33: Starting: "/usr/bin/make" -f /usr/local/lib/C++Project/Qt6/build-opencv_test_qmake-Desktop_Qt_6_1_1_clang_64bit-Debug/Makefile qmake_all
    make: Nothing to be done for `qmake_all'.
    15:19:33: The process "/usr/bin/make" exited normally.
    15:19:33: Starting: "/usr/bin/make" -j8
    /Users/apple/Qt6/6.1.1/clang_64/libexec/uic ../opencv_test_qmake/dialog.ui -o ui_dialog.h
    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../opencv_test_qmake -I. -I../../../../include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -F/Users/apple/Qt6/6.1.1/clang_64/lib -o main.o ../opencv_test_qmake/main.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../opencv_test_qmake -I. -I../../../../include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -F/Users/apple/Qt6/6.1.1/clang_64/lib -o dialog.o ../opencv_test_qmake/dialog.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -dM -E -o moc_predefs.h /Users/apple/Qt6/6.1.1/clang_64/mkspecs/features/data/dummy.cpp
    /Users/apple/Qt6/6.1.1/clang_64/libexec/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include /usr/local/lib/C++Project/Qt6/build-opencv_test_qmake-Desktop_Qt_6_1_1_clang_64bit-Debug/moc_predefs.h -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -I/usr/local/lib/C++Project/Qt6/opencv_test_qmake -I/usr/local/include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -I/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/usr/include -F/Users/apple/Qt6/6.1.1/clang_64/lib ../opencv_test_qmake/dialog.h -o moc_dialog.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../opencv_test_qmake -I. -I../../../../include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -F/Users/apple/Qt6/6.1.1/clang_64/lib -o moc_dialog.o moc_dialog.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,/Users/apple/Qt6/6.1.1/clang_64/lib -o opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake main.o dialog.o moc_dialog.o   -F/Users/apple/Qt6/6.1.1/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_features2d -lopencv_highgui -lopencv_calib3d -opencv_imcodec -framework QtWidgets -framework QtGui -framework AppKit -framework ImageIO -framework Metal -framework QtCore -framework DiskArbitration -framework IOKit -framework AGL -framework OpenGL   
    Undefined symbols for architecture x86_64:
      "cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
          _main in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake] Error 1
    15:19:36: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project opencv_test_qmake (kit: Desktop Qt 6.1.1 clang 64bit)
    When executing step "Make"
    15:19:36: Elapsed time: 00:03.
    

  • Lifetime Qt Champion

    @saeedBaba I don't see -lopencv_imcodec in the linker call.
    Please post your current pro file, it looks like you forgot to put - in -opencv_imcodec -> should be -lopencv_imcodec
    And I think it should be: -lopencv_imgcodecs



  • @jsulm said in Symbols not found for architecture x86_64 MacOS Yosemite:

    -lopencv_imcodec

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++11
    
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
        main.cpp \
        dialog.cpp
    
    HEADERS += \
        dialog.h
    
    FORMS += \
        dialog.ui
    
    #INCLUDEPATH += /usr/local/Cellar/opencv/4.5.2_4/include/opencv4
    
    #LIBS += -L/usr/local/Cellar/opencv/4.5.2_4/lib \
    #     -lopencv_core \
    #     -lopencv_imgproc \
    #     -lopencv_features2d\
    #     -lopencv_highgui
    #     -lopencv_imcodec
    #     -lopencv_calib3d
    
    
    #INCLUDEPATH += /usr/local/include/opencv4
    
    #LIBS += -L/usr/local/lib \
    #     -lopencv_core \
    #     -lopencv_imgproc \
    #     -lopencv_features2d\
    #     -lopencv_highgui
    #     -lopencv_calib3d
    #     -lopencv_imcodec
    
    #QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    macx {
        INCLUDEPATH += /usr/local/include/opencv4
    
        QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
    
        LIBS += -L/usr/local/lib
        LIBS += -lopencv_core -lopencv_imgproc -lopencv_features2d -lopencv_highgui -lopencv_calib3d -lopencv_imcodec
    
    }
    

    LOG:

    /Users/apple/Qt6/6.1.1/clang_64/bin/qmake -o Makefile ../opencv_test_qmake/opencv_test_qmake.pro -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
    /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,/Users/apple/Qt6/6.1.1/clang_64/lib -o opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake main.o dialog.o moc_dialog.o   -F/Users/apple/Qt6/6.1.1/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_features2d -lopencv_highgui -lopencv_calib3d -lopencv_imcodec -framework QtWidgets -framework QtGui -framework AppKit -framework ImageIO -framework Metal -framework QtCore -framework DiskArbitration -framework IOKit -framework AGL -framework OpenGL   
    ld: library not found for -lopencv_imcodec
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake] Error 1
    15:39:26: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project opencv_test_qmake (kit: Desktop Qt 6.1.1 clang 64bit)
    When executing step "Make"
    15:39:26: Elapsed time: 00:00.
    

  • Lifetime Qt Champion

    @saeedBaba said in Symbols not found for architecture x86_64 MacOS Yosemite:

    -lopencv_imcodec

    -lopencv_imgcodecs



  • THANKS ALOT!

    IT IS FINALLY WORKING!!!!

    can you give me a reputation so I can post faster?

    one more question:
    How can I know what libraries to include for the future? how should I check?


  • Lifetime Qt Champion

    @saeedBaba said in Symbols not found for architecture x86_64 MacOS Yosemite:

    How can I know what libraries to include for the future? how should I check?

    In case of OpenCV you can see in the documentation URL: https://docs.opencv.org/3.4/d4/da8/group__imgcodecs.html and from the include header (at least in this case):

    #include <opencv2/imgcodecs.hpp>
    


  • @jsulm said in Symbols not found for architecture x86_64 MacOS Yosemite:

    https://docs.opencv.org/3.4/d4/da8/group__imgcodecs.html

    for example, I get the same error for this code:
    1- where should I check for what to include?

    #include "opencv2/core.hpp"
    #include "opencv2/imgproc.hpp"
    #include "opencv2/highgui.hpp"
    #include "opencv2/videoio.hpp"
    #include <iostream>
    
    using namespace cv;
    using namespace std;
    
    void drawText(Mat & image);
    
    int main()
    {
        cout << "Built with OpenCV " << CV_VERSION << endl;
        Mat image;
        VideoCapture capture;
        capture.open(0);
        if(capture.isOpened())
        {
            cout << "Capture is opened" << endl;
            for(;;)
            {
                capture >> image;
                if(image.empty())
                    break;
                drawText(image);
                imshow("Sample", image);
                if(waitKey(10) >= 0)
                    break;
            }
        }
        else
        {
            cout << "No capture" << endl;
            image = Mat::zeros(480, 640, CV_8UC1);
            drawText(image);
            imshow("Sample", image);
            waitKey(0);
        }
        return 0;
    }
    
    void drawText(Mat & image)
    {
        putText(image, "Hello OpenCV",
                Point(20, 50),
                FONT_HERSHEY_COMPLEX, 1, // font face and scale
                Scalar(255, 255, 255), // white
                1, LINE_AA); // line thickness and type
    }
    

    2- Is there any way to include the whole thing in .pro file and then just include required hpp in the cpp file? I do the same thing when using CMake.


  • Lifetime Qt Champion

    @saeedBaba said in Symbols not found for architecture x86_64 MacOS Yosemite:

    Is there any way to include the whole thing in .pro file

    You should only link what is really needed. Else you will have to provide libs which are not used by your app making your package unnecessary big.

    "I get the same error for this code" - if it is the same error, then the solution is also same.
    But I guess the error is not same? Please post the error.



  • Log file for the code with videocapture .

    16:21:02: Running steps for project opencv_test_qmake...
    16:21:02: Starting: "/Users/apple/Qt6/6.1.1/clang_64/bin/qmake" /usr/local/lib/C++Project/Qt6/opencv_test_qmake/opencv_test_qmake.pro -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
    Info: creating stash file /usr/local/lib/C++Project/Qt6/build-opencv_test_qmake-Desktop_Qt_6_1_1_clang_64bit-Debug/.qmake.stash
    16:21:03: The process "/Users/apple/Qt6/6.1.1/clang_64/bin/qmake" exited normally.
    16:21:03: Starting: "/usr/bin/make" -f /usr/local/lib/C++Project/Qt6/build-opencv_test_qmake-Desktop_Qt_6_1_1_clang_64bit-Debug/Makefile qmake_all
    make: Nothing to be done for `qmake_all'.
    16:21:03: The process "/usr/bin/make" exited normally.
    16:21:03: Starting: "/usr/bin/make" -j8
    /Users/apple/Qt6/6.1.1/clang_64/libexec/uic ../opencv_test_qmake/dialog.ui -o ui_dialog.h
    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../opencv_test_qmake -I. -I../../../../include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -F/Users/apple/Qt6/6.1.1/clang_64/lib -o main.o ../opencv_test_qmake/main.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -dM -E -o moc_predefs.h /Users/apple/Qt6/6.1.1/clang_64/mkspecs/features/data/dummy.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../opencv_test_qmake -I. -I../../../../include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -F/Users/apple/Qt6/6.1.1/clang_64/lib -o dialog.o ../opencv_test_qmake/dialog.cpp
    /Users/apple/Qt6/6.1.1/clang_64/libexec/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include /usr/local/lib/C++Project/Qt6/build-opencv_test_qmake-Desktop_Qt_6_1_1_clang_64bit-Debug/moc_predefs.h -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -I/usr/local/lib/C++Project/Qt6/opencv_test_qmake -I/usr/local/include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -I/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/usr/include -F/Users/apple/Qt6/6.1.1/clang_64/lib ../opencv_test_qmake/dialog.h -o moc_dialog.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++1z  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wall -Wextra -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../opencv_test_qmake -I. -I../../../../include/opencv4 -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtWidgets.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtGui.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/apple/Qt6/6.1.1/clang_64/mkspecs/macx-clang -F/Users/apple/Qt6/6.1.1/clang_64/lib -o moc_dialog.o moc_dialog.cpp
    /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,/Users/apple/Qt6/6.1.1/clang_64/lib -o opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake main.o dialog.o moc_dialog.o   -F/Users/apple/Qt6/6.1.1/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_features2d -lopencv_highgui -lopencv_calib3d -lopencv_imgcodecs -framework QtWidgets -framework QtGui -framework AppKit -framework ImageIO -framework Metal -framework QtCore -framework DiskArbitration -framework IOKit -framework AGL -framework OpenGL   
    
    
    Undefined symbols for architecture x86_64:
      "cv::VideoCapture::open(int, int)", referenced from:
          _main in main.o
      "cv::VideoCapture::VideoCapture()", referenced from:
          _main in main.o
      "cv::VideoCapture::~VideoCapture()", referenced from:
          _main in main.o
      "cv::VideoCapture::operator>>(cv::Mat&)", referenced from:
          _main in main.o
      "cv::VideoCapture::isOpened() const", referenced from:
          _main in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [opencv_test_qmake.app/Contents/MacOS/opencv_test_qmake] Error 1
    16:21:06: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project opencv_test_qmake (kit: Desktop Qt 6.1.1 clang 64bit)
    When executing step "Make"
    16:21:06: Elapsed time: 00:04.
    

  • Lifetime Qt Champion

    @saeedBaba

    #include <opencv2/videoio.hpp>
    

    So, it is -lopencv_videoio



  • Thanks.

    How did you find it?
    How should I find future libraries to include?


  • Lifetime Qt Champion

    @saeedBaba said in Symbols not found for architecture x86_64 MacOS Yosemite:

    How did you find it?

    From the include file name. This is very OpenCV specific, maybe there is some documentation/explanation in that project.



  • @jsulm said in Symbols not found for architecture x86_64 MacOS Yosemite:

    opencv2/videoio.hpp

    What I am asking is that, do you just google

    opencv2/videoio.hpp
    

    or there is a documentation link you look into?


  • Lifetime Qt Champion

    @saeedBaba I googled for cv::VideoCapture and got https://docs.opencv.org/3.4/d8/dfe/classcv_1_1VideoCapture.html where you can see the include:

    #include <opencv2/videoio.hpp>
    

    And in case of OpenCV it looks like a header file corresponds to a lib: videoio.hpp -> opencv_videoio
    But this is so in case of OpenCV, not necesserily every lib out there!

    Qt does it more clear: it tells you what to add to pro file to use a class. For example in https://doc.qt.io/qt-5/qwidget.html you can see:

    QT += widgets
    


  • @jsulm said in Symbols not found for architecture x86_64 MacOS Yosemite:

    https://docs.opencv.org/3.4/d8/dfe/classcv_1_1VideoCapture.html

    but this link does not mention anything about -lopencv_videoio
    How did you find that?


  • Lifetime Qt Champion

    @saeedBaba Again: I deduce the lib name from the include file.

    #include <opencv2/videoio.hpp>
    

    So, header file name is videoio.hpp, lib name is opencv_videoio



  • Hi there

    I need to install opencv on qt on windows device. I was wondering if you could give me a link to an instruction or tutorial, preferably one that foes not need to alter Cmake since I have had download issues with cmake before.

    Thanks


  • Lifetime Qt Champion

    @saeedBaba Official documentation is here: https://docs.opencv.org/3.4/d3/d52/tutorial_windows_install.html
    You should consider asking in an OpenCV forum if you have problems building it, as OpenCV has nothing to do with Qt.


Log in to reply