QMake result (makefile) differs when executing from bash instead of QtCreator - c++

My goal is to add my Qt project to a Jenkins buildserver, for nightly builds. Therefore I want to compile my project from the command line. I copied the buildsteps located in the build configuration:
"/opt/fslc-x11/2.5/sysroots/x86_64-fslcsdk-linux/usr/bin/qt5/qmake" "/home/xxxx/repositories/xxx/xxx.pro" -spec linux-oe-g++ && /usr/bin/make qmake_all
"/usr/bin/make"
I execute these commands in the build directory. The problem lies in the qmake command. The qmake command generates the makefile, but this makefile is different when I generate it in the command line instead of in QtCreator. The binary result after make is ofcourse very different.
It seems that the qmake command from the command line creates a debug makefile instead of a release makefile:
CFLAGS = -pipe -02 -pipe -g -feliminate-unused-debug-types --sysroot=.........
The -02 -pipe -g -feliminate-unused-debug-types part is the only thing added when I run qmake in the command line (checked with diff).
I've tried the following:
Added CONFIG+=release to the qmake command
Added CONFIG-=DEBUG to the qmake command
Furthermore I've verified that the system environment and the terminal emulator is the same.
My question comes down to:
Why does qmake add the (debug) flags when running from the command line?
Does QtCreator add more to the environment that I might have missed?
Let me know if you need more information about the settings or the makefile that is generated.

Ok. So long story short: I've tried compiling for the local Linux distro with the standard qmake and my problem was solved.
It seems that problem lies at the custom qmake of the target (x86_64-fslcsdk-linux). I'm not gonna put more time in this issue, so feel free to add a more satisfying answer. I'll be happy to try it out :).

Related

How to configure autoreconf to use a different compiler than GCC

I am trying to compile the code for one of the projects and the source file uses autoreconf for generating the makefiles.
" autoreconf --verbose --force --make "
The problem is that this somehow generates the makefiles that uses the compiler as GCC. I want it to generate the configuration files with a different compiler. How can I do it?
I can issue the command as make CC= but this throws an error in the libtool that is used later on.
Thank You
Typically autoreconf just regenerates the configure script and the autoconf makefile templates, it doesn't create any actual makefiles.
Makefiles get created when configure is run, and that's when you want to override the compiler:
configure CC=clang CXX=clang++
that should create makefiles that use CC=clang and CXX=clang++

convert qmake file to unix makefile

