In this walkthrough, you create a basic, 'Hello, World'-style C program by using a text editor, and then compile it on the command line. If you'd like to try the Visual Studio IDE instead of using the command line, see Walkthrough: Working with Projects and Solutions (C) or Using the Visual Studio IDE for C Desktop Development. In DevCpp go FILE then NEW then Project, select Windows Application, give it a name (eg. Ball) click OK, the make a directory somewhere and save. DevCpp comes up with a template, delete that and cut and paste this code into the editor page. Software download link:www.bloodshed.net/dev/devcpp.htmlpls subscrided and like. Creating a project in DevCpp. To create your app, first, you'll create a new project and solution. In Visual Studio, open the Filemenu and choose New Projectto open the Create a new Projectdialog. Select the Console Apptemplate, and then choose Next. In the Configure your new projectdialog, enter HelloWorldin the Project nameedit box.
What is Dev-C++?
Dev-C++, developed by Bloodshed Software, is a fully featured graphical IDE (Integrated Development Environment), which is able to create Windows or console-based C/C++ programs using the MinGW compiler system. MinGW (Minimalist GNU* for Windows) uses GCC (the GNU g++ compiler collection), which is essentially the same compiler system that is in Cygwin (the unix environment program for Windows) and most versions of Linux. There are, however, differences between Cygwin and MinGW; link to Differences between Cygwin and MinGW for more information.
Bloodshed!?
I'll be the first to say that the name Bloodshed won't give you warm and fuzzies, but I think it's best if the creator of Bloodshed explains:
There's also a reason why I keep the Bloodshed name. I don't want people to think Bloodshed is a company, because it isn't. I'm just doing this to help people.
Here is a good remark on the Bloodshed name I received from JohnS:
I assumed that this was a reference to the time and effort it requires of you to make these nice software programs, a la 'Blood, Sweat and Tears'.
Peace and freedom,
Colin Laplace
Getting Dev-C++
The author has released Dev-C++ as free software (under GPL) but also offers a CD for purchase which can contain all Bloodshed software (it's customizable), including Dev-C++ with all updates/patches.
Link to Bloodshed Dev-C++ for a list of Dev-C++ download sites.
You should let the installer put Dev-C++ in the default directory of C:Dev-Cpp, as it will make it easier to later install add-ons or upgrades.
Using Dev-C++
This section is probably why you are here.
All programming done for CSCI-2025 will require separate compilation projects (i.e. class header file(s), class implementation file(s) and a main/application/client/driver file). This process is relatively easy as long as you know what Dev-C++ requires to do this. In this page you will be given instructions using the Project menu choice. In another handout you will be given instructions on how to manually compile, link and execute C++ files at the command prompt of a command window. See here.
Step 1: Configure Dev-C++.
We need to modify one of the default settings to allow you to use the debugger with your programs.
- Go to the 'Tools' menu and select 'Compiler Options'.
- In the 'Settings' tab, click on 'Linker' in the left panel, and change 'Generate debugging information' to 'Yes':
- Click 'OK'.

Step 2: Create a new project.
A 'project' can be considered as a container that is used to store all the elements that are required to compile a program.
- Go to the 'File' menu and select 'New', 'Project...'.
- Choose 'Empty Project' and make sure 'C++ project' is selected.
Here you will also give your project a name. You can give your project any valid filename, but keep in mind that the name of your project will also be the name of your final executable. - Once you have entered a name for your project, click 'OK'.
- Dev-C++ will now ask you where to save your project.
Step 3: Create/add source file(s).
You can add empty source files one of two ways:
- Go to the 'File' menu and select 'New Source File' (or just press CTRL+N) OR
- Go to the 'Project' menu and select 'New File'.
Note that Dev-C++ will not ask for a filename for any new source file until you attempt to:- Compile
- Save the project
- Save the source file
- Exit Dev-C++
- Go to the 'Project' menu and select 'Add to Project' OR
- Right-click on the project name in the left-hand panel and select 'Add to Project'.
| EXAMPLE: Multiple source files In this example, more than 3 files are required to compile the program; The 'driver.cpp' file references 'Deque.h' (which requires 'Deque.cpp') and 'Deque.cpp' references 'Queue.h' (which requires 'Queue.cpp'). |
Step 4: Compile.
Once you have entered all of your source code, you are ready to compile.
- Go to the 'Execute' menu and select 'Compile' (or just press CTRL+F9).
It is likely that you will get some kind of compiler or linker error the first time you attempt to compile a project. Syntax errors will be displayed in the 'Compiler' tab at the bottom of the screen. You can double-click on any error to take you to the place in the source code where it occurred. The 'Linker' tab will flash if there are any linker errors. Linker errors are generally the result of syntax errors not allowing one of the files to compile.
Close'. Step 5: Execute.
You can now run your program.
- Go to the 'Execute' menu, choose 'Run'.
Disappearing windows
If you execute your program (with or without parameters), you may notice something peculiar; a console window will pop up, flash some text and disappear. The problem is that, if directly executed, console program windows close after the program exits. You can solve this problem one of two ways:
- Method 1 - Adding one library call:
On the line before the main's return enter:system('Pause');
- Method 2 - Scaffolding:
Add the following code before any return statement in main() or any exit() or abort() statement (in any function):/* Scaffolding code for testing purposes */
This will give you a chance to view any output before the program terminates and the window closes.
cin.ignore(256, 'n');
cout << 'Press ENTER to continue...'<< endl;
cin.get();
/* End Scaffolding */ - Method 3 - Command-prompt:
Alternatively, instead of using Dev-C++ to invoke your program, you can just open an MS-DOS Prompt, go to the directory where your program was compiled (i.e. where you saved the project) and enter the program name (along with any parameters). The command-prompt window will not close when the program terminates.
For what it's worth, I use the command-line method.
Step 6: Debug.
When things aren't happening the way you planned, a source-level debugger can be a great tool in determining what really is going on. Dev-C++'s basic debugger functions are controlled via the 'Debug' tab at the bottom of the screen; more advanced functions are available in the 'Debug' menu.
Using the debugger:
The various features of the debugger are pretty obvious. Click the 'Run to cursor' icon to run your program and pause at the current source code cursor location; Click 'Next Step' to step through the code; Click 'Add Watch' to monitor variables.
Setting breakpoints is as easy as clicking in the black space next to the line in the source code.
See the Dev-C++ help topic 'Debugging Your Program' for more information.
Dev-C++ User F.A.Q.
Why do I keep getting errors about 'cout', 'cin', and 'endl' being undeclared?
It has to do with namespaces. You need to add the following line after the includes of your implementation (.cpp) files:
How do I use the C++ string class?
Again, it probably has to do with namespaces. First of all, make sure you '#include <string>' (not string.h). Next, make sure you add 'using namespace std;' after your includes.
Example:
That's it for now.I am not a Dev-C++ expert by any means (in fact, I do not teach C++ nor use it on a regular basis), but if you have any questions, feel free to email me at jaime@cs.uno.edu
How To Start A New Project In Dev C Renew Jungle Notes
Happy coding!
You can add C and C++ code to your Android project by placing the code into a cpp directory in your project module. When you build your project, this code is compiled into a native library that Gradle can package with your APK. Your Java or Kotlin code can then call functions in your native library through the Java Native Interface (JNI). To learn more about using the JNI framework, read JNI tips for Android.
Android Studio supports CMake, which is good for cross-platform projects, andndk-build, which can be faster than CMake but onlysupports Android. Using both CMake and ndk-build in the same module is notcurrently supported.
If you want to import an existing ndk-build library into your Android Studioproject, learn how tolink Gradle to your native library project.
This page shows you how to set up Android Studio with thenecessary build tools, create a new project with C/C++support, and add new C/C++ files to your project.
If instead you want to add native code to an existing project, you need to follow these steps:
- Create new native source files and add them to your Android Studio project.
- You can skip this step if you already have native code or want to import a prebuilt native library.
- Configure CMake to build your native source code into a library. You also require this build script if you are importing and linking against prebuilt or platform libraries.
- If you have an existing native library that already has a
CMakeLists.txtbuild script, or uses ndk-build and includes anAndroid.mkbuild script, you can skip this step.
- If you have an existing native library that already has a
- Configure Gradle by providing a path to your CMake or ndk-build script file. Gradle uses the build script to import source code into your Android Studio project and package your native library (the SO file) into the APK.
Once you configure your project, you can access your native functions from Java or Kotlin code using the JNI framework. To build and run your app, simply click Run .
Note: If your existing project uses the deprecated ndkCompile tool, you should migrate to using either CMake or ndk-build. To learn more, go to the section about how to Migrate from ndkCompile.
Attention experimental Gradle users: Consider migrating to plugin version 2.2.0 or higher, and using CMake or ndk-build to build your native libraries if any of the following apply to you: Your native project already uses CMake or ndk-build; you would rather use a stable version of the Gradle build system; or you want support for add-on tools, such as CCache. Otherwise, you can continue to use the experimental version of Gradle and the Android plugin.
Download the NDK and build tools
To compile and debug native code for your app, you need the following components:
- The Android Native Development Kit (NDK): a toolset that allows you to use C and C++ code with Android, and provides platform libraries that allow you to manage native activities and access physical device components, such as sensors and touch input.
- CMake: an external build tool that works alongside Gradle to build your native library. You do not need this component if you only plan to use ndk-build.
- LLDB: the debugger Android Studio uses to debug native code.
For information on installing these components, see Install and configure the NDK, CMake, and LLDB.
Create a new project with C/C++ support
Creating a new project with support for native code is similar to creating any other Android Studio project, but there is an additional step:
- In the Choose your project section of the wizard, select the Native C++ project type.
- Click Next.
- Complete all other fields in the next section of the wizard.
- Click Next.
- In the Customize C++ Support section of the wizard, you can customize your project with the C++ Standard field. Use the drop-down list to select which standardization of C++ you want to use. Selecting Toolchain Default uses the default CMake setting.
- Click Finish.
After Android Studio finishes creating your new project, open the Project pane from the left side of the IDE and select the Android view. As shown in figure 2, Android Studio adds the cpp group:
Figure 2. Android view groups for your native sources and external build scripts.
Note: This view does not reflect the actual file hierarchy on disk, but groups similar files to simplify navigating your project.
The cpp group is where you can find all the native source files, headers, build scripts for CMake or ndk-build, and prebuilt libraries that are a part of your project. For new projects, Android Studio creates a sample C++ source file, native-lib.cpp, and places it in the src/main/cpp/ directory of your app module. This sample code provides a simple C++ function, stringFromJNI(), that returns the string 'Hello from C++'. You can learn how to add additional source files to your project in the section about how to Create new native source files.
Similar to how build.gradle files tell Gradle how to build your app, CMake and ndk-build require a build script to know how to build your native library. For new projects, Android Studio creates a CMake build script, CMakeLists.txt, and places it in your module’s root directory. To learn more about the contents of this build script, read Configure CMake.
Build and run the sample app
When you click Run , Android Studio builds and launches an app that displays the text 'Hello from C++' on your Android device or emulator. The following overview describes the events that occur in order to build and run the sample app:
- Gradle calls upon your external build script,
CMakeLists.txt. - CMake follows commands in the build script to compile a C++ source file,
native-lib.cpp, into a shared object library and names itlibnative-lib.so, which Gradle then packages into the APK. - During runtime, the app's
MainActivityloads the native library usingSystem.loadLibrary(). The library’s native function,stringFromJNI(), is now available to the app. MainActivity.onCreate()callsstringFromJNI(), which returns 'Hello from C++', and uses it to update theTextView.
Note:Instant Run is not compatible with components of your project written in native code.
If you want to verify that Gradle packages the native library in the APK, you can use the APK Analyzer:
- Select Build > Build Bundles(s) / APK(s) > Build APK(s)
- Select Build > Analyze APK.
- Select the APK from the
app/build/outputs/apk/directory and click OK. - As shown in figure 3, you can see
libnative-lib.soin the APK Analyzer window underlib/<ABI>/.Figure 3. Locating a native library using the APK Analyzer.
Tip: If you want to experiment with other Android apps that use native code, click File > New > Import Sample and select a sample project from the Ndk list.
Create new C/C++ source files
To add new C/C++ source files to an existing project, proceed as follows:
How To Start A New Project In Dev C Renew Jungle Key
- If you don't already have a
cpp/directory in the main source set of your app, create one as follows: - Open the Project pane from the left side of the IDE and select the Project view from the drop-down menu.
- Navigate to your-module > src, right-click on the main directory, and select New > Directory.
- Enter
cppas the directory name and click OK. - Right-click on the
cpp/directory and select New > C/C++ Source File. - Enter a name for your source file, such as
native-lib. - From the Type drop-down menu, select the file extension for your source file, such as
.cpp.- You can add other file types to the drop-down menu, such as
.cxxor.hxx, by clicking Edit File Types . In the C/C++ dialog box that pops up, select another file extension from the Source Extension and Header Extension drop-down menus and click OK.
- You can add other file types to the drop-down menu, such as
- If you also want to create a header file, check the Create an associated header checkbox.
- Click OK.
After you add new C/C++ files to you project, you still need toconfigure CMake to include them inyour native library.

Additional resources
To learn more about supporting C/C++ code in your app, try the followingresource.
How To Start A New Project In Dev C Renew Jungle Pam Hardy
Codelabs

How To Start A New Project In Dev C Renew Jungle Full
- Create Hello-CMake with Android Studio,a codelab that shows you how to use the Android Studio CMake template to startAndroid NDK project development
