Exec Format Error using Codelite IDE and Ubuntu - c++

I am trying to run a C++ program using the IDE Codelite on an Ubuntu 18.04.5 LTS computer with MinGW compiler (i686-w64-mingw32). When I execute it gives the error "Exec Format Error". I can't figure out how to fix this. I appreciate any advice.

You say you are trying to run a program, correct? MinGW is a cross-platform toolchain for Windows. Nothing you build with it will run natively on Linux. Use GCC if you want to write an application you can run.
When you say "execute", do you mean build using Codelite or execute the program? A Codelite error could be a bug, or a misconfigured setting, or something. A simple google of "exec format error" told me the error came from an app failing to execute. It is typically followed by a description, such as "permission denied". It is most likely, however, to be because you are trying to execute a windows application.

Related

codelite scan could not locate mingw any on your machine error

I installed mingw and checked it in cmd by writing c++ --version it runs sucessful but whenever i open my codelite it says could not locate any mingw on your machine i have tried reinstalling both mingw and codelite few times nothing works someone please help me
Tried scanning mingw compiler on codelite but it could not locate mingw and it(mingw) is already installed in my machine and running too help me please
I don't know much about this IDE but this link is probably what you are looking for.
https://wiki.codelite.org/pmwiki.php/Main/AddNewCompiler
Since the scan failed you will have to manually add the path to your compiler in codelite. The compiler will most likely be in the mingw folder under the name 'g++.exe'.

Build QT5 project on Ubuntu for Windows

I tried to build qt project on Ubuntu for windows, following the steps in this post
Building Qt 5 on Linux, for Windows
Everything is good except when I run make command, it complains about "i686-w64-mingw32.static-g++: Command not found". But I did see i686-w64-mingw32.static-g++ under /root/mxe/usr/bin. I have no idea what happen. Do I miss something?
You can try run the command directly in shell. If it goes wrong again, check the PATH.

Debugger for C++ eclipse gives the following error. 'Launching program name' has encountered a ... Error while launching command: gdb --version

I've always worked around the debugger issue, but now it has gotten too annoying. I'm working on more complex programs and can't anywhere if I cant debug my programs. Has any one else been able to fix this issue in eclipse? It works for java, but not more my C++ plugin from minGW
Debbugger for C++ eclipse gives the following error. 'Launching program name' has encountered a problem. Error while launching command: gdb --version
Assuming you are using Windows and have MinGW installed, you only need to locate the gdb executable in the MinGW bin folder. This can be done on the "Main" tab in the "Debugger" configuration of Eclipse:

What do I have to do to set C++ development in eclipse?

I am currently trying to set my eclipse so that I can start c++ development on my Windows computer. However, I am stuck with some errors. But first, here is what I did so far:
Installed the CDT for Eclipse
Installed Cygwin (with the additional packages gcc, gcc and make)
Added all "paths for headers" in Eclipse
The problem is that when I try to run my Hello World program, I get Launch failed. Binary not found.
I already build and rebuild the project but the program is still not running. It must be because of these errors that I have:
/bin/sh: g++: command not found
make: ***[src/HelloWorld.o] Error 127
What can I do to solve these errors?
Try running the Cygwin setup.exe again and select the packages for g++. Search for that and make sure those are installed. It should be under the name gcc-g++. The C++ compiler is installed separately from the C compiler.
Ok, I figured it out by myself. Since this really freaked me out, I want anyone else who has this problem to know how I solved it.
So apparently, since I had g++, gcc and all that installed, it had to be a problem with the path.
So what I did was check my path. If you don't know how to edit it, check this link http://www.computerhope.com/issues/ch000549.htm
So in there, I chose Path under the System variables and clicked on Edit.... What I noticed was that instead of C:\cygwin64 it said C:\cygwin. All I did was append the 64 (since I had installed the 64-bit version of cygwin) and I was done.
I restarted Eclipse, cleaned and built the project and the errors where gone!

Why does my C++ program crash on one machine and not on another?

I have written a simple C++ program that I am compiling using g++ in command prompt and also running it through command prompt. The code of my program is as follows:
#include<iostream>
int main()
{
std::cout<<"Hello world"<<std::endl;
return 0;
}
When I run this code. I get a "hello_world.exe has stopped working" kind of error on my office machine. But when I run the same portion of code at home it works fine. Any idea why this is happening? Also, if I remove std::endl it works fine.
I am using Notepad++ to code.
UPDATE: I am not running the same binary on both machines. I compile on both the machines separately. I am using windows 7 32-bit at both the locations. I am using mingw. For compiling I type "g++ hello_world.cpp -o hello_world.exe". For running I typed "hello_world.exe". I downloaded mingw from the site mingw.org and used the "mingw-get-setup.exe" to install. And I installed g++ and gcc through the command prompt using the command "mingw-get install gcc g++".
When you return from main(), your program stops working. In a gui-based environment, I wouldn't be surprised to see a pop-up message warning about a terminal-based application reaching completion where the user has to click "dismiss" before the terminal spawned to support the application is terminated as well. Windows 9x used to have such checkboxes in launcher preferences for MS-DOS programs.
Questions you should use to find out the issue are:
- Is it showing the same error message if you launch the shell yourself ?
- Do you use the very same binary on both machine, and if so, are your machines both capable of running it (e.g. not trying to launch a 64-bit binary on a 32-bit OS as one of the case)
It would help to see the exact text of the error message.
Your program depends on C and C++ runtime libraries. I suspect you have the libraries installed on the machine where it works and don't where it doesn't, probably because you installed Visual Studio on the machine where you wrote the code but not on the machine where you're trying to run it.
You can install the runtime libraries on the second machine by search Microsoft Download for vcredist for the version of Visual Studio that you compiled the program with.
Works fine for me on Windows 7 32-bit using MinGW. I suspect that you've not installed all the components you need to run the program. I would re-install MinGW and Msys and be sure you install all the necessary C and C++ components.
g++ --version
g++.exe (GCC) 4.6.2
a.exe
Hello World
I have used MinGW and Msys on Windows for many years (several different versions) and have never had issues compiling, linking or executing standard C and C++ programs.