LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-12-2016, 05:40 AM   #1
knobby67
Member
 
Registered: Mar 2006
Posts: 627

Rep: Reputation: 43
c++ library including a header within a header


Hi All,
if I want to make a .a static header and include a header call from within a header I get an "No such file or directory" error. Unless I use the full path within the header. It works fine with a standard non libray build. I'm working with soap internet comms. I have two folders for source code, one holding my control code one the soap stubs for the xml code. In my control code if I do a library build and don't include full paths to stubs headers I get an error. eg
Code:
#include "soapERSWSExternalClientServiceImplServiceSoapBindingProxy.h"
error
Code:
#include "../QR/soapERSWSExternalClientServiceImplServiceSoapBindingProxy.h"
works

I am setting my includes in my makefile, it's as if when using a library makefile it just forgets to use the paths?

so my directory is as follows

|
|
-------------lib (source control files directory )
|
|
--------------| QR directory ( project name )
|
|
---------makefile
|
---------stubs directory ( sopa xml files for comms )


Am I just making a stupid mistake or need full paths set if a header includes a header?
My lib make is below. Thanks

Code:
TRGT =
CC   = $(TRGT)g++
CP   = $(TRGT)objcopy
AS   = $(TRGT)gcc -x assembler-with-cpp
BIN  = $(CP) -O binary
AR   = $(TRGT)ar

# List all debug C defines here  ok needed 
DDEFS =-DWITH_NONAMESPACES -DWITH_OPENSSL

DINCDIR = -Istubs/ -I../lib

PRODUCT_LIBS = -lpthread -lssl -lcrypto -lssl

CPPFLAGS = -Wall -pedantic -g  -std=c++11

PROGRAM = Test
LIBRARY_DIRECTORY =../lib/
COMMON_DIRECTORY =../CommonFiles/
SOURCE_DIRECTORY =source/
STUBS_DIRECTORY =stubs/

##just so I get a second try at path
IFLAGS = -I$(STUBS_DIRECTORY)


#files to compile first two lines always needed, so need to use wsdl2h and then soapcpp to pul and compile stubs
objects = $(LIBRARY_DIRECTORY)QR_Control_Class.o\
$(LIBRARY_DIRECTORY)stdsoap2.o\
$(STUBS_DIRECTORY)soapC.o\
$(STUBS_DIRECTORY)soapERSWSExternalClientServiceImplServiceSoapBindingProxy.o\
$(LIBRARY_DIRECTORY)File_Control_Class.o


#Pattern rule to generate an object file from a 'C' file
%.o : %.c
	$(CC) -c $(IFLAGS) $(DINCDIR) $(CPPFLAGS) $(DDEFS) $(PRODUCT_LIBS) $< -o $@


libfiles.a:	$(objects)
	$(AR) -rs libsoapfiles.a $(objects)
 
Old 05-12-2016, 05:58 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Try to reorganize:

Code:
CC       = $(TRGT)gcc # C-compiler
CXX      = $(TRGT)g++ # C++-compiler

DDEFS    = -DWITH_NONAMESPACES -DWITH_OPENSSL
DINCDIR  = -Istubs/ -I../lib
CPPFLAGS = ${DDEFS} ${DINCDIR}

CFLAGS   = -Wall -pedantic -g              # C-compiler
CXXFLAGS = -Wall -pedantic -g -std=c++11   # C++-compiler

# C-compilation
%.o: %.c
        ${CC} ${CFLAGS} ${CPPFLAGS} -o $@ -c $<

# C++-compilation
%.o: %.cc
        ${CXX} ${CXXFLAGS} ${CPPFLAGS} -o $@ -c $<
 
1 members found this post helpful.
Old 05-12-2016, 06:14 AM   #3
knobby67
Member
 
Registered: Mar 2006
Posts: 627

Original Poster
Rep: Reputation: 43
Ahhhhh! Thanks! I knew I would feel like an idiot. I absolutely knew I'd done something stupid but for the life of me couldn't spot it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with including user defined header file wch705 Programming 2 04-29-2011 08:09 AM
Priority in including header jkim74 Linux - Embedded & Single-board computer 1 07-29-2010 10:21 PM
Including c++ header files cbabbage Programming 6 10-28-2009 09:36 PM
Including header file using HTML hoho4rd Programming 4 12-05-2006 11:20 AM
Difference between including a header file and 'class' declaration in C++ scoTtkIm Programming 1 09-09-2004 04:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration