Aditsu's Unofficial Dev-C++ FAQ

14
Main Page Computing Misc A bout Aditsu's Unofficial Dev-C++ FAQ Computing programming C++ Important: I haven't used Dev-C++ or gone to the related forum for a long time now. Everything below this paragraph is really old information. I would also like to apologize because I've received some comments and suggestions about this FAQ from time to time, but haven't done anything about them. Some of those emails were lost, and some are just sitting there waiting to be reread. I'll try to get to them, but anyway now there is a comment form at the bottom of the page if you have something to contribute. Here goes the FAQ: Before you even think of looking for your problem and answer on this page, please go to http://www.bloodshed.net/dev/devcpp.html and make sure you have the latest version. Currently (16 Oct 2005) the latest full version is 4.9.9.2 (9 MB). Do not install the old Dev-C++ 4 unless you have special reasons to do it. This FAQ may contain issues that are no longer applicable or have already been solved; I'll remove them later. Questions: Top 5: When I run my console application, the black window flashes a bit then closes automatically 2 (some path) \2 unable to run program file This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. [Linker error] undefined reference to (something) Why can't I use conio.h functions like clrscr, gotoxy etc? Installation/uninstallation: How can I install Dev-C++ correctly? How can I uninstall Dev-C++ cleanly? Problems working with the IDE: How can I see the output of my program? The error messages appear truncated Dev-C++ doesn't recompile my code although I made modifications

Transcript of Aditsu's Unofficial Dev-C++ FAQ

Page 1: Aditsu's Unofficial Dev-C++ FAQ

Main Page Computing Misc About

Aditsu's Unofficial Dev-C++ FAQ Computing programming • C++

Important:

I haven't used Dev-C++ or gone to the related forum for a long time now. Everything belowthis paragraph is really old information. I would also like to apologize because I've receivedsome comments and suggestions about this FAQ from time to time, but haven't doneanything about them. Some of those emails were lost, and some are just sitting therewaiting to be reread. I'll try to get to them, but anyway now there is a comment form at thebottom of the page if you have something to contribute. Here goes the FAQ:

Before you even think of looking for your problem and answer on this page, please go tohttp://www.bloodshed.net/dev/devcpp.html and make sure you have the latest version.Currently (16 Oct 2005) the latest full version is 4.9.9.2 (9 MB). Do not install the oldDev-C++ 4 unless you have special reasons to do it.This FAQ may contain issues that are no longer applicable or have already been solved; I'llremove them later.

Questions:

Top 5:When I run my console application, the black window flashes a bit then closesautomatically2 (some path)\2 unable to run program fileThis file includes at least one deprecated or antiquated header. Please consider usingone of the 32 headers found in section 17.4.1.2 of the C++ standard. Examplesinclude substituting the <X> header for the <X.h> header for C++ includes, or<sstream> instead of the deprecated header <strstream.h>. To disable this warninguse -Wno-deprecated.[Linker error] undefined reference to (something)Why can't I use conio.h functions like clrscr, gotoxy etc?

Installation/uninstallation:How can I install Dev-C++ correctly?How can I uninstall Dev-C++ cleanly?

Problems working with the IDE:How can I see the output of my program?The error messages appear truncatedDev-C++ doesn't recompile my code although I made modifications

Page 2: Aditsu's Unofficial Dev-C++ FAQ

Where is the resource editor?Can I use Dev-C++ with other compilers?Does Dev-C++ support workspaces with multiple projects? How do I import Visual Cworkspaces?Dev-C++ uses gcc instead of g++ for linkingvUpdate doesn't work!I see <Err: xxxx> in various placesCode completion doesn't work well, crashes, kills my cat, etc.This IDE is too buggy, I want to use something else

Debugging questions:I can't debug, how do I debug?Can't evaluate object membersConsole I/O doesn't work while debuggingThe debugger doesn't stop at breakpoints in constructorsWhen I debug the program, Dev-C++ keeps opening new windows with the sourcecode

