In this tutorial, you'll create a simple Makefile
project.
You use the New Project wizard whenever you create a new project in the IDE. Follow these steps to create a simple "Hello world" project:
-
To open the New Project wizard, from the workbench main menu, select
-
Name your project (e.g. MyFirstProject).
-
In the Project type list, expand Makefile Project and
select Empty Project.
-
Select the QNX toolchain to build and execute on QNX Neutrino.
A toolchain represents the specific tools (such as a compiler, linker, and assembler) used
to build your project. Additional tools, such as a debugger, can also be associated with a
toolchain. Depending on the compilers installed on your system, there might be several toolchains
available to select from.
-
Click Next, then Finish.
The IDE creates your new project in your workspace. Your new
project shows in the Project Explorer view. If a message box prompts you to change perspectives,
click Yes.
If you don't see your project, click on the Project Explorer tab.
Next, you'll create a Makefile for your project.
-
In the Project Explorer view, highlight your project.
-
Click the New C/C++ Source File button on the toolbar:
-
Name your file Makefile, make sure the Template is set to
<none>,
then click Finish.
-
Double click on your new file to open it in the editor and write what you need in the file.
Here's a sample Makefile you can use:
CC:=qcc
all: hello
hello: hello.c
clean:
rm -f hello.o hello
Note: Use Tab characters to indent commands inside of Makefile rules,
not spaces.
-
When you're finished editing, save your file (right-click, then select Save,
or click the Save button in the tool bar).
-
Finally, you'll create your hello world C (or C++) source file. Again, click the New C/C++ Source File
button on the toolbar, select Source File and the
Default C source template, and name your file hello.c.
-
Open the file and write your "Hello world!" program.
Your hello.c file might look something like this when you're done:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello, world!\n");
return EXIT_SUCCESS;
}
Congratulations! You've just created your first Make C/C++ project in the IDE.
For instructions about building your program, see the section Building projects in the
Developing C/C++ Programs chapter.
Note: In order to run your program, you must first set up a
QNX Neutrino target
system. For details, see the
"Preparing Your Target" chapter.