64-bit C++ Eclipse Is Making a 32-bit Executables - c++

When I run my program, which I wrote in a 64-bit Eclipse, I get a 32-bit executable. When I first opened Eclipse it asked for a kernel32.lib. Does this force Eclipse to make 32-bit applications?
Q. Is there a way to tell it to use the 64-bit kernel? Or an option to make Eclipse compile 64-bit programs?

"Bit-ness" of Eclipse has nothing to do with the executable it will produce - that depends entirely on the compiler you use or the flags passed to the compiler. You can produce 32-bit executables in 64-bit Eclipse or 64-bit executables in 32-bit Eclipse (as well as 32->32 and 64->64).

You need to tell Eclipse to compile 64-bit.
To do this go to the "Compiler/Linker" Settings Configuration page: It should be under: "GCC C Linker > Miscellaneous". Under "Linker Flags" add:
-m64

Related

C++ Eclipse: Build a MacOSX App under Linux?

I have a C++ command line project using Eclipse under fedora
(Eclipse IDE for C/C++ Developers Oxygen.2 Release (4.7.2)).
Now i want to port this to the Mac.
To my surprise in the project settings of eclipse, in the list of available tool chains i found the entry "MacOSX GCC":
which contains a MacOS X C++ Linker. So i switched the used toolchain to this and rebuilt. The resulting file can still be executed under linux but its not executable when moved to a mac. It differs though slightly in size from the version built with the Linux GCC toolchain, but sill it is a linux, not a mac executable.
Question:
Can the MacOS X toolchain be used anyhow in the linux environment or
is this rather a bug?
If yes: What do i have to do, to build a MacOS X application under linux?

Trying to build c++ for a remote arm device on QtCreator, executable is 64bit

I have a board with zynq chipset and Armv7 processor and Ubuntu 12.04. I want to remotely build and debug a c++ program on it with QtCreator.
I tried to create a kit for building the program using this link. added the compiler in the toolchains of board and added qt version 4.8.1 to the kit (version of qt on the board is 4.8.1).
The code builds successfully. the problem is the binary is not executable on my board because it seems it is a 64bit binary and my board is not 64bit.
Am I missing something?
how can I check if my config for compiling qt everywhere source was correct and it resulted in the qmake I wanted?
btw my own OS is Ubuntu 16.04 64bit.
The instruction on the Xilinx's page instruct how to build a cross compiler for ARM, however I belive they assumed you're going to follow these steps on 32-bit Linux platform. On the other hand -xplatform qws/linux-arm-gnueabi-g++ option should produce 32bit compiler.
Are you sure your code is build with right compiler build with right option? have you trie to build any minimal example from command line and check what file command is telling you about the binary produced? For me it looks like, do don't really cross-compile your project.
after hours and hours of searching and trying different things I found the reason. First of all as #michal-f said I installed 32-bit Ubuntu. making in terminal was resulting in ARM binary but QtCreator just compiled for intel proccessor.
as stupid as it seems the reason was that I did not know that Qt variables is not related to system variables and though I had added CROSS_COMPILE variable in terminal, I should have added it to my kit environmental variables too.
so the phrase ${CROSS_COMPILE}g++ in MakeFile was simply g++ and the output was a binary compile with system g++.
I know it was something I should have found sooner, but something this stupid should have been somewhere on internet for beginners like me. So hopefully next person encountering this same problem will find this post.

Cannot build cpp file with tdm-gcc on windows 7, 32bit(says exe is not compatible)

