tags:

views:

78

answers:

1

I am attempting to compile a c++ class using gcc. Due to the nature of the build, I need to invoke gcc from a non-standard location and include non-system defined headers, only to add a set from a different location. However, when I do this, I run into an issue where I cannot find some base symbols (suprise suprise). So i am basically running this command to compile my code:

-->(PARENT_DIR)/usr/bin/gcc # invoke compiler
-B$(PARENT_DIR)/usr/lib64/gcc/suselinux-x8664 
-B$(PARENT_DIR)/usr/lib64 
 #C/C++ flags
-fPIC -fvisibility=default -g -c -Wall -m64 -nostdinc
 # source files
-I$(SRC_DIR_ONE)/ 
-I$(SRC_DIR_TWO)
-I../include 
 # 'Mock' include the system header files
-I$(PARENT_DIR)/usr/include/c++/$(GCC_VERSION) 
-I$(PARENT_DIR)/usr/include/c++/$(GCC_VERSION)/backward 
-I$(PARENT_DIR)/usr/include/c++/$(GCC_VERSION)/x86_64-suse-linux 
-I$(PARENT_DIR)/usr/lib64/x86_64-suse-linux/$(GCC_VERSION)/include 
-I$(PARENT_DIR)/usr/lib64/gcc/x86_64-suse-linux/$(GCC_VERSION)/include 
-I$(PARENT_DIR)/usr/lib64/gcc/x86_64-suse-linux/$(GCC_VERSION)/include-fixed 
-I$(PARENT_DIR)/usr/src/linux/include 
-I$(PARENT_DIR)/usr/x86_64-suse-linux/include 
-I$(PARENT_DIR)/usr/include/suselinux-x8664 
-I$(PARENT_DIR)/usr/suselinux-x8664/include 
-I$(PARENT_DIR)/usr/include 
-I$(PARENT_DIR)/usr/include/linux 
file.cpp

I am getting several errors which indicate that the base headers are not being included: such as:

$(PARENT_DIR)/usr/include/c++/$(GCC_VERSION)/cstddef ::prtdiff_t has not been declared $(PARENT_DIR)/usr/include/c++/$(GCC_VERSION)/cstddef ::size_t has not bee declared.

Is there something that I am doing wrong when I include the header file directories? Or am I looking in the wrong place?

+3  A: 

Perhaps the --sysroot arg would help, see gcc docs.

Dave Bacher
Hmm, I tried this, but I still get the same errors. Although, I must say that this is a nice flag from gcc. Thanks for the heads up on it.
bogertron
FYI, I use this because I've relocated a cross compiler. In my build script, in addition to `--sysroot=...`, I add `-I$(sysroot)/usr/include/c++` and `-I$(sysroot)/usr/include/c++/$(target)` where target is the target's arch-dist-os tuple. Maybe that'll help if it makes sense to you :)
Dave Bacher
And of course, we're using g++ for our C++ code. I'm not sure why you're running into this issue with standard C code.
Dave Bacher