Problems by error message:2 (some path)\2 unable to run program fileThis file includes at least one deprecated or antiquated header. Please consider usingone of the 32 headers found in section 17.4.1.2 of the C++ standard. Examplesinclude substituting the <X> header for the <X.h> header for C++ includes, or<sstream> instead of the deprecated header <strstream.h>. To disable this warninguse -Wno-deprecated.`cout' undeclared (first use this function)[Warning] no newline at end of file`main' must return `int'[Linker error] undefined reference to `mcount'`clrscr' undeclared (first use this function)[Linker error] undefined reference to `clrscr'[Linker error] undefined reference to `__gxx_personality_v0'[Linker error] undefined reference to (something)Fatal: 'all-before' does not exist - don't know how to make itbits/c++config.h: No such file or directory`this' is not an aggregate[Warning] unused parameter (something)

Other questions/problems:What is Dev-C++?Can I make software with Dev-C++ and distribute or sell it without giving away thesources?Why is the compiled executable file so large?How can I do graphics? Where is graphics.h?How can I write inline asm (assembly) code?

Page 3: Aditsu's Unofficial Dev-C++ FAQ

My resource file doesn't workI can't find the answer here, what can I do?How to ask questions on the forum?

Answers:

When I run my console application, the black window flashes a bit then closesautomaticallyHow can I see the output of my program?Your program does exactly what you tell it to do, and you didn't ask it to wait beforeclosing.You can add a command to wait for keyboard input before the program exits (e.g. before thereturn from main). A very simple example is system("pause"); which executes the"pause" system command (portability note: this only works in Windows and DOS); youneed to #include <cstdlib> (or #include <stdlib.h> for C programs) if the compilercomplains about the system function.Or you can use an instruction that reads something from the keyboard (e.g. cin.get(); ,getchar(); or cin>>variable; ). In that case you may need to clear the input bufferbefore reading, e.g. cin.sync(); before cin.get(); .Another option is to run your program from the command prompt; this is especially useful ifyou don't want it to wait before closing, or if it crashes before it reaches the keyboard-reading instruction.

2 (some path)\2 unable to run program fileUpdate: this problem should be solved completely in Dev-C++ 4.9.9.2.If you don't want to upgrade, or somehow you still get the error in 4.9.9.2, read on.

This happens when the IDE can't find one of the programs needed for compiling yourfile/project (usually it is make, gcc or g++).The most common cause is a nasty BUG in the Dev-C++ installation system: theuninstaller doesn't remove the Dev-C++ configuration files, and the installer doesn't overwritethem. So if you try to install Dev-C++ in a different folder without following theseinstructions, you will most likely get this error for everything you try to compile.To solve this, you can try my automatic Dev-C++ maintenance tool, and if it doesn't help (oryou prefer doing it manually) then there are two ways you can fix it:1. The "blind reinstall" solution: uninstall Dev-C++ cleanly (pay special attention to thedevcpp.ini and devcpp.cfg files if you have Dev-C++ 4.9.x.x), then reinstall the full latestversion (see top of this page) in a folder with no spaces in the path. It should workafterwards.2. The "smart fix" solution: read the compile log to see which program it tried to run; go toTools - Compiler Options - Programs and see what file it is looking for and in which folder(click the "..." button) and check if it is found in that folder. If the specified file is not there,then select it from the Dev-cpp\bin folder (or wherever you installed your compiler).

Page 4: Aditsu's Unofficial Dev-C++ FAQ

It might also help to set Tools - Compiler Options - Directories - Binaries correctly.Note: if you downloaded the IDE-only version (~2 MB) and you didn't install a gcc compiler(e.g. the mingw package), then you won't find the necessary programs; refer to solution 1.

