Source file not compiled Dev C++ - c

I just installed Dev C++ and I am learning C programming.
the code i used was
#include <stdio.h>
int main()
{
printf("Hello world");
getch();
}
I saved it as a .c file. When I compile it works fine, but when I compile and run it says source file not compiled. So I googled buncha things and came across this video on youtube which shows you how to fix it. I also saw other forums on google which suggest the same thing... However, after doing whats asked, Now I can't even compile my code. I get this error
Compiler: Default compiler
Executing C:\Dev-Cpp\bin\gcc.exe...
C:\Dev-Cpp\bin\gcc.exe "C:\Users\ubaid\Documents\C\Untitled1.c" -o "C:\Users\ubaid\Documents\C\Untitled1.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
gcc.exe: Internal error: Aborted (program collect2)
Please submit a full bug report.
See <URL:http://www.mingw.org/bugs.shtml> for instructions.
Execution terminated
I have also used what is asked on this link, and still no luck..
http://learntogeek.com/miscellaneous/solved-source-file-not-compiled-error-in-dev-cpp/
I am using windows 8

I was having this issue and fixed it by going to:
C:\Dev-Cpp\libexec\gcc\mingw32\3.4.2
, then deleting collect2.exe

Install new version of Dev c++. It works fine in Windows 8. It also supports 64 bit version.
Download link is http://sourceforge.net/projects/orwelldevcpp/ .

I guess you're using windows 7 with the Orwell Dev CPP
This version of Dev CPP is good for windows 8 only. However on Windows 7 you need the older version of it which is devcpp-4.9.9.2_setup.exe
Download it from the link and use it.
(Don't forget to uninstall any other version already installed on your pc)
Also note that the older version does not work with windows 8.

This maybe because the c compiler is designed to work in linux.I had this problem too and to fix it go to tools and select compiler options.In the box click on programs
Now you will see a tab with gcc and make and the respective path to it.Edit the gcc and make path to use mingw32-c++.exe and mingw32-make.exe respectively.Now it will work.
The reason was that you were using compilers built for linux.

You can always try doing it manually from the command prompt. Navigate to the path of the file and type:
gcc filename.c -o filename

I found a solution. Please follow the following steps:
Right Click the My comp. Icon
Click Advanced Setting.
CLick Environment Variable. On the top part of Environment Variable Click New
Set Variable name as: PATH then
Set Variable Value as: (" the location of g++ .exe" )
For ex. C:\Program Files (x86)\Dev-Cpp\MinGW64\bin
Click OK

This error occurred because your settings are not correct.
For example I receive
cannot open output file Project1.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe: *** [Project1.exe] Error 1
Because I have no permission to write on my exe file.

After some investigation, and with Dr.Topaz's help, I have learned that you will want to confirm that the program set for g++ in the Compiler Options really does compile the source code. In my case, the C:\Dev-Cpp\bin\g++.exe program did not create an exe, but the C:\Dev-Cpp\bin\c++.exe program did. Either program appears to be intended to take the same arguments and options as GNU g++. I would love to find an actual doc on the Dev-C++ compiler programs, but I have not so far.
You can test the compiler program with a simple example like this:
C:\Dev-Cpp\bin\c++.exe hello.cpp -o hello.exe
Currently in 2021, the Dev-C++ site invites you to download either original Dev-C++ or a newer fork by a group named Embarcadero.
I decided to try the Embarcadero version and the experience was slightly better. The UI is still a tad dated, but the g++.exe program it came with was able to compile programs without issue. Again, take note of where the program is being installed, but in my case, the Embarcadero compiler programs were in C:\Program Files (x86)\Embarcadero\Dev-Cpp\TDM-GCC-64\bin.
Both original Dev-C++ and Embarcadero come with mingw-32 versions of the compiler programs that from what I see do work in a Git Bash console, with slight differences such as not recognizing a default locale when using the command std::cout.imbue(std::locale("")).

I faced this similar error, and none of the solutions worked.
so I tried to download the latest version from here, https://www.bloodshed.net/
I rerun the program.
and everything is now working correctly.

I was facing the same issue as described above.
It can be resolved by creating a new project and creating a new file in that project.
Save the file and then try to build and run.
Hope that helps. :)

Related

VSCode Microsoft C/C++ Extension Using Old MinGW System Path

