Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved how to add -D_UNICODE to a qt project?

    General and Desktop
    2
    3
    1219
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      phirestalker last edited by phirestalker

      I am trying to use libmediainfo with my qt program. It is giving an undefined sympbols error and after searching it seems my project is supposed to have -D_UNICODE added to cmake options. I do not know where to set this with Qt Creator.

      here is where I found that I need -D_UNICODE
      https://sourceforge.net/p/mediainfo/discussion/297610/thread/49c9122d/#0e3a

      the exact error is as follows

      Undefined symbols for architecture x86_64:
        "MediaInfoLib::MediaInfo::Open(std::string const&)", referenced from:
            MainWindow::on_dupeslistWidget_itemClicked(QListWidgetItem*) in mainwindow.o
        "MediaInfoLib::MediaInfo::Option(std::string const&, std::string const&)", referenced from:
            MainWindow::on_dupeslistWidget_itemClicked(QListWidgetItem*) in mainwindow.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: *** [VideoTwin.app/Contents/MacOS/VideoTwin] Error 1
      18:32:29: The process "/usr/bin/make" exited with code 2.
      Error while building/deploying project VideoTwin (kit: default)
      When executing step "Make"
      

      Here is my .pro file

      QT       += core gui
      QT += sql
      QT += concurrent
      QT += multimedia multimediawidgets
      
      INCLUDEPATH += /usr/local/include /usr/local/Cellar/opencv3/3.1.0_1/include/ $$[QT_INSTALL_PREFIX]/src/3rdparty/sqlite
      LIBS += -L/usr/local/Cellar/opencv3/3.1.0_1/lib -L/usr/local/lib -lmediainfo -lzen -lz -lpthread -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_cvv -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core
      
      
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      TARGET = VideoTwin
      TEMPLATE = app
      
      
      SOURCES += main.cpp\
              mainwindow.cpp \
          preferencsedialog.cpp \
          myqlistwidget.cpp \
          $$[QT_INSTALL_PREFIX]/src/3rdparty/sqlite/sqlite3.c \
          matchpair.cpp
      
      HEADERS  += mainwindow.h \
          preferencsedialog.h \
          myqlistwidget.h \
          matchpair.h
      
      FORMS    += mainwindow.ui \
          preferencsedialog.ui
      
      RESOURCES += \
          resources.qrc
      

      in my header file

      #include <MediaInfo/MediaInfo.h>
      
      

      and offending lines in cpp file

          MediaInfoLib::MediaInfo media_info;
          media_info.Option("Internet","No");
          media_info.Open(item->data(Qt::UserRole + FilepathRole).toString().toStdString());
          QFileInfo file(item->data(Qt::UserRole + FilepathRole).toString());
          QString temp = media_info.Inform().c_str();
          ui->video_info->setText(temp);
          ui->video_info->show();
      
      1 Reply Last reply Reply Quote 0
      • P
        phirestalker last edited by phirestalker

        ok I think I found how to add it, but it doesn't work. I tried:

        QMAKE_CXXFLAGS += -D_UNICODE -DUNICODE
        
        

        in my .pro file

        EDIT: forgot to run qmake, now it has new errors

        /Users/phire/Documents/workspace/VideoTwin/mainwindow.cpp:830: error: no viable conversion from 'String' (aka 'basic_string<MediaInfoLib::Char>') to 'QString'
            QString temp = media_info.Inform();
                    ^      ~~~~~~~~~~~~~~~~~~~
        

        I changed the cpp code to:

            MediaInfoLib::MediaInfo media_info;
            media_info.Option(L"Internet",L"No");
            media_info.Open(item->data(Qt::UserRole + FilepathRole).toString().toStdWString());
            QFileInfo file(item->data(Qt::UserRole + FilepathRole).toString());
            QString temp = media_info.Inform().data();
            ui->video_info->setText(temp);
            ui->video_info->show();
        

        so now only get the one error.

        How do i store the return value in a QString?

        kshegunov 1 Reply Last reply Reply Quote 0
        • kshegunov
          kshegunov Moderators @phirestalker last edited by

          @phirestalker

          /Users/phire/Documents/workspace/VideoTwin/mainwindow.cpp:830: error: no viable conversion from 'String' (aka 'basic_stringMediaInfoLib::Char') to 'QString'

          It looks like you're mixing standard strings with Qt strings. You can make the conversions with QString::fromStdString and QString::toStdString or their counterparts for multi-byte strings.

          Kind regards.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply Reply Quote 0
          • First post
            Last post