Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Momentics and "QNX C/C++ Project" with multiple executables or libraries: (9 Items)
   
Momentics and "QNX C/C++ Project" with multiple executables or libraries  
Hi,

I have created QNX C/C++ Project in momentics IDE. It generates one executable,but if i'm trying to add another file 
with main() into the project it ends with error.
Is it somehow posible to generate more executables or libraries from one QNX project?
I know, it can appear little wierd, but there is more reasons why one can need it (i.e. make test binaries which are 
fixed to projet - I don't want to create separate project only for tests)
I know I can write my own makefile which will do that, but I dont know how to do that in QNX type of project. Is it even
 posible?
Re: Momentics and "QNX C/C++ Project" with multiple executables or libraries  
> Hi,
> 
> I have created QNX C/C++ Project in momentics IDE. It generates one executable
> ,but if i'm trying to add another file with main() into the project it ends 
> with error.
> Is it somehow posible to generate more executables or libraries from one QNX 
> project?
> I know, it can appear little wierd, but there is more reasons why one can need
>  it (i.e. make test binaries which are fixed to projet - I don't want to 
> create separate project only for tests)
> I know I can write my own makefile which will do that, but I dont know how to 
> do that in QNX type of project. Is it even posible?


http://www.qnx.com/developers/docs/6.4.1/neutrino/prog/make_convent.html

Edit common.mk and try with:

EXTRA_OBJS
    A space-separated list of object files to be added to the link/archive step even though they don't have 
corresponding source files (or have been excluded by EXCLUDE_OBJS). Default is none. 

Does it work ?

Have seen similar thing recently :-)
-Jeevan

Re: Momentics and "QNX C/C++ Project" with multiple executables or libraries  
Little bit late, but ... thank you :)
Re: Momentics and "QNX C/C++ Project" with multiple executables or libraries  
Same problem here.
In my project I have multiple test files that have main() in them. They compile to object files but I get linking error 
multiple definition of `main'.

As mentioned in this post I have added dependency as "EXTRA_OBJS:=dependency1.o dependency2.o" to my common.mk file but 
still I'm getting errors.

I appreciate your help. 
Re: Momentics and "QNX C/C++ Project" with multiple executables or libraries  
You cannot have multiple main functions. How does linker suppose to choose the right one?
Re: Momentics and "QNX C/C++ Project" with multiple executables or libraries  
Elena, Thanks for the reply. 
I have one main function in one file. In my project I have multiple c files each has only one main(). I can write a make
 file to build executable for each file but how can do the same in QNX IDE.

Lubos post explains very clearly the same thing.
Re: Momentics and "QNX C/C++ Project" with multiple executables or libraries  
IDE project builds one executable by default. You have to create custom makefile to build multiple executables.
It is easier if you create one project per executable
Re: Momentics and "QNX C/C++ Project" with multiple executables or libraries  
From previous post I understand that by adding EXTRA_OBJS to common.mk I can make multiple executable in a project. 
I have added EXTRA_OBJS = object1.o object2.o to common.mk but it didn't work

Can you please give me an example how I can accomplish this.
Re: Momentics and "QNX C/C++ Project" with multiple executables or libraries  
No extra obj just add extra object files to the same executable. You have to read docs about recursive makefiles to see 
how to do it. It is very non-trivial. It is probably easier if you just write a standard makefile in this case.