I know there are already a few answers to this question but I can't seem to understand why I keep getting this error.
So here's the explanation:
I have 64 bits machine in which I've installed Windows 7 x64. I am compiling my Code under GCC (CodeBlocks) on Windows without any problem AT ALL. Then I decided that my application has to be portable, and I decided to compile it under GCC on Linux. In my other 32bit machine the code is compiling without any problem. However, on my 64 bit machine, I decided to install Ubuntu as Wubi. Of course I have installed Wubi x64 version as well.
I installed Ubuntu successfully under Wubi, I installed all necessary stuff, but when I try to compile my project, I get in the very first line the error 'cpu you selected does not support x86-64 instruction set'. Ok, this sounds completely non sense to me, taking into account that I've installed Wubi x64, on Windows 7 x64, on a 64bits machine. So why the hell am I getting an error saying that my CPU does not support x86-64 instruction set?
Could it be JUST because I have installed WUBI instead of installing Ubuntu on root in a normal way? I really can't seem to get this thing.
Thank you very much
EDIT: Ok, somewhere in Codeblocks I found the option that was checked for "Pentium M" architectures. I've unchecked it and now I get several erros such as:
error: cast from void* to int loses precision.
For which reason should this happen ONLY on Linux and not on Windows?
Based on this comment:
EDIT: Ok, somewhere in Codeblocks I found the option that was checked for "Pentium M" architectures. I've unchecked it and now I get several erros such as:
This was the reason for the compilation problem - "Pentium M" is a 32bit architecture. gcc under CodeBlocks will produce 32bit code on Windows by default
The error:
error: cast from void* to int loses precision.
Is caused because the model for 64bit on linux x64 is LP64, where sizeof(long) == sizeof(pointer) == 64bits, and sizeof(int) == 32bits and you're trying to shove a pointer(void *)(64bits) into an int(32bits), which causes pointer information to be lost.
With a compilation error like that, it's most likely that the code is not 64bit clean.
For which reason should this happen ONLY on Linux and not on Windows?
Linux on x64 defaults to producing 64bit applications, you would need to add -m32 to the build options for the program to make it produce 32bit code (there is probably a CodeBlocks target option to do this)
Related
I am cross-compiling a C / C++ application to run on a Raspberry Pi 4 with the arm-rpi-4.9.3-linux-gnueabihf compiler from the Tools Github Repository on an x64 Debian Linux system running in a VM. I am having some issues with this application so I built Valgrind from source on the Raspberry Pi with GCC 8.3.0-++rpi1.
The compiler binaries I am using can be downloaded here: https://github.com/raspberrypi/tools/tree/master/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf
If I run Valgrind on the RPI I get a number of errors, many of which indicate "Invalid read of size 8". My understanding is this would be typical on 64-bit architecture (8*8 = 64) but may be misleading on this 32-bit system unless the application was accessing a 64-bit data structure. Also, running Valgrind on the same application, built for and running on an x64 system, does not identify errors at these same locations, which makes me think that either the compilation toolchain is introducing an ABI issue or that Valgrind is giving misleading error indications -- or both.
Valgrind also indicates on startup:
--3451-- Arch and hwcaps: ARM, LittleEndian, ARMv8-neon-vfp
--3451-- Page sizes: currently 4096, max supported 4096
However $ uname -m indicates: arm7l, which I understand to be 32 bit (and definitely not ARMv8).
Can anyone provide any guidance on what might be going wrong here?
Thanks!
So i was having trouble with reading memory. I was successful reading values that has short addresses like 0x5CD38994 but when i try longer addresses like 0x2840C6C68D8 i only get 0. Some people said that i should compile my code for 64bit. But i don't know if i am compiling it for 32bit or 64bit. How to learn that and is it changed on my IDE or is it about compiler? I am using Eclipse IDE and GCC compiler. What should i do to compile my code for 64bit?
That works:
ReadProcessMemory(pHandle, (LPVOID)0x5CD38994, &my_value, sizeof(my_value),0);
That does not:
ReadProcessMemory(pHandle, (LPVOID)0x2840C6C68D8, &my_value, sizeof(my_value),0);
0x2840C6C68D8 is a 64 bit address. You cannot use ReadProcessMemory() from a 32bit process and try to read a 64bit address, you must compile for x64.
To compile for x64 on GCC use gcc -m64, you should be able to add that to your compiler/linker flags somewhere in the settings for your IDE
I want to add the MSVC 2017 compiler correctly inside my Qt 5.13, I know where to add it! But, don't know : "How to? What is required to be filled inside the add compiler's menu?"
I have tried too many things. I have a long long story with Qt's main problem!
My main problem is : "module machine type 'x64' conflicts with target machine 'x86'" which appears in the console when I build the Qt application!
I am going to include some of the things that I have tried :
Tried to build from the Qt app and the Console.
Tried all the compilers that are auto-detected from Qt.
There are more, but no need to mention the rest.
On my default kits, Most of the names were in this order : "Qt 5.13.0 for UWP 64/86-bits (MSVC 2017)".
I thought that it must be MSVC 2017, so I tried to setup MSVC 2017 (I have MSVC 2019). I found the compiler's main program which is : "cl.exe". I went to Qt auto-detected compilers, I did not find it! I tried to add it by copying the commands for qmake.exe and jom.exe from another kits that already made for me.
However, I put the compiler's type 'custom', because I did not find MSVC. Is that wrong, and what does that differ from the other types?
My next thing to fix (actually try) is this :
The picture above contains the compiler's path and Make's path.
I need to find the Make path tool, I think it is required, isn't it?
I tried to run the program without Make step, ONLY qmake step. Which led me into another problem when running the program : "An Error has Occured when trying to Build/Deploy your program".
I filled the compiler's path correctly, but I don't know how to fill the make path, I don't even know what is make path.
Note that Qt is not giving me any result because the make path is not filled correctly!
I hope that everything is described and all the information that you need is already included in the story above!
You cannot add MSVC manually to Qt Creator. You do need to have it auto-detected.
Also the mechanisms of detection changes depending on MSVC version and Qt Creator version. So be sure to use the latest version of Qt Creator (4.9.2 at this time) to make sure all your installed MSVC toolchain are detected.
Also given you comment you seem to confuse 64-bit and 32-bit.
x86 means 32-bit and amd64 means 64-bit.
This gives:
x86 32-bit compiler that produces 32-bit exe
x86_amd64 32-bit compiler that produces 64-bit exe
amd64 64-bit compiler that produces 64-bit exe
amd_x86 64-bit compiler that produces 32-bit exe
So if you wan to produce 32-bit programs, you can use x86 or amd64_x86. If you want to produce 64-bit programs, you can use amd64 or x86_amd64.
If at some point you want to compile a Qt porgam, but Qt Creator does not recognize your MSVC toolchain, you still have a solution:
Open Qt 5.12.4 (MSVC 2017 64-bit) from the start menu
In the prompt run C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat amd64
Run qmake and enjoy
You can't manually add MSVC to Qt Creator. If you want to use it make sure to have the correct Visual Studio version installed.
I suggest reinstalling Visual Studio if the MSVC compiler don't appear in the Compilers tab.
I have a program that I made in Visual Studio 2010. I built the program in release mode and Win32 solution platform. I then made an executable by following this guide step by step. I then copied the setup.exe that was created onto a new 32-bit computer. I then get this error message when I try to run the setup on the new computer:
Why is the setup not working? I built the program in Win32, so it should work on a 32-bit computer? Am i missing something? Any help would be appreciated.
There are 3 major reasons for this to happen. The Windows executables contain 3 fields that must be matched by the OS: Minimal OS version number, correct CPU type and correct CPU bit-ness. Now you're probably not running into a Windows version issue (I think the error message is different), you're quite unlikely to have the wron CPU type (ARM builds are pretty hard to make by accident) so that leaves as the most likely scenario that you actually made a 64 bits build.
"Win32" is a rather deceiving term here, it doesn't always exclude 64 bits builds. E.g. the macro WIN32 is defined for 64 bits builds as well.
#Mailerdaimon and #MSalters you were correct. Even though I was building the program in win32, the target machine was x64. After changing it to x86 the program ran. Thanks for everyones help!
I currently have MinGW for Windows and would like to develop for Linux(I have read that I need Headers), where would I get Linux headers and set up to compile both Windows and Linux programs with MinGW code::blocks.
Note: I have researched but could not find anything from Windows to Linux only Linux to Windows.
I do not exactly see what you mean by "develop", but if you want to work in an environment that produces binaries for some Linux system, you can not really "develop" because you cannot really run / debug them on Windows (when using cross-compilation).
On the other hand, if you want to develop code that compiles on Linux, you are already there. Since you are developing using MinGW, you are pretty much guaranteed that your code will compile under Linux with corresponding version of GCC. To produce a binary for the Linux distribution of choice, you can use VM, speed should not matter since you are not probably going to do it often.