Programm crashes using Taglib - qt

I am trying to use Taglib with Qt5.7. But my programm crashes:
The GDB process terminated unexpectedly (exit code 0).
Cannot continue debugged process: The program is not being run.
During startup program exited with code 0xc0000135
There did not seem to be any error messages while building Taglib.
*.pro file
QT += core
QT -= gui
CONFIG += c++11
TARGET = untitled2
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
TAGLIBDIR = $$quote(D:/D/Programmieren/Libraries/taglib)
INCLUDEPATH += $$quote( $${TAGLIBDIR}/include )
LIBS += -L$$quote($${TAGLIBDIR}/lib) -ltag
main.cpp
#include <QCoreApplication>
#include <taglib/tag.h>
#include <taglib/fileref.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
TagLib::FileRef ref("D:/D/Media/Musik/Disturbed/The Sickness/Disturbed - Stupify.mp3");
return a.exec();
}
Edit:
I created Taglib-buildfiles using CMake-GUI and native MinGW-Installation since I did not manage to create them using Qt. My OS is Windows 10 x64 Education and I use Qt-Creator. I downloaded the latest Taglib-Release (1.11.1)
Why I cant create buildfiles using CMake:
First some *dll-files where missing, i coud solve that by just copying the ones from native MinGW-Installation to QT-MinGW.
Second I could not find any of the *exe-files desired by CMake so i could not change the path from native MinGW-Installation.
After rebuilding Taglib in debugmode I get this errors:
main.cpp:10: error: undefined reference to `_imp___ZN6TagLib8FileNameC1EPKc'
main.cpp:10: error: undefined reference to `_imp___ZN6TagLib7FileRefC1ENS_8FileNameEbNS_15AudioProperties9ReadStyleE'
main.cpp:11: error: undefined reference to `_imp___ZNK6TagLib7FileRef3tagEv'
main.cpp:11: error: undefined reference to `_imp___ZNK6TagLib6String9toCStringEb'
main.cpp:11: error: undefined reference to `_imp___ZN6TagLib6StringD1Ev'
main.cpp:10: error: undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
main.cpp:11: error: undefined reference to `_imp___ZN6TagLib6StringD1Ev'
main.cpp:10: error: undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
collect2.exe:-1: error: error: ld returned 1 exit status

Solved it by using new version (5.8 instead of 5.7) of Qt.

Related

CLion setting up Qt and getting numerous errors stating 'undefined reference to '_imp___ZN

