linux C++ include file error

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2007
Posts: 37
Reputation: linux0id is an unknown quantity at this point 
Solved Threads: 0
linux0id's Avatar
linux0id linux0id is offline Offline
Light Poster

linux C++ include file error

 
0
  #1
Jan 31st, 2008
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 -
  1. +project
  2. main.cpp
  3. +db
  4. sqlite3.h
  5. sqlite3.cpp
  6. +interface
  7. MyFrame.h
  8. 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!!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 222
Reputation: JRM will become famous soon enough JRM will become famous soon enough 
Solved Threads: 14
JRM's Avatar
JRM JRM is offline Offline
Posting Whiz in Training

Re: linux C++ include file error

 
0
  #2
Jan 31st, 2008
try the FULL path name.
"I like beating by head against the wall because it feels so good when I stop"
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 443
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 68
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: linux C++ include file error

 
0
  #3
Jan 31st, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 37
Reputation: linux0id is an unknown quantity at this point 
Solved Threads: 0
linux0id's Avatar
linux0id linux0id is offline Offline
Light Poster

Re: linux C++ include file error

 
0
  #4
Jan 31st, 2008
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!
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 443
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 68
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: linux C++ include file error

 
0
  #5
Jan 31st, 2008
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..
Last edited by Agni; Jan 31st, 2008 at 1:27 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 37
Reputation: linux0id is an unknown quantity at this point 
Solved Threads: 0
linux0id's Avatar
linux0id linux0id is offline Offline
Light Poster

Re: linux C++ include file error

 
0
  #6
Jan 31st, 2008
but say the path in my case would be
  1. "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?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 443
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 68
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: linux C++ include file error

 
0
  #7
Jan 31st, 2008
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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 37
Reputation: linux0id is an unknown quantity at this point 
Solved Threads: 0
linux0id's Avatar
linux0id linux0id is offline Offline
Light Poster

Re: linux C++ include file error

 
0
  #8
Jan 31st, 2008
thanks a lot chandra.rajat! That has helped!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC