How to use bullseye with Qt( MinGW )? - qt

I have a project in Qt which consists of the set of projects. Projects is building via MinGW and it does not create any .cov file.
I installed bullseye and enabled coverage build but it still does not create *.con file if I try to set path variable like
C:\Program Files\BullseyeCoverage\bin;%PATH%
the build is constantly failing I always get
gcc: CreateProcess: No such file or directory
The file to build whole project is following :
d:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\qmake.exe Simulator.pro -r -spec win32-g++ "CONFIG+=release"
PATH=D:\QtSDK\mingw\bin\;%PATH%
D:\QtSDK\mingw\bin\mingw32-make -f ./Makefile
How can I measure code coverage? Please help.

If somebody interested in this question - I already figured it out.
Here is a solution -
To set bullseye interceptors before your gcc compiler just replace variables
QMAKE_CC = %Bullseye gcc path%
QMAKE_CXX = %Bullseye g++ path%
This variable should be defined in *.pro file or in gcc config file, which is located in
%QTSDKPath%\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++\ // if you are using gcc from win32
You also need to set environment variable:
BULLSEYE_PATH=%PATH TO REAL COMPILER%

Related

Manually Built Qt incorrect configuration Paths

My machine use Ubuntu OS.
I built Qt 5.5.1 manually against static linking. Configuring the built, specified a path to install to:
$ ./configure -static -prefix /home/myname/qt_src/installed/
Then I moved the built stuff to another Ubuntu machine and tried call qmake from a shell:
$ qmake CONFIG+=release CONFIG-=debug /home/othername/project/q_panorama.pro -r -spec linux-g++
But I stucked with error
Could not find qmake configuration file linux-g++
Trying to fix it, I discovered that qmake's QTDIR (is it?) is incorrect:
$ qmake -v
QMake version 3.0
Using Qt version 5.5.1 in /home/myname/qt_src/installed/
Okay. Try to change special var with qmake -set option (here consider only one of vars - QT_INSTALL_PREFIX, - for simplicity). First, check it's consistency:
$ qmake -query QT_INSTALL_PREFIX
/home/myname/qt_src/installed/
Perform:
$ qmake -set QT_INSTALL_PREFIX "/home/othername/qt_static/"
Check again:
$ qmake -query QT_INSTALL_PREFIX
/home/myname/qt_src/installed/
Why the variable does not modify?
How can I make Manually Built static version of Qt work? Please, help.
Did not find the way to resolve the issue, and thus decided to act with brute force:
Created a user othername in my machine;
Run full build cycle for the path desired (under the user created).
Copied the built stuff to the target machine
PROFIT.

How to provide linker options when linking a static library with qmake?

I want to provide options to the linker when building a static library using qmake. Say I'd want to get verbose linker output when building with MSVC. The project file looks as follows:
# mylib.pro
TEMPLATE = lib
TARGET = mylib
CONFIG += staticlib
QT += core
win32-msvc*: QMAKE_LFLAGS += /VERBOSE
unix: QMAKE_LFLAGS += -v
That's the entire project file. It should result in an empty static library with no objects in it.
Setting neither QMAKE_LFLAGS nor QMAKE_LFLAGS_STATIC_LIB nor LIBS has any effect on the linker. Nothing set in those variables even makes it to the Makefile. If QMAKE_LFLAGS worked, I'd expect to see /VERBOSE or -v passed to the linker on the command line, as appropriate for given platform.
It doesn't matter what makefile generator is used, this behavior seems to be consistent. The two platforms of interest are.
qmake -spec win32-msvc2008
qmake -spec macx-llvm
Due to cross-platform nature of qmake, you can test it on any platform where you happen to have Qt installed. This reproduces on qmake from both Qt 4.8.4 and 5.1.1. The msvc version given in the mkspec doesn't matter.
In staticlib projects, the LFLAGS are not passed to the linker. In fact, there's no documented way to pass such flags.
The solution is generator-dependent.
For msvc_nmake, LIBFLAGS are passed to the linker instead. To get verbose output, you might add
QMAKE_LIBFLAGS += /VERBOSE
To verify that it works, on any system, you can invoke qmake -spec win32-msvc2008; the particular msvc version doesn't matter.
For unixmake, AR is used to invoke the linker, so you have to add the flags to QMAKE_AR. To get verbose output, you might add
QMAKE_AR += -v
To verify, invoke qmake -spec macx-llvm; any other unix spec should work as well.

Changing compiler in Qt