I'm trying to run a simple Hello World C program in VSCode, on Windows 10, to test whether things are going fine or not (I previously had to reinstall the OS). So this is the code:
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}
Should be simple, and it should run perfectly well, I thought. I tried it with these options, which I assume was from the Code Runner (by Jun Han) extension. When I try selecting the "Run Code" option, everything works well, and the code runs perfectly. When I tried the "Debug C/C++ File" or the "Run C/C++ File" option, however, this was what I got.
* Executing task: C/C++: gcc.exe build active file
Starting build...
C:\Compilers\MinGW\bin\gcc.exe -fdiagnostics-color=always -g D:\Alfred\Studies\College\Skripsi\resources\preparations\CTest\HelloWorld.c -o D:\Alfred\Studies\College\Skripsi\resources\preparations\CTest\HelloWorld.exe
The system cannot find the path specified.
Build finished with error(s).
* The terminal process failed to launch (exit code: -1).
* Terminal will be reused by tasks, press any key to close it.
Worth noting here that C:\Compilers\MinGW\bin\gcc.exe is my MinGW directory in the system path before I reinstalled the OS. I'm not sure why it pulls that specific path, considering:
I've tested the MinGW installation on the reinstalled OS, and running the gcc --version command works on cmd,
The system environment variable has been set to the new path (C:/MinGW/bin),
If it's really a problem with MinGW paths, logically the "Run Code" option should also fail. Yet it doesn't.
Finally, I've also tried restarting the laptop, reinstalling MinGW, reinstalling VSCode (along with deleting the .vscode folder in %USERPROFILE% and Code folder in %APPDATA%), but this problem still persists.
I've been looking for the possibility as to why for hours now, yet I haven't managed to. Was hoping some of you could tell me what I overlooked here.
P.S.:
The only extensions I have installed are C/C++ by Microsoft and Code Runner by Jun Han.
Please bear with me if my question was missing some details - I have very little experience in asking questions here.
Edit 1: I've been told this was due to Microsoft's C/C++ extension, and not Jun Han's Code Runner. I have edited the title to reflect so.
The two options you mentioned are from the Microsoft's C/C++ extension: they use the C_Cpp.default.compilerPath setting to locate your compiler. You can change it either the settings GUI or in the JSON file.

Codelite not running C programs

Everytime I try to build and run a program, including the standard 'Hello world!' nothing happens, I get:
==== Program exited with exit code: 0 ====
Time elapsed: 000:00.000 (MM:SS.MS)
Press any key to continue...
At the bottom it says:
'ming32-make' is not recognized as an internal or external command, operable prgram or batch file.
I have Codelite version 16 on Windows 10. I also have MinGW installed to C: and have edited the Environment variables to include C:\MinGW\bin
However, in command prompt gcc --version shows me the gcc version in C:\Users\me> and not C:\MinGW
I don't know if this is relevant or not.
All the other results seem to suggest a compiler not found problem, but this does not seem to be my case. Thanks in advance.
This is what I have installed at the moment. Can I get 'make'from one of the other files?
The Installed files
Looks like you either don't have ming32-make.exe or it can't be found.
Also I notice you still use old MinGW. I would recommend switching to newer MinGW-w64 (which supports both Windows 32-bit and 64-bit).
The standalone build from https://winlibs.com/ does include ming32-make.exe, and since you can just unzip it (no installation needed) you can try it without removing the old MinGW. Just make sure you don't have anything in your PATH variable to avoid running programs from the wrong location.
ming32-make.exe is either not installed or can't be found on your Environment variable PATH.
No, there is no mingw32-make in that bin folder. When I used the Installer originally I only selected: mingw32-gcc-g++-bin although there were other bin files. Where can I get it?
mingw32-make is outdated.
See How to compile makefile using MinGW?
If you are having problems with mingw, I would recommend using MSYS2 or a package manager like Chocolatey.
Just get rid of the previous installation first. Not mandatory but prevents confusion and storage drain due to multiple copies of mingw.
To install MinGw using chocolatey, run cmd as admin and use
choco install mingw
For make
choco install make
What worked for me was also installing mingw32-base-bin from the Installer (see second option in image in the original question).
The installation tutorial I was following did not mention installing this.
I've decided to leave this here as an answer in case someone else runs into a similar problem.
MSYS is a good option for compilers in recent CodeLite or VS-Code installation. https://www.msys2.org/.
Once you downloaded the compiler using the following steps from the installer but still have the problem with the make then follow these steps:
Reopen the MSYS2 terminal from your windows if that is previously installed.
Run the command pacman -S --needed base-devel mingw-w64-x86_64-toolchain
You will be asked to select the option from the list. You should select the option which refers to mingw-w64-x86_64-make.
Once the installation is successfully done, then open CodeLite settings->Buid Settings and check your Make file location. If that is empty or showing an unknown location then click the three dots at the very right of that box. The browse and navigate to location or where you installed the make by pacman. In my case it is C:/msys64/usr/bin/make.exe.
Click Apply and Save.
Now it might be needed to create a fresh workspace and re-run your code.

Mingw gives my a libwinpthread-1.dll was not found error when compiling code

I just downloaded and installed Mingw. I also setup the system environment variables for C:\MinGW\bin and C:\MinGW\msys\1.0\bin. I wanted to test to see if I had installed it correctly (it seemed to be since running gcc --version worked), so I wrote hellow world in c and tried to compile with gcc main.c -o hello_world.exe. However I got the error:
"The code execution cannot proceed because libewinpthread-1.dll" was not found. Reinstalling the program may fix this problem."
I have tired reinstalling it and restarting my computer. I have also tried to see if this problem has occurred to others, and while there are a few places it is mentioned, I can't seem to find a solution mentioned. I have thought about trying to download the dll separately, but if I remember correctly, downloading dlls is a big no no.
Awhile ago I installed mingw though chocolatey and it seemed to be working. I have deleted that download from my computer and removed the paths, since I wanted to try to install it the normal way. Could this be part of the error?
Any ideas what the issue could be? Thanks!
You have built an .exe file that depends on libwinpthread-1.dll.
Solutions to make sure the .exe can run:
Add the MinGW bin path to your PATH so libwinpthread-1.dll - this would only fix it for your own system so I wouldn't recommend this if you want to use the .exe file on other systems.
Copy libwinpthread-1.dll from MinGW in the same folder as your .exe file. This is generally needed for any shared dependancy library your .exe is linked against.
Build a static .exe (--static linker flag) to avoid the shared (.dll) dependancy.
Yes! probably is an error, cause MinGW is a bit stinky when it comes to DLLs
Here are some things you have to check:
Make sure the variable helding the location of MinGW is named "path"
and its pointing at: C:\MinGW64\bin

