Generated .pro file from visual studio Qt addin adds unnecessary openGL libraries? - visual-studio-2010

I've created a basic app in visual studio with Qt and an openGL widget. I export a .pro file from the addin so that I can compile in Linux.
I get the message:
/usr/bin/ld: cannot find -lopengl32
/usr/bin/ld: cannot find -lglu32
... when running make.
The issue goes away and the program compiles fine if I remove:
LIBS += -lopengl32 \
-lglu32
... from the generated .pro file.
I understand the "export .pro" feature is not flawless, but is this the correct way to fix this problem?

I don't quite remember the exact name of the OpenGL library on Linux, but it's not opengl32. Rather libopengl. So it's perfectly normal.
This will make you link with opengl32.lib on windows only:
win32 : LIBS += -lopengl32 -lglu32
and if needed, this will make you link with libopengl on Linux :
unix : LIBS += -lopengl -lglu
For the macx platform scope, I guess there is additional work to link with the OpenGL Framework.

Related

Cross compiling FFmpeg + Qt application with MXE

I got a pretty simple project that uses Qt as well as FFmpeg that i developed under linux.
Now I'am having trouble cross compiling said project with MXE to use it on a windows machine.
Under linux everything i had to do was adding
LIBS += -lavcodec -lavformat -lswscale -lavutil
to Qt's .pro file and wrap the includes for FFmpeg in an "extern "C"" block and it compiles just fine.
Now for MXE i just cloned the git repo and used
make MXE_TARGETS='x86_64-w64-mingw32.static' qt5 ffmpeg
As the MXE doc states i set the PATH variable and used
qmake && make
But i get a lot of undefined reference errors regarding libavformat.
Can anybody tell me what i am doing wrong here? I'm kinda lost.
Okay so I got this working.
The mxe version of gcc requires you to include the library multiple times if it is referenced by a library after it in the list of libraries to link.
Add -lavformat to the end of the LIBS line.

Errors while migrating Qt project from Linux to Windows

I have a Qt project develop on linux, but now I need to compile on windows. I'm having a couple of problems in the migration process.
The first error I'm getting it's:
C:\Qt\Qt5.5.1\Tools\mingw492_32\i686-w64-mingw32\include\c++\bits\c++0x_warning.h:32: error:
#error This file requires compiler and library support for the ISO C++ 2011 standard.
This support is currently experimental, and must be enabled with the
-std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
and this it's how I'm putting it in the .pro of my project
QMAKE_CXXFLAGS += -std=c++11
I also try with
CONFIG += c++11
but the problem continuous.
To give a little more of information, I'm using the MinGW compiler that the Qt Creator install and the extension of my Headers and Sources are: .H and .C (Just in case this have anything to do with the problem, because I've seen that Qt always uses .cpp)
What could be the cause of the problem ?? If something it's unclear or more information it's needed please let me know.
I solve the problem, for me it worked when I change the extension of my sources, I change .C for .cc

Multicore compilation with Qt 5.1 and jom on Windows 7 failed