This file includes at least one deprecated or antiquated header. Please considerusing one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examplesinclude substituting the <X> header for the <X.h> header for C++ includes, or<sstream> instead of the deprecated header <strstream.h>. To disable this warninguse -Wno-deprecated.First, this is a warning, not an error.Second, just do what the message says (isn't that painfully obvious?!?)Change iostream.h to iostream, strstream.h to sstream, etc.I know they told you it should be "iostream.h", I know it worked with every single compileryou used before (including gcc 2.95), but it doesn't exist in the C++ standard, so if youwant to write correctly in C++ then you must forget this "tradition" and learn to use the newheaders and the std namespace.Here is more information.

[Linker error] undefined reference to (something)Cause: You usually get a linker error (undefined reference) when you try to use a functionwhich was declared but not defined.By including the header file, you usualy get only the declaration of the function, but not itsdefinition (that is, function body).Solution: you can get the definition of a function through several ways:- defining the function yourself in the same or another cpp file (or adding to the project a cppfile which includes the definition)- linking an object file (a compiled source file) which includes that function definition- linking a library (which is a collection of object files) which includes that function definition;this is the most frequent caseNote: linking order is important, especially for libraries; if file A references symbolsdefined in file B, then link first A then B!Explanation: You might be confused because you used some functions successfullywithout doing any of the above; that happened because the compiler automatically linkssome standard libraries for you. If your function is defined in a non-standard library, then thecompiler won't link it unless you tell it to, even if it knows where to find it.By the way, if you "wipe clean" the linker configuration so that nothing will be linkedautomatically, then you'll notice the same kind of error with, for example, printf.Note: if you use g++ for linking, it will link some additional C++ libraries (compared to gcc)if they are needed. If you have a project with C++ sources and link it with gcc, you may getundefined references; see the answer about linking with g++ vs gcc.How to link: Generally, for all the functions available in the mingw header files, the mingwpackage provides libraries with the function definitions; not all available libraries areautomatically linked, because not all functions are standard C/C++; you just have to linkthem to your project when you need them.

Page 5: Aditsu's Unofficial Dev-C++ FAQ

The library files are called "libname.a" and are located in the Dev-Cpp\lib folder; the easiestway to link them is to add -lname (note: no "lib" and no ".a", and that's a small L not acapital i) to the linker parameters in your project, that is Project Options - Parameters - LinkerYou can also use the Add Library or Object button in that window, and that's ok for objectfiles, but for libraries you may run into problems when you move things to other folders or toanother computer.If you use external libraries (i.e. not included in mingw), then you should either put them inthe Dev-Cpp\lib folder, or add the folder which contains the libraries to the list of library dirs,in Project Options - Directories - Library Directories.You may still have problems if the libraries you link were compiled with an old version of gcc(and definitely if they were compiled with another compiler). Try to get libraries that matchyour compiler, or recompile them if you have the source code.Finding libraries: Which library do you need to link? Usually, the library name is similar tothe name of the header file that declares the functions, e.g. wingdi.h -> libgdi32.a,winsock2.h -> libws2_32.a; if you can't find it then just do a file search using WindowsExplorer (search for library files (lib*.a) containing the function name).Note: Microsoft managed to totally BOTCH the search functionality in Windows XP. Youmay want to use a file manager such as Total Commander, or see this article.

`clrscr' undeclared (first use this function)[Linker error] undefined reference to `clrscr'Why can't I use conio.h functions like clrscr, gotoxy etc?First you should note that conio.h is a Borland extension, NOT a standard header, soDev-C++ and MinGW are in no way required to support it. The MinGW included withDev-C++ 4.9.9.1 comes with a very reduced version of conio.h (no clrscr, gotoxy, etc); ifyou need more then you can use the native Windows console functions.I also provide and maintain an updated version of conio (and also winbgim) athttp://www14.brinkster.com/aditsu/console/; that may be what you are looking for.

How can I install Dev-C++ correctly?First, if you currently have Dev-C++ 4.9.x.x, you should uninstall it.Then install the latest version (see the top of the page) in a folder with no spaces in thepath. This is important, otherwise you risk getting various errors and inconsistencies.Why? The cause is uncertain: either the unix legacy of the programs in the compiler suiteor a Dev-C++ buglet in path handling. But it is certain: spaces in the path ask for trouble.Examples of good paths: C:\Dev-Cpp, D:\Dev-Cpp, C:\progs\devcpp, F:\aditsu\soft\devcpp4990Examples of bad paths: C:\Program Files\Dev-Cpp, C:\Dev Cpp, C:\Documents andSettings\aditsu\Desktop\Dev-cpp

How can I uninstall Dev-C++ cleanly?For Dev-C++ 4.0x or 4.9.9.2, just uninstall it from Control Panel - Add or Remove Programs.For Dev-C++ 4.9.x.x (before 4.9.9.2) you can try my automatic Dev-C++ maintenance tool,or follow these instructions very carefully:

Page 6: Aditsu's Unofficial Dev-C++ FAQ

First, run uninstall.exe from the Dev-cpp folder. Delete the Dev-Cpp folder (after backing upany files you want to keep). Then search and delete devcpp.* especially devcpp.cfg anddevcpp.ini - on windows 2000 or XP they are normally found in Documents andSettings\username\Local Settings\Application Data, which is a hidden folder. You mighthave to set up your Windows Explorer to display hidden files/folders, or select to searchhidden files/folders too. If you use the Windows XP file search thingie (which, in nice words,sucks ass), then you have to select to search in hidden folders too, or else it won't findthem.The general attitude should be "search, seek and destroy every trace", otherwise you mightget problems if you reinstall Dev-C++ afterwards.

The error messages appear truncatedNormally, gcc splits long error messages to several lines, for easy reading, but Dev-C++ willonly read the first line of each message.To force gcc to output messages on a single line, add -fmessage-length=0 in Tools -Compiler Options - Compiler.In any case, you can see the complete messages in the "Compile Log" tab.

Dev-C++ doesn't recompile my code although I made modificationsBy default, Dev-C++ only checks if the c or cpp files in the project were modified, and ifthey were, then it recompiles them. It doesn't check if a header file used by those sourcefiles was modified or not. If you want it to check this too, then clear the checkbox Tools -Compiler Options - Compiler - Use fast but imperfect dependency generation and be preparedto wait a bit longer for the subsequent compilations. Either way, you can always rebuildyour entire project by pressing Ctrl-F11.

Where is the resource editor?Dev-C++ doesn't have a visual resource editor. If you need to edit resource files (*.rc) thenyou can either do it by hand (in the text editor) or download and use a free resource editor.Some people recommended ResEd.I am currently (i.e. seldom, when I have time and mood) working on a resource editorproject. You can get the current version from here.Alternatively you can use a GUI library/toolkit. Apparently there is no library that satisfieseverybody, but the most popular ones are wxWidgets, GTK, FLTK and Fox. MFC and Qtcan not be used with MinGW as far as I know.New: I heard there is a QT for MinGW; I don't know any other details about it so you're onyour own.

Can I use Dev-C++ with other compilers?Dev-C++ was designed to work with gcc only. However, this doesn't really constrain you touse only one compiler, because gcc can have several flavours: mingw, cygwin, cross-compilers etc, each of them with different versions.If you want to set up Dev-C++ to use another compiler, you have to configure it in Tools -Compiler Options, all tabs. If you can't figure out what to do there, then you probably

Page 7: Aditsu's Unofficial Dev-C++ FAQ

shouldn't be doing it.However, you can not use non-gcc compilers such as Borland's bcc. I don't know why youwould want to do that, because they have no advantage over gcc (the ones who have arecommercial and come with their own IDE). Anyway, remember that Dev-C++ is not ageneral programmers editor, but an IDE for Windows-based gcc compilers.

Does Dev-C++ support workspaces with multiple projects? How do I import Visual Cworkspaces?Currently Dev-C++ does not support workspaces. You can just open one project at a timein each instance of the IDE. If you want to import Visual C workspaces, you have to importeach project (.dsp file) separately (File - Import). Note: that works only with VC 6.0, fornewer versions you have to convert the project files.If you *must* build several projects together, with dependencies and stuff, then your onlyoption is to write your custom makefile to do that... or use another IDE that supportsworkspaces.

Dev-C++ uses gcc instead of g++ for linkingThis happens when your project is a "C project" (you can select that when you create it) butit contains (or links to) C++ files. To change it to be a C++ project, close Dev-C++, edityour .dev file with a text editor and set IsCpp=1 in the [Project] section, then reopen theproject.

vUpdate doesn't work!Indeed, vUpdate has been discontinued since its author left the team. You should upgradeyour Dev-C++, the latest versions (see the top of this page) include WebUpdate, thereplacement for vUpdate.

I see <Err: xxxx> in various placesUpdate: should be fixed in 4.9.9.2.Most likely you upgraded Dev-C++ but you're still using old language files. You need to getthe updated language files; use WebUpdate for that. It's also possible that the updatedlanguage files are not available for your language - then you can switch to English or fix thelanguage files by yourself and tell somebody about that.

Code completion doesn't work well, crashes, kills my cat, etc.Code completion in Dev-C++ is quite broken and can't be fixed easily. It works in somecases, but often gets confused.To turn it on/off or configure it, go to Tools - Editor Options - Class browsing - Completion.

This IDE is too buggy, I want to use something elseI personally can get along quite well with Dev-C++. If you can't, or just want to try anotherIDE, take a look at Code::Blocks. You can also drop me a line to let me know if you love itor hate it :)

I can't debug, how do I debug?

Page 8: Aditsu's Unofficial Dev-C++ FAQ

First, make sure you are using a project (you can debug without a project, but it is moreconvenient to use a project, and besides, it's the only way I describe here *grin*).Then go to Project Options - Compiler - Linker and set Generate debugging information to"yes", and make sure you are not using any optimization options (they're not good fordebug mode). Also check the Parameters tab, make sure you don't have any optimizationoptions (like -O2 or -O3, but -O0 is ok because it means no optimization) or strip option(-s).After that, do a full rebuild (Ctrl-F11), then set breakpoint(s) where you want the debugger tostop (otherwise it will just run the program). To set a breakpoint on a line, just click on thegutter (the gray band on the left), or press Ctrl-F5.Now you are ready to launch the debugger, by pressing F8 or clicking the debug button. Ifeverything goes well, the program will start, and then stop at the first breakpoint. Then youcan step through the code, entering function calls, by pressing Shift-F7 or the "step into"button, or stepping over the function calls, by pressing F7 or the "next step" button. Youcan press Ctrl-F7 or the "continue" button to continue execution till the next breakpoint. Atany time, you can add or remove breakpoints.When the program stopped at a breakpoint and you are stepping through the code, you candisplay the values of various variables in your program by putting your mouse over them, oryou can display variables and expressions by pressing F4 or the "add watch" button andtyping the expression.For more information refer to the help included with Dev-C++.

Console I/O doesn't work while debuggingThis is a problem with gdb 5.1.1 on Windows 9x/ME. You can solve it by upgrading gdb toversion 5.2.1 or later. The full Dev-C++ 4.9.9.1 includes gdb 5.2.1.

The debugger doesn't stop at breakpoints in constructorsQuoting from this page about gdb 6.0:When gcc 3.x compiles a C++ constructor or C++ destructor, it generates 2 or 3 differentversions of the object code. These versions have unique mangled names (they have to, inorder for link ing to work ), but they have identical source code names, which leads to agreat deal of confusion. Specifically, if you set a breakpoint in a constructor or adestructor, gdb will put a breakpoint in one of the versions, but your program may executethe other version. This makes it impossible to set breakpoints reliably in constructors ordestructors.gcc 3.x generates these multiple object code functions in order to implement virtual baseclasses. gcc 2.x generated just one object code function with a hidden parameter, but gcc3.x conforms to a multi-vendor ABI for C++ which requires multiple object code functions.gdb 6.0 hopefully fixes this, you can try the snapshot build from the mingw site and tell meif it works.Update: I heard a report that gdb 6.0 didn't work [well] with Dev-C++, but I didn't confirm it.

When I debug the program, Dev-C++ keeps opening new windows with the sourcecode

Page 9: Aditsu's Unofficial Dev-C++ FAQ

This bug is solved in Dev-C++ 4.9.9.1; please upgrade.

`cout' undeclared (first use this function)Either you forgot to #include <iostream> or you didn't access cout correctly. You mightneed to update your knowledge of C++.The standard C++ library functions, classes and objects are declared ONLY in the stdnamespace. Therefore, you must use one of these 3 methods to access them:1. add using namespace std; after your #includes (this is recommended for small orsimple programs)2. add using std::ident; after your #includes, for each identifier you want to use3. use std::ident everywhere in your code (this is recommended for header files)

[Warning] no newline at end of fileUpdate: fixed in 4.9.9.2!This is a warning, not an error. C and C++ source files are required (by the standard) to endwith an empty line. Older versions of Dev-C++ automatically (and secretly) added it for you;4.9.9.1 doesn't do that anymore.So just open the file in question, go to the end and add a new and *empty* line (no spacesand no tabs).

`main' must return `int'Yes that's right, you have to write int main !No matter what your teacher, lecturer, parent, brother, neighbor, friend, xyz C/C++ manualor web site has told you, and no matter how many compilers accept it, "void main" alwayswas, is and will be wrong! main MUST return int , both in C and C++!Don't believe me? Then read what the creator of C++ has to say about it!The fact is: main can take any parameters, but must always return int. Usually you will useeither int main() (which is IDENTICAL to int main(void) ) or something like intmain(int argc, char**argv) for getting command-line parameters (char*argv[] alsoworks well). Note that, at least for gcc/g++, main is always a C function (even in C++programs) so you can't overload it.Also, in C you must return a value from main (an int). In C++ you can skip writing areturn instruction at the end of main , it defaults to return 0; , but if you have a returnthen you must return an int.Finally, do *NOT* call main recursively! It's generally very bad, and in C++ it's forbidden bythe standard. Most people who do that need to use a loop instead.

[Linker error] undefined reference to `mcount'If you need code profiling, add -pg to Project Options - Parameters - Linker.If you don't need code profiling, disable it in Project Options - Compiler - Code profiling.

[Linker error] undefined reference to `__gxx_personality_v0'This usually happens when you are linking a C++ project with gcc, but sometimes it is alsocaused by linking (with g++) object files which were compiled with different compiler

Page 10: Aditsu's Unofficial Dev-C++ FAQ

versions. In that case, the solution is to recompile the code (or get updated libraries if youdon't have the source).

Fatal: 'all-before' does not exist - don't know how to make itUpdate: should be fixed in 4.9.9.2.That happens when the wrong make.exe is invoked, usually the Borland one. It is easy tonotice if it leaves a copyright notice in your compile log.To solve it, you can try my automatic Dev-C++ maintenance tool; if it doesn't help (or youprefer doing it manually) then try these things:- take a look at the unable to run program file error and follow the (manual) instructions- add the bin folder of your Dev-C++ (or MinGW) installation to the PATH environmentvariable, before any Borland path that might be there- rename make.exe from the bin folder to mingw32-make.exe (if you already have it, justdelete the make.exe) and set it accordingly in Tools - Compiler Options - Programs

bits/c++config.h: No such file or directoryThis shows that you have an old or bad installation (probably from Dev-C++ 4.9.7.0). Youcan fix the problem by adding DevCppPath\include\C++\mingw32 to Tools - CompilerOptions - Directories - C++ Includes, where DevCppPath is the folder where you installedDev-C++, e.g. C:\Dev-Cpp.

Can't evaluate object members`this' is not an aggregateIt should work in Dev-C++ 4.9.9.1; if you still have problems, try watching*(classname*)this instead, and it will hopefully show you all the object members.

[Warning] unused parameter (something)This is a warning, you declared a parameter in a function, and never used it. You canremove it, or if you have to keep it then delete its name (keep the type only) but this worksonly in C++.

What is Dev-C++?This is not actually a frequently asked question, but rather a question to which a wronganswer is frequently assumed.Dev-C++ is NOT a compiler! It is an IDE (Integrated Development Environment), whichmainly means that it has a programming-oriented editor, a project manager, and visualinterfaces to various external programs.These programs are mingw builds of GNU tools, specifically: gcc and g++ for compiling andlinking, make for building projects, gdb for debugging, and others. So when a problemoccurs with one of these actions, it is usually either related to the respective mingw tool, orto the interface between Dev-C++ and it.

Can I make software with Dev-C++ and distribute or sell it without giving away thesources?

Page 11: Aditsu's Unofficial Dev-C++ FAQ

(Contributed by Mathias Bierschenk)First of all, the following answer is *solely* based on my opinions. I'm *not* a lawyer and theinformation I provide here may be outdated, misleading, or simply wrong. If you need legaladvice please consult a lawyer. That said, I appreciate any corrections or other kind offeedback.

As you might know, the Bloodshed Dev-C++ IDE is licensed under the terms of the GPL(GNU General Public License). When people read the GPL they often fear that theprograms generated with Dev-C++ will also have to be released under the GPL, thus makingit practically impossible to distribute them as shareware/commercial (non-free) software.This assumption is reasonable, but for the most part false.The GPL [1] basically says: If you modify a GPL program, or if you include parts of a GPLprogram into another one, then the resulting program must be released (if at all) under theGPL as well. That means, if you get the "Bloodshed Dev-C++" sources and improve themthen you may *not* distribute or sell the resulting super software development environmentwithout making the updated sources available freely.

But the GPL does *not* place any restrictions on just *using* a GPL program. Before weget into the details you should notice that the full Dev-C++ package is not a single program,but a collection of several tools, such as compiler, linker, libraries, header files, editor...Consider the work of the compiler. It takes a source file, let's say in C or C++. It"processes" this file in some ways and then it generates a certain output (an object file).While the compiler works we neither modify the compiler nor does the compiler put parts ofitself into the resulting object file. It just *translates* our C/C++ sources into machinelanguage, without adding anything. [2].The same for the editor. If you type in some source code you get a C or CPP file but thatfile won't include any part of the editor itself.

When you think about what goes on internally when you develop software you will noticethat there is only one step when some code of a development tool is included into yourprogram: the libraries while linking. Notice that no part of the linker will be included into yourprogram, but the libraries themselves.So under which license terms are the Dev-C++ libraries released?Dev-C++ by default uses the MinGW libraries. Fortunately, one of the goals of the MinGWproject was to "avoid the encumbrances of the GPL". Several parts of the MinGW librariesare licensed under different terms, but almost all of them don't place any restrictions uponyour code if you just *use* them (the only exception is if you use profiling code, but youwon't sell software with such code anyway). If you modify the libraries, however, there*might* be restrictions, but I leave this for you to find out. [3]

Summary:- If you just *use* Bloodshed Dev-C++ (instead of modifying it) the whole legal issue isabout the libraries.- If you use the default MinGW libraries then there aren't any restrictions (except for profiling

Page 12: Aditsu's Unofficial Dev-C++ FAQ

code).- If, for whatever reason, you use another set of libraries instead of the MinGW ones or ifyou use any additional libraries or source code, then you have to read the license termsthat apply to them. In particular, GPL libraries impose the GPL on the programs that link tothem.

References:[1] The GPL itself (also part of the Bloodshed Dev-C++ package)[2] Some frequently asked questions about the GPL, answered by the Free SoftwareFoundation (the inventors of the GPL). Please notice in particular the following:- Can I use GPL Tools for non-free programs?- Can the GPL apply to the output of a program?[3] MinGW license information to get the details.

Why is the compiled executable file so large?People usually ask this question when they compile a simple program which usesiostreams. The first thing you can do is to add -s to Project Options - Parameters - Linker,but the result may be still too large for your taste. In this case, either try to live with it (itactually doesn't matter so much!), or avoid iostreams (use cstdio), or use another compiler.Also note that there are some exe compressors on the net, e.g. upx.The reason why iostream increases the size so much is that the linker links entire objectfiles (from inside of libraries) if they contain at least one necessary reference, and the libraryfor iostream is not well separated into small object files. Also, the linker should be able tolink only certain sections of the object files (see "--gc-sections"), but this particular featuredoesn't work yet on the mingw target (and that affects all libraries and object files).

How can I do graphics? Where is graphics.h?First you should note that graphics.h is a Borland extension, NOT a standard header, soDev-C++ and MinGW are in no way required to support it.There are many ways to do graphics in Windows: API functions (GDI), DirectX, OpenGL,third party libraries etc.If you need to do graphics.h-style graphics, you can use the winbgim library which tries tokeep the compatibility with the Borland functions; you can find it on the web, or in theCLGDI devpak.I also provide and maintain an updated version of winbgim (and also conio) athttp://www14.brinkster.com/aditsu/console/; that will probably solve some problems,including some conflicts between conio and winbgim.

How can I write inline asm (assembly) code?The gcc syntax for asm is different from other compilers; an asm instruction looks like this:asm("statements" : outputs : inputs : clobbers);

where the colon parts are optional.The default syntax for the actual statements is AT&T, which is quite different from thewell-known Intel syntax. However, you can switch to the Intel syntax by adding

Page 13: Aditsu's Unofficial Dev-C++ FAQ

-masm=intel to the compiler options.Here are some documentation pages: the official gcc extended asm docs, a gcc inline asmtutorial and a guide to inline assembly for gcc/djgpp. They all use AT&T syntax.Important: you can not normally use interrupts and ports as you did in DOS; especially theNT-based systems (including Windows XP) deny direct access to hardware and require youto use some API functions instead.

My resource file doesn't workThere are several kinds of problems related to resource files. Take the following steps:1. make sure you added the resource file to the project (together with your c/cpp files); ifyou're not using a project then you have to create one2. go to Project Options - Files, click your resource file and select Include in compilation3. delete the projectname_private.* files, they will be automatically generated again4. do a full rebuildIf you still have errors after these steps, then the problem must be inside your resource fileand/or in your code. If you have an error in the "Resources" tab then it's clearly the resourcefile. If the file was written for another compiler (usually Visual C), then take these steps:1. remove everything that has "afx" in it2. add #include <windows.h> at the beginning of the file3. add #define IDC_STATIC -1 after that4. make sure that you #include any header that has #defines used in the resource fileIf it still doesn't work, then you may need to ask in the forum.

I can't find the answer here, what can I do?First take a look at the other FAQs available for Dev-C++:- Official Dev-C++ 5 FAQ- Bloodshed Software Forum FAQ- Official Dev-C++ 4 FAQ (this one is old)If you have a general C++ question, check the C++ FAQ lite.If you still can't find the answer, then follow these steps:1. use Google2. go to the Bloodshed Software Forum and first read the forum FAQ (also mentionedabove) which is kindly maintained by Wayne.3. search the forum (todo: I can't figure out how)4. if you tried everything and haven't got an answer, then ask your question in the forum

How to ask questions on the forum?Any moron can blurt out a question, but you should consider some things if you plan to geta satisfactory answer quickly. First make sure you followed the previous steps. Then take alook at these guidelines if you haven't seen them before. Some of them are also mentionedin the forum FAQ. The main points should be:- make it short but include all the necessary information (e.g. OS version, Dev-C++ version,compile log (right-click to copy), short source code example); people don't come to theforum to read novels or to play 20-questions and read your mind

Page 14: Aditsu's Unofficial Dev-C++ FAQ

- use a meaningful subject- show that you tried other means to find the answer- don't rush to claim that you found a bug or that something is wrong; it's safest to assumeyou made a mistake- try to use correct logic, grammar and spelling (non-native speakers are partly excused butshould still try their best), be polite, don't TYPE IN ALL CAPS and don't try to show what al33t h4X0r you are- don't ask people to do your homework, and don't label your problem as urgent: it willprobably have opposite effects- don't ask to get a reply by e-mail- if you solved the problem then describe the solution briefly, it can help others a lot

And as a final note: it would be very nice if you mention your name at the end of themessage (can be a nickname). People want to know who they're talking to.

In case you missed it, the address of the forum is http://sourceforge.net/forum/forum.php?forum_id=48211 (works with https too)

Contact info and permitted use:

If you want to add something to this FAQ list, or if you found an error, or just have acomment for me, then please use the comment form at the bottom of the page, or email meat [email protected], but do NOT email me for asking questions. For that, use the stepsdescribed above.You are welcome to link to this FAQ (http://www.aditsu.net/Dev-cpp_FAQ) from any page,and you can also copy it to your site if you don't modify the contents (you can still dowhatever you want with the CSS styles). Especially you must keep the above link to theoriginal page.Alternately, you can modify the contents but then you should remove any reference to me(except mentioning that you used parts of my FAQ).

Created on 12 Apr 2009, last updated on 07 Jun 2009

Comments:

borkus

Too bad 27 Sep 2010It's too bad to see so many say that Dev-C++ is dead and hasn't beenupdated in a long time. I came across this IDE some years ago and lovedthe streamlined feeling the interface had. I was loathed to turn to VS buthad to for work reasons. Upon getting back into programming as a hobbyagain I was saddened to see that this product will likely fall to the sandsof time. Very much a pity and hopefully I am wrongReply

Add a comment