How to ask Linux g++ to correctly compile header files contained within another header file?

Good morning, I have a question about how to fix the following Linux Makefile code:

g++ -g -Wall -I"./" -I"../CameraControlLib" -I"./Cameras" -I"../../Utilities/DataServer" -o Server.o CameraControlLib/Server.cpp

In this particular case, DataServerLib.h includes CameraControlDefs.h as shown below. The Ubuntu Linux g++ compiler resolves the include file, DataServerLib.h, correctly using the -I preprocessor directive as shown below. However, the g++ compiler tells me that there is no such file or directory as CameraControlDefs.h even though I point a -I subdirectory path to ../../Utilities/DataServer.

In file included from CameraControlLib/DataServer.h:4:0, from CameraControlLib/DataServer.cpp:8: CameraControlLib/DataServerLib.h:9:31: fatal error: CameraControlDefs.h: No such file or directory #include "CameraControlDefs.h" ^ compilation terminated.

I know that if I use #include "SomeDir/CameraControlDefs.h" ,that should get rid of the compiler error message. Please let me know if there is an alternate way to do this using the full range of Linux g++ options.
camster123Senior C++ Software EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Karrtik IyerSoftware ArchitectCommented:
Can you please post your current directory structure sample as per the example stated for both the header files?
1
Karrtik IyerSoftware ArchitectCommented:
Is CameraControlDefs.h below this directory ../../Utilities/DataServer/SomeDir or is it directly under
../../Utilities/DataServer?
1
camster123Senior C++ Software EngineerAuthor Commented:
Karrtik Iyer, The directory structure for all three of the header files

./ CameraControlLib/DataServer.h  RELATIVE TO  /home/testing/developmentMine/Hybrid
.. /CameraControlLib/DataServerLib.h RELATIVE TO  /home/testing/developmentMine/Hybrid
... /home/testing/developmentMine/Hybrid/Utilities/Server/cameracontroldefs.h
      
is the only viable option we have is to change the line in a C++ source file where the nested header file is specified to include eaccurate relative path OR use some other G++ option?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

camster123Senior C++ Software EngineerAuthor Commented:
Karrtik Iyer,
>> Is CameraControlDefs.h below this directory ../../Utilities/DataServer/SomeDir or is it directly under
>> ../../Utilities/DataServer?

CameraControlDefs.h is directly below .././Utilitie/DataServer.

Thank you.
0
Karrtik IyerSoftware ArchitectCommented:
Little bit confused, before looking for g++ option, One more question, in your original question you have mentioned that you can solve this problem by changing code to have SomeDir in the include statement.
SomeDir/CameraControlDefs.h
Where's is the SomeDir in the directory structure you specified in the last post for 3 header files?
1
Karrtik IyerSoftware ArchitectCommented:
Instead of giving relative path in g++ option to data server, can you try giving absolute path to data server(or wherever CameraControlDefs.h is present) , which is instead of
-I"../../Utilities/DataServer"
Try giving -I"/home/testing/developmentMine/Hybrid/Utilities/DataServer“
I'm little confused whether it is Utilities/server or Utilities/DataServer, your original question suggests it is Utilities/DataServer but while mentioning the directory structure of 3 files you have mentioned that CameraControlDefs.h is under Utilities/Server, so please specify appropriately.
0
Karrtik IyerSoftware ArchitectCommented:
Just in case, if you want to specify a parent directory as include directory  (../../Utilities/DataServer/)  and want build tool set to search for the header files below all sub folders for  
  (../../Utilities/DataServer/)
You can use below in your make file (not possible without make file using only g++ at command prompt)
INCDIRS := $(addprefix -I,$(shell find  ../../Utilities/DataServer  -type d -print))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
camster123Senior C++ Software EngineerAuthor Commented:
Karrtik Iyer,
         Here are the complete directory structures for the 3 C++ header files..
/home/testing/developmentMine/Hybrid/Recorder/CameraControlLib/CameraControlLib/DataServer.h

 /home/testing/developmentMine/Hybrid/Recorder/CameraControlLib/DataServerLib.h

/home/testing/developmentMine/Hybrid/Utilities/Server/cameracontroldefs.h

Thank you.
0
Karrtik IyerSoftware ArchitectCommented:
Can you please try giving absolute path to CameraControlDefs.h ( /home/testing/developmentMine/Hybrid/Utilities/Server)  in your include path instead of relative path?
0
camster123Senior C++ Software EngineerAuthor Commented:
Karrtik Iyer,
 I just tested sucessfuly your solution to myy question today by adding the following to my Makefile.
INCDIRS := $(addprefix -I,$(shell find  ../Utilities/DataServer  -type d -print))


Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.