How to change compiler (GCC) in Qt? I've installed GCC 4.4 and 4.6. At the momment Qt uses 4.4 but I'd like it to use 4.6. How to do it?
In the build sequence it may have a qmake command like qmake YourProject.pro -r -spec linux-g++-64 the choice of the tool chain is done in the spec file here linux-g++-64. Your will find this file in path-to-the-sdk/qt/mkspecs/linux-g++-64 (you get the concept right?)... If you open the spec file you will see that it includes the linux spec and the g++ spec.
One solution is to copy the g++ spec file and rename it g++-4.6 for example edit it and change :
QMAKE_CC = gcc
QMAKE_CXX = g++
to :
QMAKE_CC = gcc-4.6
QMAKE_CXX = g++-4.6
Idem for the linux-g++-64 it can be copied to linux-g++-4.6-64 and modify the include(...) command to include your new g++-4.6 file.
Finally build your project with qmake YourProject.pro -r -spec linux-g++-4.6-64.
I hope it's clear :) ...
I realise I am very late for the party but on Linux it is as simple as follows:
qmake -makefile <your-project.pro> -spec linux-clang
On my system, all sorts of different mkspecs are available at:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs
Running make CC=my-custom-gcc CXX=my-custom-g++ LINK=my-custom-g++ seems to do the trick for me. But it might not be 100% safe (i.e. I wouldn't be surprised if running qmake with Linux specs and then specifying mingw32 compilers would fail).
If you are using Qt Creator 2.2.0, you can try Tools > Options > Tool Chains and then Add > MinGW.

Linking Matlab shared library into Qt (Windows)

I want to use Matlab's C API within QT (http://www.mathworks.com/help/techdoc/matlab_external/f39876.html#bsfvqhp-1) under Windows for opening a .mat file. In my .pro file I have included
INCLUDEPATH += "C:\Program Files\MATLAB\R2010b\extern\include"
which works fine (the code compiles). But when trying to link the libmat.lib file (I have read the .dll files cannot be linked directly) using
LIBS += -L"C:\Program Files\MATLAB\R2010b\extern\lib\win32\microsoft" -llibmat
the application crashes on execution. The error given says [file].exe exited with code -1073741515
I'm neither a QT nor a Windows expert but for this project I am forced to use both (I guess it would be easier to fix this in GNU/Linux) so any help would be appreciated. Using Windows XP, QT version 4.7.0 with Qt Creator 2.0.1, and Matlab R2010b.
The last output from the compiler just in case it is useful:
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug/MainUI.exe debug/main.o debug/maingui.o debug/matparser.o debug/matutils.o debug/moc_maingui.o -L'c:/Qt/2010.05/qt/lib' -lmingw32 -lqtmaind "-LC:\Program Files\MATLAB\R2010b\extern\lib\win32\microsoft" -llibmat -lQtGuid4 -lQtCored4
I just tested building a simple C program that uses the MAT-File Interface Library with no problems. The example file is located in: matlabroot/examples/eng_mat/matcreat.c. I am compiling using MinGW on a Windows XP 32-bit machine. Here is the Makefile I used:
# root directory of MATLAB installation
MATLABROOT="/c/Program Files/MATLAB/R2010b"
.PHONY : all clean run
all: matcreat
matcreat:
gcc ${MATLABROOT}/extern/examples/eng_mat/matcreat.c -o matcreat \
-I${MATLABROOT}/extern/include \
-L${MATLABROOT}/extern/lib/win32/microsoft -llibmat -llibmx
clean:
rm -rf matcreat *.exe *.mat
run:
# UNIX uses LD_LIBRARY_PATH to find libs at runtime, Windows/MinGW uses PATH
#PATH=${MATLABROOT}/bin/win32:"${PATH}" ./matcreat
I suspect that the Matlab library will have been compiled with MSVC and since you say you are compiling your own code with MingW I would imagine the two are incompatible.
Have a look at the MingW page on mixing compilers for more information.

How to use Ant with NetBeans C++ Qt applications

I'm using NetBeans C++ to build a simple Qt application. Here is what I did:
From 'File' I chose 'New project'
In the 'New project' window I selected C/C++ category and C/C++ Qt application
Then I clicked Next and on the second frame I renamed my project to 'Test'
Clicked 'Finish' and the sample project was created successfully (is is also the only project open so it is treated as the main project).
From 'Run' I chose 'Build Main Project' - the action was successful
Then I created an Ant script to build the same project from the console:
<?xml version="1.0"?>
<project name="Test.linux" default="My.Test" basedir="../..">
<description>Linux projects build</description>
<target name="My.Test">
<echo>Building my Test Linux project.</echo>
<exec executable="make" failonerror="true" dir="Test">
<arg value="-f"/>
<arg value="Makefile"/>
<arg value="clobber"/>
</exec>
</target>
</project>
When I run this script I get a peculiar error:
Test.linux:
[echo] Building my Test Linux project.
My.Test:
[echo] Building my Test Linux project.
[exec] for CONF in Debug Release ; \
[exec] do \
[exec] "make" -f nbproject/Makefile-${CONF}.mk QMAKE= SUBPROJECTS= .clean-conf; \
[exec] done
[exec] make[1]: Entering directory `/home/myusr/Development/Projects/Test'
[exec] VPATH=. -o qttmp-Debug.mk nbproject/qt-Debug.pro
[exec] /bin/sh: -o: not found
The build fails. After looking at the make files I found the following lines in Makefile-Debug.mk:
# Link Libraries and Options
LDLIBSOPTIONS=
nbproject/qt-${CND_CONF}.mk: nbproject/qt-${CND_CONF}.pro FORCE
${QMAKE} VPATH=. -o qttmp-${CND_CONF}.mk nbproject/qt-${CND_CONF}.pro
mv -f qttmp-${CND_CONF}.mk nbproject/qt-${CND_CONF}.mk
I don't understand why ${QMAKE} VPATH=. -o qttmp-${CND_CONF}.mk nbproject/qt-${CND_CONF}.pro is unacceptable and what is actually wrong.
After some pondering I noticed that NetBeans sets the value of ${QMAKE} to /usr/bin/qmake, but when I call the ant script it stays an empty string. So my question is rather how NetBeans knows where to find the qmake - is there a project setting or is it a setting of the IDE itself. Should I rely on the fact that the qmake path is always this '/usr/bin/qmake' and set ${QMAKE} variable in the ant script manually or is there another way to solve this?
Qt itself uses QTDIR to check which installation to use in case if you have several versions installed. Some linux distributions doesn't set this environment variable since in most cases it's not needed.
Good way to find out which Qt version to use is:
1) Check if ${QTDIR} exists. In this case qmake is located under ${QTDIR}/bin directory
2) If ${QTDIR} doesn't exists try to find qmake in the directories specified by ${PATH} env variable. For example using which command.
This method is used by SCons qt4 build tool (unofficial third party module for this build system). I think it should be simple to implement this algorithm with ant.

Resources