Encounter errors when compiling program using QT5.6 on windows 10 - c++

I want to compile a program called uartassistant using QT5.6 on windows 10,I encountered this error:
g++ -Wl,-subsystem,windows -mthreads -o debug\uartassistant.exe
debug/main.o debug/dialog.o debug/hled.o debug/moc_dialog.o
debug/moc_hled.o -lmingw32 -LF:\qt\5.6\mingw49_32\lib
F:\qt\5.6\mingw49_32\lib\libqtmaind.a -LC:\utils\postgresql\pgsql\lib
-LC:\utils\my_sql\my_sql\lib -lshell32 -LE:\uartassistannew\uartassistant\build -lqextserialportd1 -LE:\uartassistannew\uartassistant\analogwidgets -lanalogwidgets F:\qt\5.6\mingw49_32\lib\libQt5Widgetsd.a
F:\qt\5.6\mingw49_32\lib\libQt5Quickd.a
F:\qt\5.6\mingw49_32\lib\libQt5Guid.a
F:\qt\5.6\mingw49_32\lib\libQt5Qmld.a
F:\qt\5.6\mingw49_32\lib\libQt5Networkd.a
F:\qt\5.6\mingw49_32\lib\libQt5Cored.a
E:\uartassistannew\uartassistant\analogwidgets/libanalogwidgets.a(manometer.o):manometer.cpp:(.text+0x44a):
undefined reference to _imp___ZNK7QString3argEdiciRK5QChar'
E:\uartassistannew\uartassistant\analogwidgets/libanalogwidgets.a(manometer.o):manometer.cpp:(.text+0x11f8):
undefined reference to_imp___ZNK7QString3argEdiciRK5QChar'
E:\uartassistannew\uartassistant\analogwidgets/libanalogwidgets.a(manometer.o):manometer.cpp:(.text+0x1570):
undefined reference to _imp___ZNK11QMetaObject2trEPKcS1_'
E:\uartassistannew\uartassistant\analogwidgets/libanalogwidgets.a(manometer.o):manometer.cpp:(.text+0x178a):
undefined reference to_imp___ZNK11QMetaObject2trEPKcS1_'
F:/qt/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
E:\uartassistannew\uartassistant\analogwidgets/libanalogwidgets.a(manometer.o):
bad reloc address 0x24 in section
`.text$ZplRK7QStringS1[__ZplRK7QStringS1_]' collect2.exe: error: ld
returned 1 exit status Makefile.Debug:71: recipe for target
'debug\uartassistant.exe' failed mingw32-make[1]: *
[debug\uartassistant.exe] Error 1 mingw32-make[1]: Leaving directory
'E:/uartassistannew/build-uartassistant-Desktop_Qt_5_6_0_MinGW_32bit-Debug'
makefile:34: recipe for target 'debug' failed mingw32-make: *
[debug] Error 2 Error while building/deploying project uartassistant
(kit: Desktop Qt 5.6.0 MinGW 32bit) When executing step "Make"
12:14:13: Elapsed time: 00:18.
I compiled the same program on windows 7 using QT,no error happened.
Anyone can help me deal with it?
Thanks.

Related

undefined reference compiling taskwarrior on arm chromebook

I tried to build task-2.5.1 on my armv81 chromebook inside a termux session. It didn't work due build dependencies so I installed them then uncompressed and started in a fresh new directory. When I ran make VERBOSE=1 I got an undefined reference to __atomic_fetch_add_4 when linking...
[ 98%] Linking CXX executable lex
cd /data/data/com.termux/files/home/src/task-2.5.1/src && /data/data/com.termux/files/usr/bin/cmake -E cmake_link_script CMakeFiles/lex_executable.dir/link.txt --verbose=1
/data/data/com.termux/files/usr/bin/c++ -Wall -Wsign-compare -Wreturn-type -std=c++11 -stdlib=libc++ -O3 -DNDEBUG -rdynamic CMakeFiles/lex_executable.dir/lex.cpp.o -o lex libtask.a commands/libcommands.a columns/libcolumns.a libtask.a -lgnutls -luuid
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: libtask.a(Nibbler.cpp.o): in function `Nibbler::Nibbler(Nibbler const&)':
Nibbler.cpp:(.text+0x8c): undefined reference to `__atomic_fetch_add_4'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: libtask.a(Nibbler.cpp.o): in function `Nibbler::operator=(Nibbler const&)':
Nibbler.cpp:(.text+0xe0): undefined reference to `__atomic_fetch_add_4'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: Nibbler.cpp:(.text+0x104): undefined reference to `__atomic_fetch_add_4'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: libtask.a(Nibbler.cpp.o): in function `Nibbler::~Nibbler()':
Nibbler.cpp:(.text+0x174): undefined reference to `__atomic_fetch_add_4'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/CMakeFiles/lex_executable.dir/build.make:90: src/lex] Error 1
make[2]: Leaving directory '/data/data/com.termux/files/home/src/task-2.5.1'
make[1]: *** [CMakeFiles/Makefile2:175: src/CMakeFiles/lex_executable.dir/all] Error 2
make[1]: Leaving directory '/data/data/com.termux/files/home/src/task-2.5.1'
make: *** [Makefile:152: all] Error 2
I found this discussion about undefined references in arm builds. I tried adding a -latomic to CMakeFiles/task_executable.dir/link.txt but it didn't change the output.
Any ideas how to fix this?
Many thanks to wbsch in this issue (posted just after this one) for the link to the known fix which was successful on my machine, removing the three lines from CMakeLists.txt.

collect2.exe: error: ld returned 5 exit status

I've recently updated all msys2 packages and now I can't build my project.
The error occurs at the moment of linking one of .dlls - target_library.dll.
The error message isn't clear to me. What does status 5 mean?
collect2.exe: error: ld returned 5 exit status
Full message:
g++ -Wl,-s,--relax,--gc-sections -shared -Wl,-subsystem,windows -mthreads -Wl,--out-implib,C:/msys64/workspace/Project_Root_Directory/project/src/../build/release/plugins/libtarget_library.dll.a -o ../../../../build/release/plugins/target_library.dll object_script.target_library.Release -lglu32 -lopengl32 -luser32 -LC:/msys64/workspace/Project_Root_Directory/project/build/release -LC:/msys64/workspace/Project_Root_Directory/project/third-party/out/lib -LC:/msys64/workspace/Project_Root_Directory/project/deps/lib -lexif -ldecimal -lsqlite3 -lutils -LC:/Python35/libs -lpython35 -lkmlbase -lkmlengine -lkmldom -lkmlxsd -lminizip -luriparser -lkmlconvenience -lcore -lrender -lraster -lgui -LC:/msys64/workspace/Project_Root_Directory/project/deps/lib/target_library/win64 -LC:/msys64/mingw64/lib C:/msys64/mingw64/lib/libQt5Widgets.dll.a C:/msys64/mingw64/lib/libQt5WinExtras.dll.a C:/msys64/mingw64/lib/libQt5Gui.dll.a C:/msys64/mingw64/lib/libQt5Network.dll.a C:/msys64/mingw64/lib/libQt5Concurrent.dll.a C:/msys64/mingw64/lib/libQt5Xml.dll.a C:/msys64/mingw64/lib/libQt5Core.dll.a
collect2.exe: error: ld returned 5 exit status
make[4]: *** [Makefile.Release:159: ../../../../build/release/plugins/target_library.dll] Error 1
make[4]: Leaving directory '/workspace/Project_Root_Directory/project/src/modules/plugins/target_library'
make[3]: Leaving directory '/workspace/Project_Root_Directory/project/src/modules/plugins/target_library'
make[2]: *** [Makefile:384: sub-target_library-make_first] Error 2
make[2]: Leaving directory '/workspace/Project_Root_Directory/project/src/modules/plugins'
make[1]: *** [Makefile:297: sub-plugins-make_first] Error 2
make[1]: Leaving directory '/workspace/Project_Root_Directory/project/src/modules'
make: *** [Makefile:44: sub-modules-make_first] Error 2
gcc 7.1.0, Qt5 5.9.1, qmake, Win7 x64
I had the same issue.
I link my project with static library.
After mingw64 upgrade, my project stoped building with the same error.
I found out that debug version built successfully. So i compared linker flags. In release version Qt add this flags "-Wl,-s,--relax,--gc-section".
I couldn't find any information about "-s" flag, but due to this link i figured out that -gc-section flag was the reason of fail.
I added the following code to my .pro-file, and it worked
mingw {
contains(QT_ARCH, x86_64): {
LIBS+=-Wl,--no-gc-sections
}
}
Just in case someone finds this due the same problem, please, add the following flag to your compiler -Wl,--verbose (or --verbose to the linker). This will show which library was not found or give you more information about the problem.

GLFW MinGW link error

I've been attempting to test out GLFW with C++ for quite a while and am having constant linker issues. I am fairly new to C++, although I have experience in Java and C#, working directly with the compiler is fairly new to me. Here's my setup information.
IDE: Qt Creator
OS: Windows 7 64-bit
Compiler: MinGW32 4.8.1
01:23:26: Starting: "C:\MinGW\bin\mingw32-make.exe"
C:/MinGW/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'A:/workspace_cpp/Test-Debug'
g++ -Wl,-subsystem,console -mthreads -o debug\Test.exe debug/main.o -lglfw3 -lopengl32
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.::(.text+0x2c7): undefined reference to `CreateDCW#16'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x358): undefined reference to `GetDeviceCaps#8'
Makefile.Debug:77: recipe for target 'debug\Test.exe' failed
mingw32-make[1]: Leaving directory 'A:/workspace_cpp/Test-Debug'
Makefile:34: recipe for target 'debug' failed
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x370): undefined reference to `GetDeviceCaps#8'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor .c:(.text+0x39e): undefined reference to `DeleteDC#4'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj): bad reloc address 0x20 in section `.eh_frame'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
The code I'm testing is the code on the GLFW Documentation Page, I'm using my own build of GLFW, and have already tried this and several other potential solutions. I have tried using the prebuilt GLFW mingw libraries but I couldn't get them to work.
The solution as posted by enhzflep was to include to gdi32 library when compiling, making all the necessary linkers -lglfw3 -lgdi32 -lopengl32, as the missing methods, CreateDCW, GetDeviceCaps and DeleteDC are all inside of libgdi32.a in the MinGW lib folder C:\MinGW\lib\libgdi32.a in this case.

