Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Simple Include

This might be an obvious question but I've never written C/C++ untill recently.


In my 'src' folder I have a file called recordvideo.c


I want to include that in the main cpp file I had assumed I would do something like ...




Can anyone tell me how to properly include the c file? Also when you use #include what is the default path, e.g. in what folder is it looking for recordvideo.c?

co-founder of Diaree | BB Dev for PictureThis
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Simple Include

You don't include the source (c/cpp) files. They are compiled into the app binary. Header files (h/hpp) are the only ones that need to be included.
Posts: 54
Registered: ‎06-26-2012
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Simple Include

Thank you for the question.
You don't use the "#include" directive for .c files visibility, instead you use it to expose C/C++ types, classes, macros,...
i.e. your declarations located in your .h files to other .c/c++ files.
If you want your objects or global variables from your C/C+ files to be accessed by other C/C++ files, you can simply use the "extern" keywork (there are other ways to do that but this is the simplest way)

Please check our helloword application or the very basic apps for how to set your include path.


Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: Simple Include

In addition...


When the include statement is:


#include <bb/cascades/QmlDocument>

 The compiler will look through the folders contained in the Include Path.. This is located in QNX Momentics IDE at:

Project -> Properties -> C/C++ General -> Paths and Symbols -> Includes tab on the right... The compiler will look through the folders contained there in the order they are in from top to bottom.


When the include statement is:


#include "Box2D/Box2D.h"


The compiler will look for the file relative to the current file that the include statement is in.  That is, in the same folder that the current file is in... 


.../workspace/NDK/myApp.cpp <--- include statement "" it will look in .../workspace/NDK/ ...