I am getting several undefined reference errors with using Qt. I am using MinGW as my compiler and I am using Qt version 5.15.2.
This is my CMake file:
cmake_minimum_required(VERSION 3.17)
project(jerseytraffic)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(QT_VERSION 5)
set(REQUIRED_LIBS Core Gui Widgets)
set(REQUIRED_LIBS_QUALIFIED Qt5::Core Qt5::Gui Qt5::Widgets)
set(CMAKE_PREFIX_PATH "A:\\CppProjects\\CppLibraries\\Qt5\\5.15.2\\mingw81_64\\lib\\cmake\\")
find_package(Qt${QT_VERSION} COMPONENTS ${REQUIRED_LIBS} REQUIRED)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} ${REQUIRED_LIBS_QUALIFIED})
This is main.cpp:
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
qDebug() << "Hello World";
return QCoreApplication::exec();
}
These are the errors I'm getting:
CMakeFiles\jerseytraffic.dir/objects.a(main.cpp.obj): In function `main':
A:/CppProjects/jerseytraffic/main.cpp:5: undefined reference to `_imp___ZN16QCoreApplicationC1ERiPPci'
A:/CppProjects/jerseytraffic/main.cpp:6: undefined reference to `_imp___ZNK14QMessageLogger5debugEv'
A:/CppProjects/jerseytraffic/main.cpp:6: undefined reference to `_imp___ZN6QDebugD1Ev'
A:/CppProjects/jerseytraffic/main.cpp:7: undefined reference to `_imp___ZN16QCoreApplication4execEv'
A:/CppProjects/jerseytraffic/main.cpp:5: undefined reference to `_imp___ZN16QCoreApplicationD1Ev'
A:/CppProjects/jerseytraffic/main.cpp:6: undefined reference to `_imp___ZN6QDebugD1Ev'
A:/CppProjects/jerseytraffic/main.cpp:5: undefined reference to `_imp___ZN16QCoreApplicationD1Ev'
CMakeFiles\jerseytraffic.dir/objects.a(main.cpp.obj): In function `ZN7QString8fromUtf8EPKci':
A:/CppProjects/CppLibraries/Qt5/5.15.2/mingw81_64/include/QtCore/qstring.h:706: undefined reference to `_imp___ZN7QString15fromUtf8_helperEPKci'
CMakeFiles\jerseytraffic.dir/objects.a(main.cpp.obj): In function `ZN6QDebug10maybeSpaceEv':
A:/CppProjects/CppLibraries/Qt5/5.15.2/mingw81_64/include/QtCore/qdebug.h:129: undefined reference to `_imp___ZN11QTextStreamlsEc'
CMakeFiles\jerseytraffic.dir/objects.a(main.cpp.obj): In function `ZN6QDebuglsEPKc':
A:/CppProjects/CppLibraries/Qt5/5.15.2/mingw81_64/include/QtCore/qdebug.h:159: undefined reference to `_imp___ZN11QTextStreamlsERK7QString'
CMakeFiles\jerseytraffic.dir/objects.a(main.cpp.obj): In function `ZN15QTypedArrayDataItE10deallocateEP10QArrayData':
A:/CppProjects/CppLibraries/Qt5/5.15.2/mingw81_64/include/QtCore/qarraydata.h:239: undefined reference to `_imp___ZN10QArrayData10deallocateEPS_jj'
This is what I get in the CMake output when it reloads:
"A:\ProgramFiles\CLion 2020.3.2\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" A:\CppProjects\jerseytraffic
-- Configuring done
-- Generating done
-- Build files have been written to: A:/CppProjects/jerseytraffic/cmake-build-debug
[Finished]
One thing I have tried is modifying the cmake file by adding this around the add_executable line, but it did not make any changes:
find_package(Qt5 COMPONENTS Core REQUIRED)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} Qt5::Core)
Some other things that I have attempted include:
set(CMAKE_BUILD_TYPE "Debug -G \"MinGW Makefiles\"")
set(CMAKE_CXX_COMPILER "C:\\MinGW\\bin\\gcc.exe")
option(G "MinGW Makefiles")
I added this CMake option in Settings > Build, Execution, Deployment > CMake > Debug > CMake options: -G "MinGW Makefiles" %*
However, none of these seemed to fix the error.

build openCV & Qt project and link error:undefined reference and bad reloc address 0x1 in section

