Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Include header from a linked folder
Include header from a linked folder [message #1712197] Wed, 21 October 2015 21:02 Go to next message
Marcus Santo is currently offline Marcus SantoFriend
Messages: 8
Registered: October 2014
Junior Member
Hi,
Why files in linked folder cannot be included?

I have a project, B, whos files are located in the git directory and another A project in the workspace. In the project A, I create a new linked folder to the project B. In A, I have a main.cpp file where I include a file from B
#include "B/file.ext"


I also tried to linked folder as source folder and checked the project B in the Project References menu of the project A.

EDIT: I also tried to include a project from the same workspace but also doing so doesn't work.
  • Attachment: Cattura.PNG
    (Size: 16.23KB, Downloaded 385 times)

[Updated on: Wed, 21 October 2015 21:14]

Report message to a moderator

Re: Include header from a linked folder [message #1712268 is a reply to message #1712197] Thu, 22 October 2015 14:07 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The makefile is run in your workspace A but A itself doesn't have B so any reference to B will be unresolved. You will need more path information before using B that will find what you are looking for relative to wherever A is physically located. So, it either has to be in the include itself or a path to B has to be given to the compiler (GCC?) often with -I<path>. You don't say who is generating the make file or what you are using to compile/link. Remember, the compiler doesn't know anything about Eclipse. How you tell it where those files are depends on what you are doing and who is generating the make files, etc.

In fact it looks like what you have wouldn't work even if you had complete path information to B as the .hpp files seem to be in B/src (or is it A/src? -- not sure which is A and B in your image).
Re: Include header from a linked folder [message #1712270 is a reply to message #1712268] Thu, 22 October 2015 14:37 Go to previous messageGo to next message
Marcus Santo is currently offline Marcus SantoFriend
Messages: 8
Registered: October 2014
Junior Member
I'm using CDT Internal Builder.
In the project A (test) I created a linked folder to project B (tree/src).
Yes, I knew I can include it in the include path but imagine I had many related projects that I want to link each other. Using include path would quickly become unmanageable.

Thank you for the answer.
Re: Include header from a linked folder [message #1712274 is a reply to message #1712270] Thu, 22 October 2015 14:59 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Think about the difficulty in automating this. I've seen many different placement of header files over the years. In the source directory or in folders named inc, include, hdr, header. Not often, but I've seen combinations of them used concurrently. In your image it looks like you have a directory named "tree.hpp". Does it also contain headers? Asking CDT to figure out which directories you intend to use for your headers is asking a lot.

What you could do perhaps is have a directory somewhere that contains links to your projects so you only need to add a single link to each project. Or, you could separate out the header folders as separate projects as suggested here: http://www.eclipse.org/forums/index.php/mv/msg/68594/215191/#msg_215191

Re: Include header from a linked folder [message #1745103 is a reply to message #1712274] Wed, 05 October 2016 08:38 Go to previous messageGo to next message
Lloyd Elliott is currently offline Lloyd ElliottFriend
Messages: 1
Registered: October 2016
Junior Member
So, what's the best practice for solving this? TBH I'm sort of surprised I can't #include "src/test.hpp" given that "src" is a subfolders (albiet linked) of the directory in which my translation unit resides. If I were specifying eclipse, I'd make linked subfolders turn into soft links at compile time, that strikes me as the least surprising behaviour.
Re: Include header from a linked folder [message #1745172 is a reply to message #1745103] Thu, 06 October 2016 00:06 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
First, you should understand that there is no such thing as an objective best. Everything depends on requirements.
Discussions of this nature lead to arguments and/or meandering posts.

What I have done is create a LOCALLIB project and use it as en external library in all the others.
Whether that is suitable for your purposes I can't say. YMMV and all that.
Previous Topic:Eclipse Won't Start
Next Topic:Issue using eclipse 4.5 with gtk+3.2.2
Goto Forum:
  


Current Time: Fri Apr 19 12:54:15 GMT 2024

Powered by FUDForum. Page generated in 0.03766 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top