I have installed Qt 5.1.1 with MinGW 4.8 and QtCreator through Qt Online installer.
I launched Qt creator and made new project (Qt application Desktop) with MainWindow class based on QMainWindow (default). It works fine and popped up a mainwindow after compilation.
However, when I used C:\Qt\Qt5.1.1\Tools\QtCreator\bin\jom.exe instead of C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\mingw32-make.exe , I got some output like below.
jom 1.0.13 - empower your cores
C:\Qt\Qt5.1.1\Tools\QtCreator\bin\jom.exe -f Makefile.Release
g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../foobar -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtWidgets' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtGui' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtCore' -I'release' -I'.' -I'.' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/mkspecs/win32-g++' -o release/main.o ../foobar/main.cpp
In file included from ../foobar/main.cpp:1:0:
../foobar/mainwindow.h:4:23: fatal error: QMainWindow: No such file or directory
#include <QMainWindow>
^
compilation terminated.
jom: D:\work\build-foobar-Desktop_Qt_5_1_1_MinGW_32bit-Release\Makefile.Release [release\main.o] Error 1
jom: D:\work\build-foobar-Desktop_Qt_5_1_1_MinGW_32bit-Release\Makefile [release] Error 2
15:17:38: Process "C:\Qt\Qt5.1.1\Tools\QtCreator\bin\jom.exe" stopped with code 2
Error while building/deploying project foobar (kit: Desktop Qt 5.1.1 MinGW 32bit)
During step 'Make'
15:17:38: Elapsed time: 00:00.
My .pro is like this.
#-------------------------------------------------
#
# Project created by QtCreator 2013-09-08T15:16:13
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = foobar
TEMPLATE = app
SOURCES += main.cpp\ mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
I think the line in .pro greaterThan(QT_MAJOR_VERSION, 4): QT += widgets and in the output during compilation -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtWidgets' looks fine, but failed.
How can I compile with Qt 5.1 and jom on Windows 7 (32 bit)?
Thanks in advance.
Jom is a replacement of nmake and not MinGW's make.
nmake is the Visual Studio command line tool used to compile makefiles. Unfortunately that tool is using only one core (Parallel builds are handled inside Visual Studio either directly or using MSBuild, I'm not really sure). That being said, Jörg Bornemann wrote a tool called jom that sort of adds the -j command to nmake. It will allow you to compile your code using the Visual C++ compiler across different threads.
MinGW on the other end contains (amongst other things) a port of the GNU GCC compiler for Windows. Being a port, not everything that is possible to do with GCC is possible with MinGW and I guess that -jN is one of these. However, MinGW do support the option -j that will spawn as many processes as it can (beware that if you use this option, you may not be able to use your computer whilst compiling).
In your case, you probably want to use MinGW as your Qt version is compiled with it. If you want to use Visual Studio, you will have to install it but also either:
recompile Qt (and all other library dependencies) or
download the binary corresponding to the Visual Studio version you just installed.
Using jom should just work with QtCreator once this is done.
In my case I fixed this error by overriding system environment PATH in project settings by adding only bin path to qt, mingw and qtcreator: "E:\Qt\4.8.1\bin;E:\qt\mingw-4.4.0\bin;E:\Qt\qtcreator-4.0.0\bin" and after Run qmake and Rebuild

Qt + MinGW + another undefined reference to `WinMain#16' issue

I know, I dug the whole internet to find out what the problem is and nothing has been helpful so far.
I am on Windows 7, using:
Qt 4.8.3: https://download.qt.io/archive/qt/4.8/4.8.3/qt-win-opensource-4.8.3-mingw.exe
MinGW32 4.4.0: http://nosymbolfound.blogspot.com/2012/12/since-until-now-qt-under-windows-is.html
I can compile any Qt demo example with Qt Creator, so I believe my system is working fine.
When trying to compile the program I ran into the well known issue:
g++ -enable-auto-import -o libqlcengine.a object_script.libqlcengine.Debug -L".\lib" -L"c:\Qt\4.8.3\lib" -lwinmm -L../../hotplugmonitor/src -lhotplugmonitor -lQtScriptd4 -lQtXmld4 -lQtGuid4 -lQtCored4
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain#16'
(object_script.libqlcengine.Debug is a pretty long list of .o files)
Now, at that point of build it's trying to link a static .a library, so I see no reason for MinGW to look for WinMain. I did grep 'WinMain' and found no result on the entire source tree.
If you want to checkout the original sources:
svn co https://qlc.svn.sourceforge.net/svnroot/qlc qlc
Or my forked version:
git clone git://git.code.sf.net/p/qlcplus/code qlcplus-code
They have the same result.
Guys, what am I missing here ? I tried a whole bunch of C flags (-mwindows -lmingw32 -DQT_NEEDS_MAIN -lqtmain) but none worked.
Any magic please ?
P.S. Of course I can build on Linux either i386/amd64
SOLVED:
I just needed to add the following line to the .pro files where libraries were created:
win32:QMAKE_LFLAGS += -shared
[SOLVED]
I just figured out I needed to add the following line to the .pro files where libraries were created:
win32:QMAKE_LFLAGS += -shared

Why can't g++ find/link to qjpeg4.dll?

Using Qt Creator 2.4.1 (Windows/mingw), I'm trying to compile my project dynamically linking with some Qt image plugins (i.e. the ones in C:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\imageformats\). In the .pro file:
QTPLUGIN += qjpeg qgif qico qtiff
This is the error:
g++ -Wl,-s -mthreads -Wl,-subsystem,windows -o release\myproject.exe object_script.myproject.Release -L"c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib" -lmingw32 -lqtmain release\myproject_res.o -L. -lswscale-2 -lavcodec-54 -lavdevice-53 -lavfilter-2 -lavformat-54 -lavutil-51 -lusb -lPsapi -lasa047 -lsphinxbase -lpocketsphinx -LC:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins/imageformats -lqjpeg -lqgif -lqico -lqtiff -lQtMultimedia4 -lQtGui4 -lQtNetwork4 -lQtCore4
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lqjpeg
In the above you can see -LC:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins/imageformats specified before -lqjpeg and C:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\imageformats\qjpeg4.dll exists ... so what gives?
Additional info: I can comment out the QTPLUGIN line in the .pro file and put instead:
LIBS += -LC:\\QtSDK\\Desktop\\Qt\\4.8.1\\mingw\\plugins\\imageformats -l:qjpeg4.dll
This links successfully, but I'm more interested in why QTPLUGIN appears broken out of the box under Windows mingw. What am I missing?
Seems to be a known (unresolved) bug with qmake: https://bugreports.qt.io/browse/QTBUG-24177?focusedCommentId=179693#comment-179693

Resources