I have built the release version of openCV 4.5.1 shared library with CMake 3.91.2 & MinGW-W64 GCC-6.4.0 i686-posix-dwarf with default compile config.
Tried to use the libraries with Qt 5.4 & MinGW 4.9.1 32 bit.
I'm in Windows 10 64 bit.
Here's my .pro:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test05
TEMPLATE = app
CONFIG += c++11
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += $$PWD/include
LIBS += -L$$PWD/lib/opencv -lopencv_highgui451.dll -lopencv_core451.dll -lopencv_imgcodecs451.dll -lopencv_imgproc451.dll
Here's main.cpp
#include "mainwindow.h"
#include <QApplication>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int main(int argc, char** argv) {
Mat image = imread("D:\\test.jpg");
namedWindow("window", WINDOW_AUTOSIZE );
imshow("window",image);
waitKey(0);
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
Here's build output:
E:\workspace\test05\main.cpp:-1: error: undefined reference to `cv::imread(std::string const&, int)'
E:\workspace\test05\main.cpp:-1: error: undefined reference to `cv::namedWindow(std::string const&, int)'
E:\workspace\test05\main.cpp:-1: error: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
:-1: error: release/main.o: bad reloc address 0x1 in section `.text$_ZN7cvflann7anyimpl21typed_base_any_policyIbE4typeEv[__ZN7cvflann7anyimpl21typed_base_any_policyIbE4typeEv]'
collect2.exe:-1: error: error: ld returned 1 exit status
I have googled a lot,these two questions seems close to my situation but could not solve my problem:
Undefined reference to cv::imread(std::string const&, int)
C++ Qt MingW bad reloc 0xc address in section rdata
EDIT:
Thank for your advice,I deleted the GUI part and tried these:
LIBS += E:\workspace\test05\lib\opencv\libopencv_core451.dll.a
LIBS += E:\workspace\test05\lib\opencv\libopencv_core451.dll
Both don't work,the issues keep the same as above.I don't know if I built the shared library correctly or it's a simple link error?

OpenCV 2.4.6 with QT 5.1.0 Errors

I am trying to get OpenCv2.4.6 to work with QT5.1.0
I've followed this Guide so far Qt creator 5.0.1 with OpenCv 2.3.4 on windows
Unfortunatly after finishing trying out the sample Application(Display an Image using OpenCv in the QtCreator I get these Errors:
[Project-Path]\main.o:-1: In function `main':
[Project-Path]\main.cpp:8: error: undefined reference to `cv::imread(std::string const&, int)'
[Project-Path]\main.cpp:9: error: undefined reference to `cv::namedWindow(std::string const&, int)'
[Project-Path]\main.cpp:10: error: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
[Project-Path]\main.cpp:10: error: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
[Project-Path]\main.cpp:11: error: undefined reference to `cv::waitKey(int)'
[Project Build Path Desktop Debug]\debug\main.o:-1: In function `ZN2cv3MatD1Ev':
[OpenCV/Install/include]\opencv2\core\mat.hpp:278: error: undefined reference to `cv::fastFree(void*)'
[Project Build Path Desktop Debug]\debug\main.o:-1: In function `ZN2cv3Mat7releaseEv':
[OpenCV/Install/include]\opencv2\core\mat.hpp:367: error: undefined reference to `cv::Mat::deallocate()'
collect2.exe:-1: error: error: ld returned 1 exit status
the "[]" Paths are my formatting and supposed to help keep track .
main.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main() {
// read an image
Mat image = imread("img.jpg");
namedWindow("My Image");
imshow("My Image", image);
waitKey(5000);
return 1;
}
myFirstOpenCVProject.pro
QT += core
QT -= gui
TARGET = myFirstOpenCVProject
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:/qt/OpenCV246_bin/install/include
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_core246.dll
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_highgui246.dll
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_imgproc246.dll
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_features2d246.dll
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_calib3d246.dll
Can you help me resolve this?
I can't find any solutions that apply to my case ...
-L is to add directories to the search path. The actual libs are added via -l. The correct line would be:
LIBS += -LC:/qt/OpenCV246_bin/install/lib -llopencv_core246 -llopencv_highgui246 ...
I think you are missing the static libs of opencv:
opencv_core246.lib
opencv_highgui246.lib
opencv_video246.lib
opencv_ml26d.lib
opencv_legacy246.lib
opencv_imgproc246.lib
opencv_whatever.lib
Don t know the pro commands very well. Maybe something like:
LIBS += -Lc:/blabla/opencv_imgproc246.lib

undefined reference to `QSound::play(QString const&)'

Trying to play sound, via QSound (QT 5, Ubuntu 13.04)
The code:
#include <QtMultimedia/QSound>
void MainWindow::on_pushButton_2_clicked()
{
QSound::play("sounds/win.wav");
}
And getting 2 errors:
undefined reference to `QSound::play(QString const&)'
collect2: error: ld returned 1 exit status
What am i doing wrong ? In documentation here i see the same code.
You need to include the multimedia module. Add this to your .pro file:
QT += multimedia

Own static linking plugin

I have plugin and i want static link it with my app.
In plugin.pro file i have:
TEMPLATE = lib
CONFIG += staticlib
In plugin.cpp:
Q_EXPORT_PLUGIN2(plugin, pluginClass)
Of course TARGET in .pro file is the same as plugin name.
In myapp.pro file:
LIBS += libplugin.a
main.cpp:
#include <QtGui/QApplication>
#include <QtPlugin>
Q_IMPORT_PLUGIN(plugin)
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
...
return a.exec();
}
Plugin compiles without errors, i got *.a and *.o files, so i copied *.a file to myapp directory and when i trying compile i get error like this:
cannot find -lmyplugin.a
collect2: ld returned 1 exit status
So i gave full path to libplugin.a in myapp.pro file and i got in the line with Q_IMPORT_PLUGIN error:
undefined reference to `qt_plugin_instance_plugin()'
and much errors like this:
undefined reference to `pluginClass::function()'
I included *.h file of my plugin.
What am I doing wrong?
In your plugin .pro file use this code:
CONFIG += plugin static
instead of
CONFIG += staticlib

Resources