Dev C++, created by Bloodshed programming, is a free IDE for programming in C/C++. It works with Windows 7, 8 and 10 and can be used to compose Windows or control centre based C/C++ programs effectively, and you can also make an installer for your application.
In this article, we’re going over what is the Dev C++ build error, and quick fixes for the error.
What is the Dev C++ build error?
Build represents a compilation of the code. If the code is built successfully, it is now executable and does not have any errors. An error is the illicit use of commands or operations, leading to abnormal functionality. An error prevents the code from being built or compiled and hence becomes non-executable.
There are five different types of errors commonly seen in C/C++.
- Syntax error
- Run-time error
- Linker error
- Logical error
- Semantic error
The syntax error is also known as compilation error or build error.
Syntax errors
Syntax errors occur due to a violation of the basic rules or syntax for writing the code in the C/C++ language. This error prevents the code from getting compiled. All the syntax errors detected by the compiler need to be resolved for the code to compile successfully.
The most common syntax errors are forgetting to put a semicolon, incorrect number of parenthesis and using a variable without the declaration, among others.
Note the words failed and Error 1 in the snipped above. This indicates that the code ran into a build error.
Also read: How to create a project in Dev C++?
Ensure that the version being used is the latest and is supported by your device.
The first step to follow when a build error occurs is to check the errors and the lines where it is happening. Then, under the Compiler tab in the bottom panel, the error message is mentioned alongwith the line number.
Follow the message and attempt to debug the code. The error in the above snippet is expected ‘;’ before return, which indicates that the 6th line is missing a semicolon.
Paranthesis
Build errors may occur due to the incorrect opening/closing of the parenthesis or an incorrect number of them. Always make sure that function calls like main(), or any other user-defined function has the opening and closing brackets next to them with or without the parameters in them depending on the type of function.
When writing a conditional statement like if, if-else, for, switch, while and others, double-check the number of opening parenthesis. Nested loops might often have a confusing set of brackets. Always keep practising making both the start and end set of parenthesis when starting a new loop.
Spell check
While coding, the spellings of variables, functions, methods, and keywords often go wrong and sometimes may not be detected as a spelling error in the console, which makes it tricky to fix the errors. C/C++ is a case-sensitive language.
All user-defined variables, functions and methods must be called in the same case for the code to build error-free. Try to keep the names of variables and functions easy to remember, something meaningful to its function in the code and not very complicated in terms of the casing.
Semicolon
Forgetting a semicolon is one of the worst nightmares of any coder. The absence of a single semicolon can prevent the entire program from building.
If the semicolon is missed within a loop, it can cause many more errors that may make no sense. Ensure to insert a semicolon after every single line of code, with the given exceptions of functions and beginnings of loops.
Data type
Every initialised variable and user-defined function has a specific data type. Data types include int or integer, str or string, float and many others. Using the wrong data type under these variables can cause the entire program to break down.
When writing a command for taking input or initialising the values for the variables, double-check the originally initialised data type for it. If the function is an array or tuple, or dictionary, check all the individual parameters before calling them.
Syntax
While C and C++ are both similar and can be written in the same software, there are a few key differences in the syntax of the two languages. For instance, the commands for input and output in C are scanf and print; on the other hand, cin and cout are C++ commands.
Writing a C code in C++ and vice-versa often leads to syntax errors that may be correct in the other language. Always use syntax for the language in which the file/project was created.
Another important aspect of the syntax is the include files. There are specific header files to be written initially in the code to use specific functions like input-output, mathematical functions and others. The absence of header files prevents the function from being verified and used; hence the build may fail.
Also read: How to add a header file in Dev C++?
8 / 8 / 5 Регистрация: 07.12.2014 Сообщений: 73 |
|
1 |
|
27.02.2015, 16:59. Показов 9707. Ответов 11
Здравствуйте, у меня есть ошибка с комплиации в dev c++, ОС Windows 8.1 Профессиональная Миниатюры
0 |
55 / 56 / 34 Регистрация: 29.12.2012 Сообщений: 478 |
|
27.02.2015, 17:08 |
2 |
А код ошибки то и не показали….
0 |
41 / 41 / 26 Регистрация: 24.02.2015 Сообщений: 151 |
|
27.02.2015, 17:08 |
3 |
Попробуй добавить return 0;
1 |
55 / 56 / 34 Регистрация: 29.12.2012 Сообщений: 478 |
|
27.02.2015, 17:12 |
4 |
Не по теме
Попробуй добавить return 0; Гении мыслят одинаково
1 |
8 / 8 / 5 Регистрация: 07.12.2014 Сообщений: 73 |
|
27.02.2015, 17:18 [ТС] |
5 |
Добавил return 0; Тоже дает одинаковый ошибку Рисунок
0 |
41 / 41 / 26 Регистрация: 24.02.2015 Сообщений: 151 |
|
27.02.2015, 17:27 |
6 |
Наверное, кривая сборка dev c++. Попробуй переинсталить.
0 |
8 / 8 / 5 Регистрация: 07.12.2014 Сообщений: 73 |
|
27.02.2015, 17:34 [ТС] |
7 |
Я установил dev c++ 4.9.9 dev и c++ 5.3, я тоже думал что некоторые компоненты не установился, и потом установил Visual studio 2012 и Visual Studio 2013. Не помогло. Потом я установил эти сборки на другом компьютеры на который установленоWindows XP и Windows 7. У них работал.
0 |
41 / 41 / 26 Регистрация: 24.02.2015 Сообщений: 151 |
|
27.02.2015, 17:49 |
8 |
Может быть это косяк Windows 8. В любом случае проблема здесь не в коде. Так что надо эксперементировать. Отключить антивирусник, переустановить компилятор, библиотеки.
0 |
быдлокодер 1723 / 910 / 106 Регистрация: 04.06.2008 Сообщений: 5,666 |
|
27.02.2015, 18:00 |
9 |
Если поможет- ось почему-то палит компилятор. ТС:
0 |
0 / 0 / 0 Регистрация: 10.01.2015 Сообщений: 1 |
|
27.02.2015, 18:13 |
10 |
Erkin надо устанавить оs windows 7 ))))
0 |
быдлокодер 1723 / 910 / 106 Регистрация: 04.06.2008 Сообщений: 5,666 |
|
27.02.2015, 18:20 |
11 |
Erkin надо устанавить оs windows 7 Если уж так, то XP (на чём и работаю). Но мы должны найти в чём именно плоха windows 8, поэтому будем разбирать всё предметно.
1 |
8 / 8 / 5 Регистрация: 07.12.2014 Сообщений: 73 |
|
27.02.2015, 19:03 [ТС] |
12 |
Друзья, все работал спасибо за внимание. Обновил систему и переустановил dev c++
0 |
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-Cppbing++.exe
program did not create an exe, but the C:Dev-Cppbinc++.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-Cppbinc++.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)EmbarcaderoDev-CppTDM-GCC-64bin
.
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 have read other posts regarding this error but I have not been able to solve my problem. It could be something obvious with my code, but the code seems fine to me. The compiler log output is:
mingw32-make.exe -f "C:UsersMichaelDesktopDurham CoursesSummer 2015OOP Object-Oriented ProgrammingDev CPP DirectoryMakefile.win" all
g++.exe cash.o main.o -o Lab3Functions.exe -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc
main.o:main.cpp:(.text+0x0): multiple definition of `cash(double, int&, int&, int&, int&, int&, int&, int&)'
cash.o:cash.cpp:(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
C:UsersMichaelDesktopDurham CoursesSummer 2015OOP Object-Oriented ProgrammingDev CPP DirectoryMakefile.win:25: recipe for target 'Lab3Functions.exe' failed
mingw32-make.exe: *** [Lab3Functions.exe] Error 1
Compilation failed after 0.91 seconds with errors
Could it be this multiple definition bit toward the end? What I’ve done (as per my assignment) is created one file (cash.cpp) which contains the definition of cash function and then I’ve got:
#include "cash.cpp"
at the top of my main. Is that not correct?
asked Jul 17, 2015 at 16:31
4
I tried simulating your issue:
Here is my test.cpp with the main function:
#include <stdio.h>
#include "cash.cpp"
using namespace std;
int main()
{
printf("%d",cash());
return 0;
}
And here is cash.cpp:
int cash()
{
return 10;
}
And 10 is the output.
Your cash.cpp and the main file must be in the same directory. And ensure only one such file is in the same directory.
Also it could be related to C Drive privileges on Windows.
In that case a workaround can be found here: Dev C++ compilation error, permission denied.
Also, see this (Possible linker failure). Check that the forward declarations of the function are consistent with the definition.
answered Jul 17, 2015 at 16:38
adrian008adrian008
3956 silver badges18 bronze badges
5
I ended up creating a header file which contained the definitions for the functions in my main()
. I used #ifndef
to get around the multiple definitions problem.
My assignment required the use of a .cpp
but I can’t get it to work, so at least this compiles and runs. Thank you all for your help!
answered Jul 17, 2015 at 18:34