Qt 5.0.2 + Mingw-builds (4.8.1) webkit linkage error

I am trying to build Qt 5.0.2 with Mingw-builds (4.8.1), but during webkit building i have linking error:
C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/release/libWebKit1.a(FullScreenVideoQt.o):FullScreenVideoQt.cpp:(.text+0x143): undefined reference to `WebCore::HTMLMediaElement::platformMedia() const'
C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/release/libWebKit1.a(FullScreenVideoQt.o):FullScreenVideoQt.cpp:(.text+0x19e): undefined reference to `WebCore::HTMLMediaElement::platformMedia() const'
C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/release/libWebKit1.a(FullScreenVideoQt.o):FullScreenVideoQt.cpp:(.text+0xe5): undefined reference to `WebCore::HTMLMediaElement::exitFullscreen()'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/release/libWebKit1.a(FullScreenVideoQt.o): bad reloc address 0x0 in section `.pdata'
collect2.exe: error: ld returned 1 exit status
Makefile.api.Release:81: recipe for target '..\lib\Qt5WebKit.dll' failed
mingw32-make[4]: *** [..\lib\Qt5WebKit.dll] Error 1
mingw32-make[4]: Leaving directory 'c:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source'
Makefile.api:52: recipe for target 'release-all' failed
mingw32-make[3]: *** [release-all] Error 2
mingw32-make[3]: *** Waiting for unfinished jobs....
C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/debug/libWebKit1d.a(FullScreenVideoQt.o):FullScreenVideoQt.cpp:(.text+0x94): undefined reference to `WebCore::ChromeClientQt::createFullScreenVideoHandler()'
C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/debug/libWebKit1d.a(FullScreenVideoQt.o):FullScreenVideoQt.cpp:(.text+0x163): undefined reference to `WebCore::HTMLMediaElement::platformMedia() const'
C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/debug/libWebKit1d.a(FullScreenVideoQt.o):FullScreenVideoQt.cpp:(.text+0x1c7): undefined reference to `WebCore::HTMLMediaElement::platformMedia() const'
C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/debug/libWebKit1d.a(FullScreenVideoQt.o):FullScreenVideoQt.cpp:(.text+0x293): undefined reference to `WebCore::HTMLMediaElement::platformMedia() const'
C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/debug/libWebKit1d.a(FullScreenVideoQt.o):FullScreenVideoQt.cpp:(.text+0x122): undefined reference to `WebCore::HTMLMediaElement::exitFullscreen()'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source/WebKit/debug/libWebKit1d.a(FullScreenVideoQt.o): bad reloc address 0x0 in section `.pdata'
collect2.exe: error: ld returned 1 exit status
Makefile.api.Debug:81: recipe for target '..\lib\Qt5WebKitd.dll' failed
mingw32-make[4]: *** [..\lib\Qt5WebKitd.dll] Error 1
mingw32-make[4]: Leaving directory 'c:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source'
Makefile.api:38: recipe for target 'debug-all' failed
mingw32-make[3]: *** [debug-all] Error 2
mingw32-make[3]: Leaving directory 'c:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source'
Makefile.QtWebKit:43: recipe for target 'sub-api-pri-all-ordered' failed
mingw32-make[2]: *** [sub-api-pri-all-ordered] Error 2
mingw32-make[2]: Leaving directory 'c:/qt-everywhere-opensource-src-5.0.2/qtwebkit/Source'
Makefile:221: recipe for target 'sub-Source-QtWebKit-pro-all-ordered' failed
mingw32-make[1]: *** [sub-Source-QtWebKit-pro-all-ordered] Error 2
mingw32-make[1]: Leaving directory 'c:/qt-everywhere-opensource-src-5.0.2/qtwebkit'
Makefile:233: recipe for target 'module-qtwebkit-all' failed
mingw32-make: *** [module-qtwebkit-all] Error 2
So, does anybody know how i can fix this error, and is it possible to build Qt 5.0.2 with MinGW on windows?
P.S. My configure command:
>configure.bat -debug-and-release -developer-build -opensource -icu -opengl desktop -platform win32-g++ -c++11 -shared -nomake examples -nomake demos -nomake tests -prefix C:\Libs\Qt
It sounds strange, but when i done build in another directory with another -prefix option for 'configure' script build have finished successfully... So, question is closed? thanks all for responses...

