Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Linked resources, header files and includes paths(Linked resources, header files and includes paths)
Linked resources, header files and includes paths [message #1767509] Thu, 06 July 2017 15:27 Go to next message
Alex Bb is currently offline Alex BbFriend
Messages: 7
Registered: September 2016
Junior Member
Hi,

I'm experimenting linked resources but when header files get involved it seems to become pretty confusing..

I have 2 projects in Eclipse neon, let say A and B.
A is the main project, it uses an external makefile for build and that projects builds successfully.
Second project B, in the same workspace, is made of B-private files and some C and H files belonging to project A.

I use linked resource to "add" in project B source files from project A.
For C source files, this is OK, works fine.
For H source files, I add one H file as a linked resource in my project B. But that file cannot be found by gcc (No such file or directory) - unlike other B-private H files.
It seems that linked files are not visible to the project even when they are located in a valid folder (where others H files are properly included).

Are there some specific rules to get linked header files properly included in a project ?

Thanks in advance for any hint,

Alex
Re: Linked resources, header files and includes paths [message #1767573 is a reply to message #1767509] Fri, 07 July 2017 08:29 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
I have successfully used linked folders to share in that way before. I can't recall doing it with linked files directly, but the place I would look is how your includes are being set-up and resolved.

If you can provide a specific failing test case then we can work from there.
Re: Linked resources, header files and includes paths [message #1767615 is a reply to message #1767573] Fri, 07 July 2017 15:34 Go to previous messageGo to next message
Alex Bb is currently offline Alex BbFriend
Messages: 7
Registered: September 2016
Junior Member
Hello,

Yes, I also have no problem at using linked folder, just need to add them in the search path of the preprocessor.

Note sure what can I provide exactly from my project. What I can add at least is:

- Eclipse neon runs on Ubuntu 16.04
- When building Project B (helloPiShell), here the output:
23:50:06 **** Incremental Build of configuration Debug for project helloPiShell ****
make all
Building file: ../HelloW.c
Invoking: GCC C Compiler
gcc -I"/home/alex/workspace/helloPiShell" -I"/home/alex/workspace/essProcMode/inc" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"HelloW.d" -MT"HelloW.o" -o "HelloW.o" "../HelloW.c"
../HelloW.c:13:22: fatal error: keyboard.h: No such file or directory
compilation terminated.
make: *** [HelloW.o] Error 1
subdir.mk:18: recipe for target 'HelloW.o' failed

23:50:06 Build Finished (took 249ms)


- -I arguments show 1/ the local include path and 2/ the linked folder path in A project (essProcMode). Files there are all found perfectly.
- keyboard.h is located in B project main folder (not linked) "/home/alex/workspace/essProcMode". I don't think I have to set this path in the B project's search path - otherwise why using links ?
- I'm suprised to see HelloW.c included from ../. instead of just ./. . Seems the build is run from debur or release folder ?
- In Eclispe outline view, all files are perfectly found and can be display by just a doubleclick, local or linked files. Seems then Eclipse and the builder do not have the same 'search paths'

Not sure what else can I add or try ...

Thanks

[Updated on: Fri, 07 July 2017 15:35]

Report message to a moderator

Re: Linked resources, header files and includes paths [message #1767636 is a reply to message #1767615] Fri, 07 July 2017 20:14 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
Quote:
- keyboard.h is located in B project main folder (not linked) "/home/alex/workspace/essProcMode". I don't think I have to set this path in the B project's search path - otherwise why using links ?

Is this statement correct? Is the keyboard.h located in B project (helloPiShell) main folder or in the path shown?

I have created a git repo with a starting project. If you fork it and adjust to a MCVE that represents your case I can help further. See https://github.com/jonahkichwacoders/eclipse-forum-1087314-1767615

Quote:
- I'm suprised to see HelloW.c included from ../. instead of just ./. . Seems the build is run from debur or release folder ?

Yes it is run from the Debug folder

Quote:
- In Eclispe outline view, all files are perfectly found and can be display by just a doubleclick, local or linked files. Seems then Eclipse and the builder do not have the same 'search paths'


This is probably due to heuristic resolving of includes allowing for settings to not be perfectly aligned to build settings.

Re: Linked resources, header files and includes paths [message #1767639 is a reply to message #1767636] Sat, 08 July 2017 00:30 Go to previous messageGo to next message
Alex Bb is currently offline Alex BbFriend
Messages: 7
Registered: September 2016
Junior Member
Quote:
Is this statement correct? Is the keyboard.h located in B project (helloPiShell) main folder or in the path shown?

Sorry, you're right, this is incorrect, that file is in Project A, as stated in the build command line.

Thank you for others replys. I will take a look at your repo...
Re: Linked resources, header files and includes paths [message #1767642 is a reply to message #1767639] Sat, 08 July 2017 06:17 Go to previous messageGo to next message
Alex Bb is currently offline Alex BbFriend
Messages: 7
Registered: September 2016
Junior Member
Checked the repo... thank you for this :)
Quote:
This project will fail with a build error. To fix it you need to add the folder containing proj_a.h as GCC sees it.

You mean, in my B project I need to add in the include search path the A folder containing the linked header file ?
Even when that 'external file' is already linked into project B ?

In this case I see no benefit to link that file. Just adding the path without the link would work too.
Are header files links allowed or relevant ? With such a limit (need to add a path that is already set through the link) then I see no benefit of linked file for headers.
I think with sym links this would work, might be a workaround then ?
But I might have missed something...

Thanks for your hints !
Re: Linked resources, header files and includes paths [message #1767653 is a reply to message #1767642] Sat, 08 July 2017 14:02 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
I think you have come to the correct conclusion. Adding links to header files seems of little value as CDT will not re-interpret the containing folder. There may be some utility in it sometimes, but I'm not sure when.

You could use sym-links, or as you mentioned earlier Eclipse links to containing folder. If the containing folder has C files you don't want, you could then exclude those files from the build.
Re: Linked resources, header files and includes paths [message #1767740 is a reply to message #1767653] Mon, 10 July 2017 13:46 Go to previous message
Alex Bb is currently offline Alex BbFriend
Messages: 7
Registered: September 2016
Junior Member
Well, ok, thank you for your reply, I indeed started using sym links wich works pretty fine. I just thought it would be as simple with Eclipse. But this might not the the proper use of linked resources in Eclipse.
Documentation doesn't specifically mention the cases of header files.

Thanks again for your support !
ALeX
Previous Topic:Reverse debugging at program start up broken?
Next Topic:Eclipse team view history in svn
Goto Forum:
  


Current Time: Fri Mar 29 01:03:46 GMT 2024

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

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

Back to the top