Eclipse CDT Debug not in executable format: File format not recognized after strawberry installation

Maybe I'm missing something obvious since I searched the internet for quite a while but could not find a solution for the following problem:
I'm using Eclipse Kepler SP2 (Build id: 20140224-0627) with CDT and MinGW as compiler backend. Debugging C code with gdb worked great up until today (at least I noticed the problem today).
Now I get the following error message when i want to start a progam in the debugger:
Error in final launch sequence
Failed to execute MI command:
-file-exec-and-symbols C:/[...]/Debug/test.exe
Error message from debugger back end:
"C:\[...]\Debug\test.exe": not in executable format: File format not recognized
The program runs nicely and so I thought I might have screwed up some settings. But when I tried to debug an old program, everything worked until I recomplied the old program -> same problem. If I ask the C-wizard to create a new "Hello World" ANSI C application with MinGW, the same problem occurs.
The compile commands which were used are
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\test.o" "..\\src\\test.c"
gcc -o test.exe "src\\test.o"
I did not update my MinGW in between, but updated Eclipse.
Do you have any pointers on where to look for the problem?
Edit: I just checked the binary type: My old projects are all [x86/le], the newly compiled ones are [amd64/le]. This should be a trace.... Will update posting according to progress.
Edit2: argh I installed strawberry perl a few days ago, and the installer has changed the environment variable MINGW_HOME in origin BUILD SYSTEM to c:\strawberry\c and this screwed up my builds. Resetting it to my c:\MinGW solved the issue.
I'll post this as answer, too. Heading and tags have been updated to point to this issue more directly.
I installed strawberry perl a few days ago, and the installer has changed the environment variable MINGW_HOME in origin BUILD SYSTEM to c:\strawberry\c and this screwed up my builds. Resetting it to my c:\MinGW solved the issue.
BTW: This happened, because strawberry added c:\strawberry\c to the PATH in front of my custom c:\MinGW and eclipse adds those to the BUILD SYSTEM variables.
It should be a parser problem, what is your binary parser under Project/Properties/Build/Settings ?
Check Project->Properties ->C/C++ Build ->environment and path for MINGW_HOME
make sure you have right gdb version (by checking under debug Configuration ->environment).

Compiling with C.vim on Windows?

C.Vim works, as evidenced by the commands I've been using, syntax highlighting, and template. But I use \rc and nothing happens. \rr tells me that there is no .exe, and an Everything search tells me that it's not a directory issue.
In all the resources I've read, I don't see anything that says I need to point it to a specific compiler, though I've installed Visual Studio 2010.
How do I get C.vim to compile my code? I'm a relative beginner with Vim and C.
Edit: I've set the Windows Environment Variable to C:/cygwin/bin where I've downloaded and installed the GCC packages, but am still getting the same error.
Edit2: I've downloaded Msys and Mingw as well. I tried setting up Eclipse as well, following the instructions here. Running make from the command line tells me that GNU Make 3.81 is running. Running :make in Vim tells me:
shell returned 2
(1 of 1) : make *** No targets specified and no makefile found
Trying Eclipse, I get another make error:
make: *** No rule to make target `all'; Stop.
Edit3: I got Code::Blocks running, which is what I used to run. (It's been a while since I programmed, and even then I was a beginner.) I didn't really have to configure it at all, though I would still prefer to use Vim, so help is still much appreciated.
Edit4: running make vimFirst (vimFirst.c is my file) compiles! Running the program with :! vimFirst.exe works as expected. Now returning to the original question, how to do it with C.vim? It would be so much more convinient to type \rc and have the program compile and run, which is about 1/10 of the typing of the other method.
Edit4: running make vimFirst (vimFirst.c is my file) compiles! Running the program with :! vimFirst.exe works as expected. Now returning to the original question, ... type \rc and have the program compile and run...
Check your maps for \rc and \rr:
:map \rc
:map \rr
If no mapping exists, you might have no_plugin_maps or something similar set in your vimrc.
I think you'll get what you want if you set them up like this:
nmap \rc :make %<<CR>
nmap \rr :! %<.exe<CR>
If you're really familiar with Visual Studio and want to use nmake to build your code, you should check out the :compiler option. :compiler msvc will setup your makeprg and errorformat for nmake and Visual Studio's compiler.
I'm not sure what make is currently using to build your code, so I don't know what compiler setting you'd want.

Resources