I have a cli program that I want to build on older machines (that don't have qt installed). My main development machine has QT and I use qt-creator to do most of my work, however when going to these older machines and running make, the makefile that is generated by qmake expects qmake to be available.
How do I make qmake files portable?
Edit:
platform is Linux, (various servers, some old some new)
using qmake to make a makefile doesn't work because the makefile created needs qmake (hence my question).
It would be helful, if you tell us your desire platform where you want to use make.
By using qmake, you can easily create Makefile for you desire platform, by running qmake as
$qmake -spec your_desire_platform_spec your_project.pro
Then run, make as
$make
Say, you want to run it on FreeBSD;
if you want to use clang, qmake as
$qmake -spec freebsd-clang your_project.pro
if you want to use g++, run qmake as
$qmake -spec freebsd-g++ your_project.pro
then run make
$make
Hope it will help you.
Don't use qmake to make non Qt projects. It doesn't make any sense. However, if your project file is just a series of
SOURCES = ...
then just define a Makefile variable with the same values, define something like
OBJECTS = $(patsubst %.cpp,%.o, $(SOURCES))
And then define a rule like:
%.o: %.cc
g++ -o $# $<
(or whichever compiler is the right one).
You could also look at the generated Makefile, strip it down to its most basic expression, and drop the qmake file.

How to build coreutils with LLVM 3.4

I am trying to build GNU Coreutils 8.23 using the LLVM 3.4 tool-chain. One very important aspect is that I also need the LLVM bytecode for all the coreutils. Therefore, I need to include -emit-llvm in the CFLAGS. Therefore, I removed the $(CFLAGS) from the LINK variable of the coreutils Makefile. Afterwards, I run the following command:
make CC=/home/user/llvm-3.4.2/build/Release+Asserts/bin/clang
CCLD=/home/user/llvm-3.4.2/build/Release+Asserts/bin/llvm-link
IGNORE_UNUSED_LIBRARIES_CFLAGS= CFLAGS="-emit-llvm -S"
VERBOSE=1 AM_CFLAGS= AM_LDFLAGS=
AR=/home/user/llvm-3.4.2/build/Release+Asserts/bin/llvm-ar
RANLIB=/home/user/llvm-3.4.2/build/Release+Asserts/bin/llvm-ranlib
and I get the following error:
/home/user/llvm-3.4.2/build/Release+Asserts/bin/llvm-link: src/libver.a:1:2: error: expected integer
!<arch>
^
/home/user/llvm-3.4.2/build/Release+Asserts/bin/llvm-link: error loading file 'src/libver.a'
Any ideas of how to get this to work?
Try this.
export CC="/home/user/llvm-3.4.2/build/Release+Asserts/bin/clang"
export CXX="/home/user/llvm-3.4.2/build/Release+Asserts/bin/clang++"
Make sure this is where your compiler toolchain is present.
Then in the the coreutils directory, run ./configure (before this run ./bootstrap if you havent already run it). Running ./configure checks if your clang can compile properly and creates a Makefile with the correct configuration.
Then do a make and make install as instructed.
Lib file '.a' here is not readable by llvm-link.
A possible informal hack to this probably is to find out the Makefile generating this lib, and let
AR = llvm-link, ar option = -o(i.e. change ar rv to llvm-link -o),
and disable ranlib command while compling(you don't need ranlib if using llvm-link).
Then the '.a' file generated is a stitched bc file, and this '.a' file should be accpetable by llvm-link command you are calling

How can I run vcvars32.bat before code build in eclipse?

I want to compile my c++ codes with cl compiler. Therefore I started a "c++ makefile project" in eclipse. Then I wrote my make file. I must run vcvars32.bat firstly to run cl so I write that command in make file also bu it didn't work correctly. What should I do now? How can I run that command before building the code? By the way I am using nmake.
My make file is below:
OBJS = helloWorld.o
TARGET = helloWorld.exe
all: $(TARGET)
helloWorld.exe:
**vcvars32.bat**
cl helloWorld.cpp
rm -f *.obj
clean:
rm -f helloWorld.exe *.obj
Open a command line, run vcvars32.bat, then start eclipse from the same command line.
The first two steps can be combined into one by going to Start->Visual Studio xxx->Visual Studio Tools->VS command prompt (exact naming depends on what you have installed)

Error when cross compiling Qt for ARM

I am trying to cross compile Qt on Ubuntu Linux for ARM. But I get the following error:
bin/rcc: File does not exist 'dialogs/qprintdialog.qrc'
The build command which produces this is:
bin/rcc -name qprintdialog dialogs/qprintdialog.qrc -o .rcc/release-shared/qrc_qprintdialog.cpp
I tried to manually execute this command by giving an absolute path to dialogs/qprintdialog.qrc but still have the same error although dialogs/qprintdialog.qrc does exist.
I have configured Qt as:
./configure -no-exceptions -no-accessibility -no-xsync -no-xinerama -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-mitshm -no-xinput -no-xkb -no-nas-sound -arch arm -platform linux-g++ -xplatform qws/linux-arm-g++ -release -opensource -fast -I$ARM/usr/include -L$ARM/usr/lib -L$ARM/lib -lrt -lX11 -lxcb -lXau -lXdmcp -lXext -lz -prefix custom_path_to_install
Any help would be appreciated.
An easy way to troobleshot this could be to install Qt Creator. Create a project with your code. Then, don't compile and run inside the IDE, but instead, in your terminal, do to your project folder with all your code (and new Qt Creator file .pro), and enter this:
qmake -project
qmake
make
Don't change -project, it's really the command, not the name of your project. I believe it will do it. Qt create has a .pro file which is then compile into a Makefile via qmake and manage all that for you.