I prepare TagLib for use in my TagLib project as follows:
Windows 10
Build the Makefiles:
Open CMake GUI.
Set Paths.
"Where is the source code" and "Where to build the binaries"
Example, Both would be: C:\GitRoot\taglib
Tick: Advanced
Select: Configure
Select: Generator
Tick: Use default native compilers
Select: Finish
Wait until done.
If using ZLib, Scroll down.
(to the bottom of the list of options ... should go over them all)
Edit: ZLIB_INCLUDE_DIR
Edit: ZLIB_LIBRARY
Select: Generate
Build the project:
MinGW:
C:\GitRoot\taglib> gmake
Install the project:
MinGW:
C:\GitRoot\taglib> gmake install
I copy the above generated files into my Taglib project on Qt, so that now this is my taglibtest project folder structure:
then add the following files to my project:
F:*\taglibtest\taglib\lib\libtag.dll.a**
F:*\taglibtest\taglib\lib\libtag_c.dll.a**
as you can see below in tablibtest.pro
taglibtest.pro
QT += core
QT -= gui
CONFIG += c++11
TARGET = taglibtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/lib/ -llibtag.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/lib/ -llibtag.dlld
INCLUDEPATH += $$PWD/taglib/include
DEPENDPATH += $$PWD/taglib/include
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/lib/ -llibtag_c.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/lib/ -llibtag_c.dlld
INCLUDEPATH += $$PWD/taglib/include
DEPENDPATH += $$PWD/taglib/include
HEADERS += \
taglib/include/taglib/aifffile.h \
taglib/include/taglib/aiffproperties.h \
etc.... \
etc.... \
etc....
In the main:
**main.cpp**
#include <QCoreApplication>
#include <QDebug>
#include <taglib/include/taglib/fileref.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
TagLib::FileRef f("E:/Dire Straits - Sultans of Swing.mp3");
return a.exec();
}
I get the following error when I run the project:
:-1: error: cannot find -llibtag.dll
:-1: error: cannot find -llibtag_c.dll
collect2.exe:-1: error: error: ld returned 1 exit status
What am I missing in my project? Which files should I include in my project to use the Taglib Framework
Thank you all in advance.
Related
I'm trying to create a project that uses the TagLib library. I'm not really sure of how exactly to go about it.
I have downloaded TagLib 1.11.1.
I built it as follows:
Build zlib, by first having CMake create a Visual Studio solution file, then building this solution with Visual Studio:
mkdir build && cd build
cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="e:\workspace\lib\installed"
msbuild /P:Configuration=Debug INSTALL.vcxproj
msbuild /P:Configuration=Release INSTALL.vcxproj
Build TagLib much in the same way:
cd ....\taglib-1.11.1
mkdir build && cd build
cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="e:\workspace\lib\installed" -DZLIB_INCLUDE_DIR="e:\workspace\lib\installed\include" -DZLIB_LIBRARY="e:\workspace\lib\installed\lib\zlib.lib" -DWITH_ASF=on -DWITH_MP4=on -DBUILD_EXAMPLES=on
msbuild /P:Configuration=Release INSTALL.vcxproj
I create a simple Qt Console Application:
I then add tag.lib from the TagLib Build above in E:\workspace\lib\installed\lib using Qt
Qt -> Add Library -> Library Type (External Library) -> .......
main.cpp :
#include <QCoreApplication>
#include <QDebug>
#include <taglib/fileref.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
TagLib::FileRef f("D:/Dire Straits - Sultans of Swing.mp3");
return a.exec();
}
taglibtest.pro
QT += core
QT -= gui
CONFIG += c++11
TARGET = taglibtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltag
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltagd
else:unix: LIBS += -L$$PWD/taglib/builds/ -ltag
INCLUDEPATH += $$PWD/taglib/builds
DEPENDPATH += $$PWD/taglib/builds
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltag
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltagd
else:unix: LIBS += -L$$PWD/taglib/builds/ -ltag
INCLUDEPATH += $$PWD/taglib/builds
DEPENDPATH += $$PWD/taglib/builds
HEADERS += \
taglib/aifffile.h \
taglib/aiffproperties.h \
taglib/apefile.h \
taglib/apefooter.h \
taglib/apeitem.h \
taglib/apeproperties.h \
taglib/apetag.h \
taglib/asfattribute.h \
taglib/asffile.h \
taglib/asfpicture.h \
taglib/asfproperties.h \
etc....
etc....
I get the following errors whenever I try Building the project in Qt:
F:\taglibtest\main.cpp:-1: error: undefined reference to `_imp___ZN6TagLib8FileNameC1EPKc'
F:\taglibtest\main.cpp:-1: error: undefined reference to `_imp___ZN6TagLib7FileRefC1ENS_8FileNameEbNS_15AudioProperties9ReadStyleE'
F:\taglibtest\main.cpp:-1: error: undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
F:\taglibtest\main.cpp:-1: error: undefined reference to `_imp___ZN6TagLib7FileRefD1Ev'
:-1: error: release/main.o: bad reloc address 0x0 in section `.ctors'
:-1: error: final link failed: Invalid operation
collect2.exe:-1: error: error: ld returned 1 exit status
What should I do to fix this and get working with TagLib?
taglibtest.pro
QT += core
QT -= gui
CONFIG += c++11
TARGET = taglibtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltag
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltagd
else:unix: LIBS += -L$$PWD/taglib/builds/ -ltag
INCLUDEPATH += $$PWD/taglib/builds
DEPENDPATH += $$PWD/taglib/builds
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltag
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/taglib/builds/ -ltagd
else:unix: LIBS += -L$$PWD/taglib/builds/ -ltag
INCLUDEPATH += $$PWD/taglib/builds
DEPENDPATH += $$PWD/taglib/builds
HEADERS += \
taglib/aifffile.h \
taglib/aiffproperties.h \
taglib/apefile.h \
taglib/apefooter.h \
taglib/apeitem.h \
taglib/apeproperties.h \
taglib/apetag.h \
taglib/asfattribute.h \
taglib/asffile.h \
taglib/asfpicture.h \
taglib/asfproperties.h \
etc....
etc....
You have compiled TagLib and zlib with Visual Studio and you compile your project with mingw (at least that's what I can guess from error messages). This won't work. You need to compile all your libraries and apps with the very same compiler.
Visual Studio and gcc have different ABI's so gcc cannot see Visual's symbols.
M'kay so I'm new to Qt and I'm trying to include the boost/filesystem lib to my project. However, when I try to build it, I always get this error:
LNK1104: File "libboost_filesystem-vc140-mt-1_61.lib" cannot be
opened.
Now, I know that this library needs to be build beforehand, so, as described on the Boost-Website I made:
bootstrap
.\b2
and it built just fine. I also used the Qt dialog to add the libary to my project, my .pro-file looks like this:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ProjectName
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
someclass.cpp \
someclass2.cpp
HEADERS += mainwindow.h \
someclass.h \
someclass2.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/libarys -llibboost_filesystem-vc140-mt-1_61
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/libarys -llibboost_filesystem-vc140-mt-1_61
else:unix: LIBS += -L$$PWD/libarys -llibboost_filesystem-vc140-mt-1_61
INCLUDEPATH += $$PWD/boost
DEPENDPATH += $$PWD/boost
Apparently, I did something wrong, but I can't figure out, WHAT exactly it is. The internet knows the problem, but it seems there's no "easy" solution to it.
Turned out, my project didn't like the lib-version.
I rebuilt my lib files:
>b2 --build-dir="destination/directory" toolset=msvc --build-type=complete link=static threading=multi --with-filesystem stage
Then, I used the library in
release/link-static/runtime-link-static/threading-multi/
Which is:
libboost_filesystem-vc140-mt-s-1_61
And re-ran qmake for the .pro-file. Then built and executed the application and the error is gone.
I'm using QT(5)-Creator with 2 projects, that compile both with MinGW my C++ programs under Windows 7. One project generates a static library, and the other is just there to verify that the library is alright.
The error:
When building the library no errors are generated and it creates successfully the static lib MyClassName.a.
In turn, when trying to import the library, I get error messages durring building/compilation:
undefined reference to 'MyClassName::MyClassName()'
undefined reference to 'MyClassName::MyClassFunction()'
The files:
here's the main.cpp of my importer project
#include <QCoreApplication>
#include "MyClassName.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
MyClassName *mainThread = new MyClassName();
mainThread->MyClassFunction();
return a.exec();
}
and it's .pro file
QT += core
QT += widgets
QT -= gui
TARGET = TESTerase
CONFIG += console
CONFIG -= app_bundle
CONFIG +=extserialport
CONFIG +=staticlib
TEMPLATE = app
HEADERS += \
MyClassName.h
SOURCES += main.cpp
unix:!macx: LIBS += -L$$PWD/../MyClassName-Release/ -lMyClassName
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD/../MyClassName-Release/release
DEPENDPATH += $$PWD/../MyClassName-Release/release
unix:!macx: PRE_TARGETDEPS += $$PWD/../MyClassName-Release/release/MyClassName.a
btw I've used QT-Creator's include external library function
My guesses:
Since I'm able to [Strg+Click] the functions in the main, I assume the error is thrown by the Linker.
It may also be a manner of importing/creating/using libraries too, since I just started with that topic.
Anyways searching the Internet about it usually just results in the hint, to use the same compiler for both projects - which shouldn't matter in my case (since I'm building both projects with the same Creator and the same settings).
Has anybody an idea?
Thanks for your support
Kind Regards
[Update for Bogdans request]
the new .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2015-04-29T19:46:22
#
#-------------------------------------------------
QT += core
QT += widgets
QT -= gui
TARGET = TESTerase
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG +=extserialport
HEADERS += \
MyClassName.h
SOURCES += main.cpp
unix:!macx: LIBS += -L$$PWD/../MyClassName-Release/ -lMyClassName
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../MyClassName-Release/release/ -lMyClassName
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../MyClassName-Release/debug/ -lMyClassName
else:unix:!macx: LIBS += -L$$PWD/../MyClassName-Release/ -lMyClassName
INCLUDEPATH += $$PWD/../MyClassName-Release/release
DEPENDPATH += $$PWD/../MyClassName-Release/release
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/release/MyClassName.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/debug/MyClassName.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/release/MyClassName.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/debug/MyClassName.lib
else:unix:!macx: PRE_TARGETDEPS += $$PWD/../MyClassName-Release/MyClassName.a
Your .pro file defines library dependencies only for unix platform unix:!macx:. I suppose there should be also win32 for Windows.
Had the same problem just now. Build was working fine on macOS/OSX but not on Windows with the same codebase.
It was caused by the fact I was not exporting my symbols, which is necessary on Windows.
Use Q_DECL_EXPORT on functions when building the lib.
And use Q_DECL_IMPORT when using the functions from the lib.
Example how to do this here: https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application#Creating_a_shared_library
Solved the problem in my case, hope it helps!
ISSUE SOLVED (scroll down)
Im on windows 7 and compilling with MinGW.
I made a new Qt application in QtCreator 3.01 (Qt 5.2.1). I compile it, the empty application window pops up everything is awesome. But as soon as i use any other library (like boost or gtest) im starting getting these errors when compiling
cannot find -lqtmain
cannot find -lQt5Widgets
cannot find -lQt5Gui
cannot find -lQt5Core
ld returned 1 exit status
This is my .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2014-04-19T14:17:24
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Thermovision
TEMPLATE = app
include(Model/Model.pri)
include(Controller/Controller.pri)
include(View/View.pri)
include(Interface/Interface.pri)
SOURCES += \
main.cpp
HEADERS += \
logdebug.h
FORMS +=
OTHER_FILES += \
Model/Model.pri \
View/View.pri \
Controller/Controller.pri \
Interface/Interface.pri \
Globals/zGlobals.pri
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
INCLUDEPATH += $$PWD/../../../../../../../MinGW/msys/1.0/local/include
DEPENDPATH += $$PWD/../../../../../../../MinGW/msys/1.0/local/include
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../Downloads/boost_1_54_0/boost_1_54_0/stage/lib/ -lboost_thread-mgw48-mt-1_54
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../Downloads/boost_1_54_0/boost_1_54_0/stage/lib/ -lboost_thread-mgw48-mt-1_54d
this is the main.cpp
#include <iostream>
#include <QApplication>
#include "View/form.h"
#include <boost/thread.hpp>
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Form w;
w.show();
boost::thread b;
return a.exec();
}
when i comment usage of boost thread, the include and the part in .pro file responsible for finding boost thread library everything compiles again. Same when im trying to use gtest.
The odd thing is that I havent found any information regarding this issue anywhere on the internet :<
Can someone help me?
=================================================================================
[SOLVED]
ok so it seems qt wanted me to explicitly add the libraries into project. I used the built-in tool which generated the following output
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Core.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Cored.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Core.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Cored.lib
but im sure one can thin it down (im gonna stay with this)
Based on our comments and outcome, it seems that a quick solution is to add the libraries explicitly that you wish to use. It will generate something like this in the background, so basically using static libraries as opposed to dynamic:
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Core.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Cored.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Core.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Cored.lib
Alternatively, which I would personally suggest more is to add the following line for now in your project file to get this working with dynamic libraries rather than static to make your application binary go up to the hill:
LIBS += -L$$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/
I have trouble in making an application which communicates FTDI devices via D2xx driver.There is some example project for Visual Studio in ftdi's website. But there isn't for QtCreator. I chose QtCreator as c++ IDE because my application needs Qt framework.
I put ftd2xx.h and ftd2xx.lib in the Qt project directory.
(ftd2xx.lib is static library, which were originally located in [download-folder]\CDM v2.08.30 for Windows 8.1\Static\i386)
When sample source code was compiled, I got following error message.
Error message when I use .pro file(1).
LNK1104: cannot open file 'ftd2xx.lib'
Error message when I use .pro file(2).
error: Assignment needs exactly one word on the left hand side.
How should I correct Qt project setup in order to utilizes ftd2xx library?
My source code and .pro file is here.
[main.cpp]
#include <QCoreApplication>
#include <windows.h>
#include "ftd2xx.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
FT_HANDLE ftHandle;
FT_STATUS ftStatus;
ftStatus = FT_Open(0,&ftHandle);
return a.exec();
}
[.pro file if the checkbox is enabled] ---(1)
#-------------------------------------------------
#
# Project created by QtCreator 2014-02-11T18:51:08
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = D2XXtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
HEADERS += ftd2xx.h
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/ -lftd2xx
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/ -lftd2xxd
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/libftd2xx.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/libftd2xxd.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/ftd2xx.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/ftd2xxd.lib
[.pro file if the checkbox is NOT enabled] ---(2)
#-------------------------------------------------
#
# Project created by QtCreator 2014-02-11T18:51:08
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = D2XXtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
HEADERS += ftd2xx.h
win32: LIBS += -L$$PWD/ -lftd2xx
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
win32:!win32-g++ PRE_TARGETDEPS += $$PWD/ftd2xx.lib
else:win32-g++: PRE_TARGETDEPS += $$PWD/libftd2xx.a
Any help would be appreciated. Thanks in advance.
[Note]
OS: Windows 8.1
IDE: Qt Creator 3.0.0
Compiler: MSVC2012(32bit)
Target device: ft232hl
[Additional Note]
The configuration of "Add Library" is following.
If I enable the checkbox "Add "d" suffix for debug version, then I got error message about LNK1104. Otherwise, I got different error message.
My hunch is that you've made a typo in your error message, and the real error message reads as follows:
LNK1104: cannot open file 'ftd2xxd.lib'
See that d there? It doesn't belong, there's no ftd2xxd.lib. You need to change any references to ftd2xxd.lib back to ftd2xx.lib, re-run qmake, and you should be all set. Otherwise your .pro file seems correct.
After your edit, you gave a .pro file with the "checkbox enabled". That's certainly not true, since the contents you show imply that the checkbox is disabled, not enabled.
Anyway, we don't care what the dialog box settings are. Just show the actual .pro file that you really use, because so far I don't know which one you do use, and I don't know if you've re-run qmake after the .pro file was changed.
Are you sure that the ftd2xx.lib file is actually in the same folder where the .pro file is?