Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Force Eclipse to build a source file from an included directory?
Force Eclipse to build a source file from an included directory? [message #1797623] Fri, 02 November 2018 19:57 Go to next message
Mae Ji-Yun is currently offline Mae Ji-YunFriend
Messages: 1
Registered: November 2018
Junior Member
I'm trying to figure out how to correctly make use of header files, but I'm having some issues. I'm following an article called "Headers and Includes: Why and How" from the c++ website, but it won't let me link it.

My program consists of three files: main.cpp, func.h, and func.cpp. Main.cpp is located within the directory of my project, but func.h and func.cpp are in a folder on my desktop that I added to the include directories of my project.

In main.cpp, I include func.h. In func.h, among other things, I have the prototype to a function. In func.cpp, I include func.h and declare the body of my function.

Calling my function in main.cpp gives me an error saying that my function is undefined, because my program is apparently only aware of the function prototype in func.h. I've read the article I linked over and over and over again, but as far as I'm aware, I'm doing exactly what it wants me to do.

I'm guessing that func.cpp just isn't being compiled, which makes sense to me because it's not #included in main.cpp or func.h. How, then, do I force this file to compile with my project without moving it from its folder on my desktop?

I am still very much a beginner, so please excuse me if I got anything wrong. I'd love to hear any feedback y'all are willing to give me.
Re: Force Eclipse to build a source file from an included directory? [message #1797875 is a reply to message #1797623] Wed, 07 November 2018 21:10 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The easiest way is with a symlink IMO.
You can add symlinks to a workspace for both folders and files.
The files and folders will appear to be within the project.
This works for Linux but not sure if it works under Windows.

When using Linux
$ cd <project dir>
$ ln -s <real loc> <name within proj>

You will need to refresh the Project Explorer view.
Afterwards the linked directory will appear.
Any edits you do to the linked files will change the original.

Eclipse also provides a kind of symlink for directories only.


    o) Right click on the project within Project Explorer view.
    o) From the popup menu: New --> Folder
    o) Enter the folder name (can be anything).
    o) Select Advanced --> Link to alternate location (Linked Folder) --> Browse
    o) Then pick a folder to link.

If you select a linked folder made by Eclipse and display its properties,
it will show the original location.

You can also try:
Project --> Properties --> Paths and Symbols --> Source Location tab
Never used it myself though.

[Updated on: Wed, 07 November 2018 21:32]

Report message to a moderator

Previous Topic:Compiling C++ code or solution
Next Topic:Clean always executed for builds with custom toolchain
Goto Forum:
  


Current Time: Fri Apr 26 14:26:27 GMT 2024

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

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

Back to the top