This question already has answers here:
Identifier for win64 configuration in Qmake
(5 answers)
Closed 7 years ago.
I'm trying to build a MultiArch Application for Ubuntu. I have to compile it separately on different Architectures. However I have to do a lot of manual changes Each time the Architecture changes. For Instance-
#linux-g++:LIBS += $$DESTDIR/lib32/libusb-1.0.so #arch-specific changes
linux-g++:LIBS += $$DESTDIR/lib64/libusb-1.0.so
Here I have to comment and uncomment a line every time I'm compiling for a different Architecture. I have to do this on a number of places.
However if there is a way to specify the Linux Architecture in the .pro file itself then my task will become much easier. I know that we can use win32 and macx scope variables and linux-g++ for Ubuntu. But I want to distinguish between ubuntu 32 bit and 64 bit Architectures. Is there any way this might be achieved a little more elegently?
I have already seen
qmake platform scopes
and I just want to specify that I'm looking to distinguish between linux32bit and linux64bit .
SOLVED IT:
linux-g++{
!contains(QT_ARCH, x86_64){
LIB=lib32
message("Compiling for 32bit system")
} else {
LIB=lib64
message("Compiling for 64bit system")
}
}
Related
All of a sudden I seem to be struggling with compiling c++ programs (specifically TDM64 5.1.0) from the command-line on Windows (specifically 10) when using wildcard based filenames. It works fine when the names are given in full. I've done this countless times before with no problem Edit: But not normally on windows... my memories of this working before must be false. What am I missing?
C:\Users\Duncan Coulter\Code>dir *.cpp
Volume in drive C has no label.
Volume Serial Number is 9EE6-DBBD
Directory of C:\Users\Duncan Coulter\Code
2016/04/04 01:35 PM 7 869 LittleMan.cpp
2016/04/04 01:35 PM 1 912 main.cpp
2 File(s) 9 781 bytes
0 Dir(s) 90 288 394 240 bytes free
C:\Users\Duncan Coulter\Code>g++ *.cpp
g++: error: *.cpp: Invalid argument
C:\Users\Duncan Coulter\Code>g++ main.cpp LittleMan.cpp
Your problem is where you write:
g++ *.cpp
g++ is a linux style program, and expects the shell to expand wildcards for it. The windows command shell doesn't do that - it expects individual programs to expand wildcards for themselves.
The easiest solution is to download cygwin - which does expand wildcards for you. Otherwise the answers to this question may be useful:
https://superuser.com/questions/460598/is-there-any-way-to-get-the-windows-cmd-shell-to-expand-wildcard-paths
I note that TDM is based on the MINGW port of GCC. I've found that different versions of this compiler do in fact treat the wildcard differently. For example, it works perfectly fine for me as of version 3.4.2, compiling in Windows 7:
However, when I upgraded to GCC v.4.9.2, this batch file and others I was using broke (specifically, the *.cpp was not recognized). This was a version of MINGW GCC which came with the Dev-C++ IDE. Because I needed this feature rather badly (specifically, test-compiling large submissions of student code with unspecified random filenames), I actually had to downgrade and revert back to the old version for just this purpose.
Is there a way to compile with MingW with CodeBlocks in Windows so they can be used in Ubuntu or Centos distros?
I've tried compiling with GNU GCC option then got the output file with .o extensions under obj/Release/ folder.
When I run I get this error under my Vagrant Ubuntu machine:
-bash: ./main.o: cannot execute binary file
How can I compile it so it runs on my Linux machines?
The technical term for what you're trying to accomplish is cross-compilation. For that, you need to build a specific cross-compiler using GCC sources. If you still want to keep MinGW, there is a page explaining the steps needed to create a ARM cross-compiler : http://www.mingw.org/wiki/HostedCrossCompilerHOWTO. (you'll have to modify the target)
List of targets supported by GCC :
armv5te-android-gcc armv5te-linux-rvct armv5te-linux-gcc
armv5te-none-rvct
armv6-darwin-gcc armv6-linux-rvct armv6-linux-gcc
armv6-none-rvct
armv7-android-gcc armv7-darwin-gcc armv7-linux-rvct
armv7-linux-gcc armv7-none-rvct
mips32-linux-gcc
ppc32-darwin8-gcc ppc32-darwin9-gcc ppc32-linux-gcc
ppc64-darwin8-gcc ppc64-darwin9-gcc ppc64-linux-gcc
sparc-solaris-gcc
x86-android-gcc x86-darwin8-gcc x86-darwin8-icc
x86-darwin9-gcc x86-darwin9-icc x86-darwin10-gcc
x86-darwin11-gcc x86-darwin12-gcc x86-linux-gcc
x86-linux-icc x86-os2-gcc x86-solaris-gcc
x86-win32-gcc x86-win32-vs7 x86-win32-vs8
x86-win32-vs9
x86_64-darwin9-gcc x86_64-darwin10-gcc x86_64-darwin11-gcc
x86_64-darwin12-gcc x86_64-linux-gcc x86_64-linux-icc
x86_64-solaris-gcc x86_64-win64-gcc x86_64-win64-vs8
x86_64-win64-vs9
universal-darwin8-gcc universal-darwin9-gcc universal-darwin10-gcc
universal-darwin11-gcc universal-darwin12-gcc
generic-gnu
There is only one big caveat : since Windows is not POSIX compliant, I don't think you can use signals or pthreads.
Finally, brace yourself because it's a tedious task to build a cx-compiler (lots of obscure bugs). That's why profesionnal devs pays $$$ for "plug'n'play" solutions.
EDIT : this MXE project can be useful to you
This is the log I received from Dev-Cpp when I tried to compile a program:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
make.exe: Interrupt/Exception caught (code = 0xc00000fd, addr = 0x4ff283)
Execution terminated
I have googled for the answer, I've tried the "PATH" fix, and make my MINGW stuff first like this.
C:\Dev-Cpp\mingw32\bin;C:\Dev-Cpp\bin;
Yet I still can't compile, I've even restarted my computer (Windows 7 x64), and still the same error. So I'm wondering if you guys have any answers that can help.
Thanks in advance!
I have used the old Dev-C++ in the past and I've have had it break randomly on me at times.. (crucial times I might add).
Bloodshed Dev-C++ hasn't been updated for years and development has actually stopped on it.
If you really like the environment consider getting the updated and maintained Orwell Dev C++ that is improved, faster and much cleaner.
No additional PATH is normally needed for compilation with Dev-CPP.
Seems to be a very old Dev-CPP version. My version neither has a \Dev-Cpp\bin directory, nor a Makefile.win in the main location. Maybe your installation is defective.
Did you install the compiler system along with Dev-CPP (and make executeable).
Please remove everything and use a modern, up to date version of DevCpp for 32 or 64 bit.
Dev-CPP 32bit
Dev-CPP 64bit
One hint: Do not install DevCpp into a directiory with ' ' spaces, like /Program Files/ etc. Better, use C:\Apps\Dev-Cpp or sth. like that.
Addendum
To the critics who say "Dev-Cpp is very old, drop it". No, thats wrong. Dev-Cpp is imho actually the best free IDE/Compiler system for Windows - and I have a lot of them installed (Netbeans, CodeBlocks, VS2010, VS2012rc, dropped Eclipse/CDT). Please have a look here ...
Dev-Cpp retains the simplicity of the early Turbo-Compiler and connects that with 32/64bit gcc 4.6. Although I use VS2010/12rc for serious development, I always create the projects in parallel for Dev-Cpp in order to get gcc compatibility.
Regards
rbo
perhaps recursion problem in macro expansion.
Makefile:
rtest=$(info $(words $1))$(call rtest,$1 1)</b>
$(info $(call rtest))
# eof Makefile
yields :
2152
2153
mingw32-make: Interrupt/Exception caught (code = 0xc00000fd, addr = 0x00007ffdbdea2f57)
2154
I am linking to a .a lib and need to link to the right version for the machine that's compiling. Is there a way to detect the type of machine in a .pro file in linux? I found this article, but they only discuss Windows: http://developer.qt.nokia.com/faq/answer/how_can_i_detect_in_the_.pro_file_if_i_am_compiling_for_a_32_bit_or_a_64_bi
Edit: The .a library is Gtest. Another way to solve my problem would be to somehow build a .a file with g++ that will work on either 32-bit or 64-bit platforms. Is that possible?
By doing your conditional on a mkspec, (see Platform Scope Values here), you can check for a very large variety of compiler/platform.
My mkspec directory (Linux64 machine), gives the following differentiations:
aix-g++/ irix-g++-64/ qconfig.pri wince50standard-armv4i-msvc2005/
aix-g++-64/ linux-cxx/ qws/ wince50standard-armv4i-msvc2008/
aix-xlc/ linux-ecc-64/ sco-cc/ wince50standard-mipsii-msvc2005/
aix-xlc-64/ linux-g++/ sco-g++/ wince50standard-mipsii-msvc2008/
common/ linux-g++-32/ solaris-cc/ wince50standard-mipsiv-msvc2005/
cygwin-g++/ linux-g++-64/ solaris-cc-64/ wince50standard-mipsiv-msvc2008/
darwin-g++/ linux-g++-maemo/ solaris-cc-64-stlport/ wince50standard-sh4-msvc2005/
default# linux-icc/ solaris-cc-stlport/ wince50standard-sh4-msvc2008/
features/ linux-icc-32/ solaris-g++/ wince50standard-x86-msvc2005/
freebsd-g++/ linux-icc-64/ solaris-g++-64/ wince50standard-x86-msvc2008/
freebsd-g++34/ linux-kcc/ symbian/ wince60standard-armv4i-msvc2005/
freebsd-g++40/ linux-llvm/ symbian-abld/ wince60standard-x86-msvc2005/
freebsd-icc/ linux-lsb-g++/ symbian-sbsv2/ wincewm50pocket-msvc2005/
hpux-acc/ linux-pgcc/ tru64-cxx/ wincewm50pocket-msvc2008/
hpux-acc-64/ lynxos-g++/ tru64-g++/ wincewm50smart-msvc2005/
hpux-acc-o64/ macx-g++/ unixware-cc/ wincewm50smart-msvc2008/
hpux-g++/ macx-g++40/ unixware-g++/ wincewm60professional-msvc2005/
hpux-g++-64/ macx-g++42/ unsupported/ wincewm60professional-msvc2008/
hpuxi-acc-32/ macx-icc/ win32-borland/ wincewm60standard-msvc2005/
hpuxi-acc-64/ macx-llvm/ win32-g++/ wincewm60standard-msvc2008/
hpuxi-g++-64/ macx-pbuilder/ win32-icc/ wincewm65professional-msvc2005/
hurd-g++/ macx-xcode/ win32-msvc2003/ wincewm65professional-msvc2008/
irix-cc/ macx-xlc/ win32-msvc2005/
irix-cc-64/ netbsd-g++/ win32-msvc2008/
irix-g++/ openbsd-g++/ win32-msvc2010/
In the .pro file, you can have things like:
mkspec:VAR += special_spec_var_value
So for example, when compiling for arm, to link my touchscreen lib I do:
linux-arm-g++:LIBS += -lts
I'm trying to use ChangeWindowAttributes() function in Qt Creator project on Mac OS X.
But I can't build the project.
What I've tried:
#include <MacWindows.h>
Result (compiler): File not found
#include <Carbon/Carbon.h>
// Or the same:
#include </Developer/Headers/FlatCarbon/MacWindows.h>
Result (compiler): ChangeWindowAttributes was not declared in this scope
#include <Carbon/Carbon.h>
extern OSStatus ChangeWindowAttributes (
WindowRef window,
WindowAttributes setTheseAttributes,
WindowAttributes clearTheseAttributes
);
// And in *.pro file:
LIBS += -framework Carbon
Result (linker): Undefined Symbols ChangeWindowAttributes( ...
Where am I wrong?
According Google it seems that everybody already knows how to include it, so there are no guides anywhere. Maybe someone here also has a link to the guide or something?
By default, QT Creator build your project in your Mac's CPU architecture. The libraries themselves come in x86 and x86_64 universal binaries. This is if you are using the prebuild SDK from Nokia.
If you are running 64-bit capable OS/Mac combination, like 10.6 on a new Intel Mac, it will build it in x86_64. Carbon calls are still available to your code but only those marked as 64-bit compatible one. Open MacWindows.h and find ChangeWindowAttributes. You will see in the comment:
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: not available
If you have to call this (and other 32-bit only) function, you'll have to force Creator to build it in 32-bit (x86). Add these lines to your .pro file:
CONFIG -= x86_64
CONFIG += x86
Clean all and rebuild.