Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Cannot link to source files in project sub-folders?: (7 Items)
   
Cannot link to source files in project sub-folders?  
Hello,

I am just getting started with the QNX momentics IDE. I started creating a simple project but I am running into the 
problem where the QNX Momentics IDE cannot seem to link against source files in sub folders of my project.

I have created a very small simple project, it is a QNX C/C++ project. It has the following structure: In the root 
folder: MyTest.cc, and a source folder called asdf. In the /asdf/ folder: asdf.h and asdf.cpp exist.

MyTest.cc is as follows: 

#include <cstdlib>
#include <iostream>

#include "asdf/asdf.h"

int main()
{
    doStuff();
}

asdf.cpp is as follows:

/*
 * asdf.cpp
 */

#include "asdf.h"
#include <stdio.h>

void doStuff()
{
    printf ("hello, world.\n");
}

and asdf.h:

/*
 * asdf.h
 */

#ifndef ASDF_H_
#define ASDF_H_

void doStuff();

#endif /* ASDF_H_ */



As you can see, this is a very simple example. The project compiles against the header correctly then gives me the 
linker error: "undefined reference to doStuff"... I am new to QNX and a rather novice programmer, but this still strikes

 me as something the IDE should be able to manage? What am I missing? 

I can simply compile this example from command line with 

g++     MyTest.cpp asdf/asdf.cpp   -o MyTest

and it works just fine, so I am very confused why I cannot get the IDE to do the same.. Any advice?
Re: Cannot link to source files in project sub-folders?  
How did you create "source folder"? Looks like it does not think it is a 
source folder

On 14-05-13 01:27 PM, Ariosto Ferro wrote:
> Hello,
>
> I am just getting started with the QNX momentics IDE. I started creating a simple project but I am running into the
> problem where the QNX Momentics IDE cannot seem to link against source files in sub folders of my project.
>
> I have created a very small simple project, it is a QNX C/C++ project. It has the following structure: In the root
> folder: MyTest.cc, and a source folder called asdf. In the /asdf/ folder: asdf.h and asdf.cpp exist.
>
> MyTest.cc is as follows:
>
> #include <cstdlib>
> #include <iostream>
>
> #include "asdf/asdf.h"
>
> int main()
> {
>      doStuff();
> }
>
> asdf.cpp is as follows:
>
> /*
>   * asdf.cpp
>   */
>
> #include "asdf.h"
> #include <stdio.h>
>
> void doStuff()
> {
>      printf ("hello, world.\n");
> }
>
> and asdf.h:
>
> /*
>   * asdf.h
>   */
>
> #ifndef ASDF_H_
> #define ASDF_H_
>
> void doStuff();
>
> #endif /* ASDF_H_ */
>
>
>
> As you can see, this is a very simple example. The project compiles against the header correctly then gives me the
> linker error: "undefined reference to doStuff"... I am new to QNX and a rather novice programmer, but this still 
strikes
>   me as something the IDE should be able to manage? What am I missing?
>
> I can simply compile this example from command line with
>
> g++     MyTest.cpp asdf/asdf.cpp   -o MyTest
>
> and it works just fine, so I am very confused why I cannot get the IDE to do the same.. Any advice?
>
>
>
> _______________________________________________
>
> QNX Momentics Getting Started
> http://community.qnx.com/sf/go/post110305
> To cancel your subscription to this discussion, please e-mail momenticsgs-community-unsubscribe@community.qnx.com

Re: Cannot link to source files in project sub-folders?  
Ok it does not smart enough to add them automatically. Go to project properties, select QNX C/C++ Project
Select Compiler tab, in drop down select Extra source paths, click Project... - add your folder
Attachment: Image Screenshot from 2014-05-13 15:03:44.png 55.06 KB
Re: Cannot link to source files in project sub-folders?  
I right click on the project in the project explorer window and select "new source folder"
Re: Cannot link to source files in project sub-folders?  
Okay, cool I can do that, except I am working on a project that will have close to on hundred folders each with sub 
folders? Will I have to add every folder manually with that method?
Re: Cannot link to source files in project sub-folders?  
You can edit makefile manually. Do one folder and see what it generates. 
Just add stuff to the same make variable
(will be in common.mk)

On 14-05-13 03:07 PM, Ariosto Ferro wrote:
> Okay, cool I can do that, except I am working on a project that will have close to on hundred folders each with sub 
folders? Will I have to add every folder manually with that method?
>
>
>
> _______________________________________________
>
> QNX Momentics Getting Started
> http://community.qnx.com/sf/go/post110309
> To cancel your subscription to this discussion, please e-mail momenticsgs-community-unsubscribe@community.qnx.com

Re: Cannot link to source files in project sub-folders?  
Awesome. That is exactly what I needed. Thanks