How to include headers from another project?

General questions regarding the usage of CodeLite
nerdux
CodeLite Curious
Posts: 2
Joined: Tue Dec 10, 2013 2:11 pm
Genuine User: Yes
IDE Question: C++
Contact:

How to include headers from another project?

Post by nerdux »

Hello Codeliters! please be patient, I'm a newbie here.

I have coded a basic singly linked list class for testing, and compiled it as a dynamic library using codelite. Folder/file structure is as follows:

Work/SingleIntList:
Debug SingleIntList.project singly_int_list.cpp
SingleIntList.mk SingleIntList.txt singly_int_list.h

Work/SingleIntList/Debug:
SingleIntList.so singly_int_list.o singly_int_list.o.d



I have also created a workspace and a project inside it

Work/TestSIL:
Makefile TestSIL TestSIL.workspace

Work/TestSIL/TestSIL:
Debug main.cpp TestSIL.mk TestSIL.project

Work/TestSIL/TestSIL/Debug:
main.o.d


In this workspace (TestSIL) I have "added an existing project" and then selected SingleIntList. So far so good, I have both projects in the TestSIL workspace, but when I compile it terminates with the following error:
/home/mario/Work/TestSIL/TestSIL/main.cpp:2:43: fatal error: SingleIntList/singly_int_list.h: No such file or directory

This is the source for main.cpp in the TestSIL project (so you can see how I'm including the header from the other project):

Code: Select all

#include <iostream>
#include <SingleIntList/singly_int_list.h>

using namespace std;

int main()
{
     SinglyIntList j;

     j.prepend(5);
     cout << "Hola, Mundo" << endl;

     return 0;
}
How should I set things up in order to build this project successfully in this layout?
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: How to include headers from another project?

Post by Jarod42 »

Simply fix the project settings:
Add correct path in Include Paths (Settings... -> Common settings ; Compiler)

linker options may also be fixed.
nerdux
CodeLite Curious
Posts: 2
Joined: Tue Dec 10, 2013 2:11 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to include headers from another project?

Post by nerdux »

Thank you very much, Jarod42, that fixed it. And you were right, linker options must be fixed too (workig on that right now).
Zoran
CodeLite Curious
Posts: 4
Joined: Tue Jan 31, 2012 11:26 am
Genuine User: Yes
IDE Question: c++
Contact:

Re: How to include headers from another project?

Post by Zoran »

nerdux wrote:Thank you very much, Jarod42, that fixed it. And you were right, linker options must be fixed too (workig on that right now).
Hello,
How should these linker options be fixed?
I have the same problem and after I added the path in "Include Paths" my project still does not compile.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to include headers from another project?

Post by eranif »

Zoran wrote:I have the same problem and after I added the path in "Include Paths" my project still does not compile
This is a very generic description that gives no information about your problem

Please read the HOW TO POST thread and provide all the information needed

Eran
Make sure you have read the HOW TO POST thread
Zoran
CodeLite Curious
Posts: 4
Joined: Tue Jan 31, 2012 11:26 am
Genuine User: Yes
IDE Question: c++
Contact:

Re: How to include headers from another project?

Post by Zoran »

eranif wrote:
Zoran wrote:I have the same problem and after I added the path in "Include Paths" my project still does not compile
This is a very generic description that gives no information about your problem

Please read the HOW TO POST thread and provide all the information needed

Eran
Sorry, my question is specifically about the nerdux's sentence which I had quoted in my previous post — "linker options must be fixed too".
Perhaps I didn't understand well, but I thought that this means that two steps are required:
1. adding the path to "Include paths", which is explained in this topic.
2. fixing linker options, which I don't know how to do

Thanks, Zoran
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to include headers from another project?

Post by eranif »

Zoran wrote:fixing linker options
Project Settings -> Common Settings -> Linker

Edit the library paths and libraries to link against

Eran
Make sure you have read the HOW TO POST thread
Post Reply