g++ cross distro compilation problem

Nick Stokes randomaccessiterator@gmail.com
Thu Jan 20 19:29:00 GMT 2011

On Thu, Jan 20, 2011 at 11:40 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 20 January 2011 15:53, Nick Stokes wrote:
>> Assuming you are referring to compiling a code with g++  (and not
> Yep, that's what I meant.
>> compiling gcc itself), then no it doesn't make a difference. (in fact,
>> g++ -v shows that _GNU_SOURCE is already defined).
>> Could it be some other silly mistake on my part, e.g forgetting to set
>> an environment variable or something? Indeed there is the distro's g++
>> compiler installed on the login node, and most of these headers --
>> that are potentially incompatible with the gcc versions I am trying to
>> install under /opt -- are under common places  /usr/include etc.
> You don't need to set any environment variables to use GCC, the 4.4.3
> compiler under /opt will find its own c++ headers not the ones in
> /usr/include/c++/x.y.z (you can check the paths printed with -v to see
> that for yourself)
> You need to find why uselocale is not defined here:
> /opt/gcc/4.4.3/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../../include/c++/4.4.3/x86_64-unknown-linux-gnu/bits/c++locale.h:52:
> error: 'uselocale' was not declared in this scope
> Try using the -E flag and examining the preprocessed output. Do that
> on both machines and look for differences in the path or contents of
> the locale.h header.  To minimise the output it should be sufficient
> to do:
> echo '#include <ios>' | g++ -E -x c++  -

Great! This indeed revealed it.  In /usr/include/locale.h (same
location, line  133, in both distros actually)  there is #ifdef
__USE_GNU  on CentOS version, which is  #ifdef __USE_XOPEN2K8 in
SUSE's version.   So, in fact if I define `__USE_XOPEN2K8'  while
compiling on SUSE, it works. Hmm, go figure.. This can not be the
right way to do this. What am I missing?


More information about the Gcc-help mailing list