Audiere incomplete universal character name \U Error

Hey so I'm trying to make a music player using QT and Audiere. First I installed Audiere and put the header file in the compiler's include folder. Then I added the .lib file to the QT project. I wrote the following code:
AudioDevicePtr device(OpenDevice());
if(!device){
//failure
}
SampleSource* source = OpenSampleSource("C:\Users\Amenechi\Downloads\LMFAO - Sexy And I Know It");
OutputStreamPtr stream(OpenSound(device,source,true));
if(!stream){
//failure
}
stream->setRepeat(true);
stream->setVolume(0.5f);
stream->play();
But I get this error:
http://s20.postimage.org/u1yxk0d0s/Untitled.jpg
Now I'm not sure where it went wrong, maybe i installed the audiere library incorrectly?
EDIT:
Hey here's the compile output if that helps.
07:37:45: Running steps for project QTunesV2...
07:37:45: Configuration unchanged, skipping qmake step.
07:37:45: Starting: "C:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe"
C:/Qt/Qt5.0.1/Tools/MinGW/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Qt/Qt5.0.1/Tools/QtCreator/bin/QTunesV1/QTunesV2-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug'
g++ -Wl,-subsystem,windows -mthreads -o debug\QTunesV2.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -lmingw32 -lqtmaind -LC:/Qt/Qt5.0.1/Tools/QtCreator/bin/QTunesV1/QTunesV2/../../ -laudiered -LC:\Qt\Qt5.0.1\5.0.1\mingw47_32\lib -lQt5Widgetsd -lQt5Guid -lQt5Cored -llibEGLd -llibGLESv2d -lgdi32 -luser32
c:/qt/qt5.0.1/tools/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -laudiered
collect2.exe: error: ld returned 1 exit status
Makefile.Debug:80: recipe for target 'debug\QTunesV2.exe' failed
mingw32-make[1]: *** [debug\QTunesV2.exe] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.0.1/Tools/QtCreator/bin/QTunesV1/QTunesV2-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug'
mingw32-make: *** [debug] Error 2
makefile:34: recipe for target 'debug' failed
07:37:45: The process "C:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project QTunesV2 (kit: Desktop Qt 5.0.1 MinGW 32bit)
When executing step 'Make'