Environment and What I'm Trying to Do: I'm trying to set up a C++ coding/debugging environment with sublime text 3 on a 32 bit Windows 7 PC.
I installed Sublime Text 3 for Windows and Dev-C++(from http://orwelldevcpp.blogspot.kr/) which includes TDM-GCC 4.9.2 (32bit and 64bit).
Problem: After adding "C:\Program Files\Dev-Cpp\MinGW64\bin" to the PATH environment variable, I tried to build a simple Hello World! code, but only got this messege:
[Finished in 5.1s with exit code 1]
[shell_cmd: g++ "D:\SublimeText\main.cpp" -o "D:\SublimeText/main" && "D:\SublimeText/main"]
[dir: D:\SublimeText]
[path: (all the directories added to PATH)]
When I try to execute the main.exe file generated in D:\SublimeText, a warning that says something like 'This program is not compatible with this OS. Check your OS type if it's 32 bit or 64 bit and execute the right one'.
If I compile and run the same code in Dev-C++ after choosing the 'TDM-GCC 32bit compiler', it compiles and runs just fine.
Expected Cause: Maybe Sublime Text compiles my code with a 64bit compiler, but I couldn't find how to make it use the 32bit compiler.
I'm new to coding(registered to stack overflow an hour ago..), so a kind and detailed answer would be very appreciated! Thank You.
The TDM GCC 64 bit compiler can be installed and run on a 32-bit host
(like yours) because the compiler executables are themselves all 32-bit.
The 64-bit compiler can generate both 64- and 32-bit executables for
you, and by default will generate 64-bit ones, which will not run
on your 32-bit host. To get 32-bit executables you must explicitly tell gcc
you want them by passing it the -m32 option, for both compilation
and linkage.

64-bit and 32-bit C++ executables with Code::Blocks

I have an executable compiled on a 64-bit machine using Code::Blocks and GCC compiler. I also have someone on a 32-bit machine that can't run the executable. Do I need to make two separate versions of the executable, or is there a way that I can compile it to run on both 32-bit and 64-bit systems?
You could use -m32 in gcc command line to build a 32-bit version. Please make sure your code is portable from 64-bit to 32-bit.

How to compile C++ programs in codeblocks for 32bit computers with the dual targets MinGw compiler [duplicate]

I've downloaded MinGW with mingw-get-inst, and now I've noticed that it cannot compile for x64.
So is there any 32-bit binary version of the MinGW compiler that can both compile for 32-bit Windows and also for 64-bit Windows?
I don't want a 64-bit version that can generate 32-bit code, since I want the compiler to also run on 32-bit Windows, and I'm only looking for precompiled binaries here, not source files, since I've spent countless hours compiling GCC and failing, and I've given up for a while. :(
AFAIK mingw targets either 32 bit windows or 64 bit windows, but not both, so you would need two installs. And the latter is still considered beta.
For you what you want is either mingw-w64-bin_i686-mingw or mingw-w64-bin_i686-cygwin if you want to compile for windows 64. For win32, just use what you get with mingw-get-inst.
See http://sourceforge.net/apps/trac/mingw-w64/wiki/download%20filename%20structure for an explanation of file names.
I realize this is an old question. However it's linked to the many times the question has been repeated.
I have found, after lots of research that, by now, years later, both compilers are commonly installed by default when installing mingw from your repository (i.e. synaptic).
You can check and verify by running Linux's locate command:
$ locate -r "mingw32.*[cg]++$"
On my Ubuntu (13.10) install I have by default the following compilers to choose from... found by issuing the locate command.
/usr/bin/amd64-mingw32msvc-c++
/usr/bin/amd64-mingw32msvc-g++
/usr/bin/i586-mingw32msvc-c++
/usr/bin/i586-mingw32msvc-g++
/usr/bin/i686-w64-mingw32-c++
/usr/bin/i686-w64-mingw32-g++
/usr/bin/x86_64-w64-mingw32-c++
/usr/bin/x86_64-w64-mingw32-g++
Finally, the least you'd have to do on many systems is run:
$ sudo apt-get install gcc-mingw32
I hope the many links to this page can spare a lot of programmers some search time.
for you situation, you can download multilib (include lib32 and lib64) version for Mingw64:
Multilib Toolchains(Targetting Win32 and Win64)
By default it is compiled for 64bit.You can add -m32 flag to compile for 32bit program.
But sadly,no gdb provided,you ought to add it manually.
Because according to mingw-64's todo list, gcc multilib version is done,but gdb
multilib version is still in progress,you could use it maybe in the future.
Support of multilib build in configure and in gcc. Parts are already present in gcc's 4.5 version by using target triplet -w64-mingw32.
gdb -- Native support is present, but some features like multi-arch support (debugging 32-bit and 64-bit by one gdb) are still missing features.
mingw-64-todo-list