Hi everyone!
I am new to C++, started not so long ago. I am writing a database program using sqlite3 and gtkmm (C++ bindings to GTK) GUI toolkit. I am using Eclipse for project building (managed make). In my project, I have two folders - 'db' and 'interface'. here is what inside folders -

+project
     main.cpp
     +db
          sqlite3.h
          sqlite3.cpp
     +interface
          MyFrame.h
          MyFrame.cpp

Now, I want to initialize the sqlite3 class so it is part of MyFrame and then I can link buttons to use its functions in MyFrame. I try to do this by using #include "db/sqlite3.h" in MyFrame.h, but the compiler says "No such file or directory". If, however, I place the sqlite3 class files into 'interface' folder, everything works fine. But I do not want that - I want to keep things in different folders for better organization (in my opinion). Soon there will more classes and files added to this project, and I don't want to have to dump everything into one 'interface' folder. Please help!!!

either you give the complete path in the include statement. or else what you can do is that you can add the complete path in the include path of the compiler. in command prompt we do it by using the compiler option -I. eg

gcc -I<path> file.cpp

you can set this in the makefile or
if its GUI there must be some option to set this path for the compiler.

I forgot to mention that I have tried that and, yes it does work. But is there a better way other than giving it a full path, say that if I wanted to pack this project later on so that others can compile and install it? Thanks for the suggestions though!

Then put it in the makefile and give the makefile with the source code for compilation and yes to make sure the makefile works for anyone, make sure the paths are not hardcoded. use environment variables like $PATH etc. so that it works for anyone in any directory structure..

but say the path in my case would be

"home/linux0id/.eclipse/workspace/database/db/sqlite3.h"

surely it would not work on anyone elses machine unless they happen to have the same filepath? Or am I wrong?

exactly thats y i mentioned that use environment variables like $MYPATH but yes its always there that you might change the drive in which you place the code etc. but after a point the dir structure has to be the same as urs. i mean suppose you put it in

"e:/linux/eclipse/workspace/" and set $MYPATH as e:/linux then ur makefile will have

$MYPATH/workspace

now the other person might store it in

"c:/temp/project/workspace"

he can set $MYPATH as c:/temp/project and the makefile will work for him provided the final folder is same as urs, which is workspace in this case..

got it?

This question has already been answered. Start a new discussion instead.