Configure question when building root from source

Hi,
I need to use a different compiler that I built (don’t ask; long story!) rather than use the default compiler. So I notice this option in configure from the --help option:

[i]with compiler options, prefix with --with-, overrides default value

cc alternative C compiler and options to be used
cxx alternative C++ compiler and options to be used
f77 alternative Fortran compiler and options to be used[/i]

So I configured it with this option:
–with-cxx=/home/jade/gcc-4.8.0/local/bin/gcc

So when I run make, how do I know it’s picking up the correct include that corresponds to the compiler version and not looking at the default /usr/include? I have set the LD_LIBRARY_PATH to first look in /home/jade/gcc-4.8.0/local/lib64, to make sure it picks up the library that matches with the compiler. But how does one make sure it’s picking up the right include that’s consistent to the compiler?

I only ask this because when I run make, I get a linking error … it can’t find standard C++ ostream, strings, among other things:

History.cpp:(.text+0x29e): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std: :__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)' History.cpp:(.text+0x2bb): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std: :__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'

My guess is that it’s not picking up the right include that matches the library (that is it is probably picking up the default in /usr/include). I looked at the compilation line and there’s nothing there that indicates that it’s picking up the include that’s consistent to the compiler I suggested. For instance, here’s one compilation line:

gcc -O2 -pipe -m64 -Wall -W -fPIC -Iinclude -DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION -DG__64BIT -DG__HAVE_CONFIG -DG__NOMAKEINFO -DG__CINTBODY -I/home/jade/root/cint/cint/inc -I/home/jade/root/cint/cint/src -I/home/jade/root/cint/cint/src/dict -pthread -I. -o cint/cint/src/g__cfunc.o -c /home/jade/root/cint/cint/src/g__cfunc.c bin/rmkdepend -R -fcint/cint/src/config/strlcpy.d -Y -w 1000 -- -pipe -m64 -Wall -W -fPIC -Iinclude -DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION -DG__64BIT -DG__HAVE_CONFIG -DG__NOMAKEINFO -DG__CINTBODY -I/home/jade/root/cint/cint/inc -I/home/jade/root/cint/cint/src -I/home/jade/root/cint/cint/src/dict -pthread -I. -- /home/jade/root/cint/cint/src/config/strlcpy.c

As an alternative, I didn’t bother with the --with-cxx and made sure that my $PATH had /home/jade/gcc-4.8.0/local/bin, so that it picked up the preferred gcc, but I still get the same build error. It’s the same problem … how do I know it’s picking up the correct include that’s consistent to the compiler? I thought the --with-cxx would fix the problem, but it did not. Any advice? I attached my config.log
savconfig.txt (282 KB)

Just a simple question: Why do you set the C++ compiler to something that looks like a C compiler (gcc instead of g++)? If the C++ compiler is later used for linking it will not link a C++ stdlib, but some libc.

Hi Honk,
no particular reason. I just thought that the g++ being under gcc would just naturally be triggered based on weather the file is a *.cxx or *.c. In anycase, I went ahead and reconfigured root (see new attached config.txt) where now I passed the option:
–with-cxx=/home/jade/gcc-4.8.0/local/bin/g++

But still the same linking problem occurs (see attached build.txt). So the question remains: when --with-cxx is specified, is it really picking up the right c++ includes? I don’t see any modification with the includes in the compilation line that is consistent to the g++ specified. And I definitely set in my LD_LIBRARY_PATH to pick up the right g++ library:

$:~/root> echo $LD_LIBRARY_PATH /home/jade/gmp-5.1.3/local/lib:/home/jade/mpfr-3.1.2/local/lib:/home/jade/mpc-1.0.1/local/lib:/home/jade/gcc-4.8.0/local/lib64:/home/jade/gsl-1.16/local/lib: ...
build.txt (527 KB)
savconfig.txt (282 KB)

BTW I had also noticed that in the build.txt I attached in my previous build, the error happens at this linking:

/home/jade/gcc-4.8.0/local/bin/g++ -pipe -m64 -Wshadow -Wall -W -Woverloaded-virtual -fPIC -Iinclude -pthread -I. -I/home/jade/root/cint/cint/inc -o core/textinput/src/G__TextInput.o -c core/textinput/src/G__TextInput.cxx g++ -shared -Wl,-soname,libCore.so -m64 -O2 -Wl,--no-undefined -Wl,--as-needed -o lib/libCore.so core/base/src/TSystem.o core/base/src/TVirtualPS.o ...

So I notice that the compilation above is explicit in using the g++ I specified in the config, but in the linking, it wasn’t as explicit on which g++ it was using. Now, I have setup my path such that it will pick up the matching g++, that is:

$:~/root> which g++ /home/jade/gcc-4.8.0/local/bin/g++

But possibly to get to the root of the problem, I went ahead and reconfigured again (and made sure I did ‘make distclean’) by being explicit to use the correct g++ version for linking:

./configure "--with-cc=/home/jade/gcc-4.8.0/local/bin/gcc" "--with-cxx=/home/jade/gcc-4.8.0/local/bin/g++" "--with-ld=/home/jade/gcc-4.8.0/local/bin/g++" "--with-gsl-incdir=/home/jade/gsl-1.16/local/include" "--with-gsl-libdir=/home/jade/gsl-1.16/local/lib" "--with-gviz-incdir=/tools/graphviz/current/include" "--with-gviz-libdir=/tools/graphviz/current/lib" "--all"

Still no difference. The same exact error occurs. :frowning: Still undefines for C++ stdlib routines.

[quote=“jade2”]BTW I had also noticed that in the build.txt I attached in my previous build, the error happens at this linking:

/home/jade/gcc-4.8.0/local/bin/g++ -pipe -m64 -Wshadow -Wall -W -Woverloaded-virtual -fPIC -Iinclude -pthread -I. -I/home/jade/root/cint/cint/inc -o core/textinput/src/G__TextInput.o -c core/textinput/src/G__TextInput.cxx g++ -shared -Wl,-soname,libCore.so -m64 -O2 -Wl,--no-undefined -Wl,--as-needed -o lib/libCore.so core/base/src/TSystem.o core/base/src/TVirtualPS.o ...

So I notice that the compilation above is explicit in using the g++ I specified in the config, but in the linking, it wasn’t as explicit on which g++ it was using. Now, I have setup my path such that it will pick up the matching g++, that is:

$:~/root> which g++ /home/jade/gcc-4.8.0/local/bin/g++

But possibly to get to the root of the problem, I went ahead and reconfigured again (and made sure I did ‘make distclean’) by being explicit to use the correct g++ version for linking:

./configure "--with-cc=/home/jade/gcc-4.8.0/local/bin/gcc" "--with-cxx=/home/jade/gcc-4.8.0/local/bin/g++" "--with-ld=/home/jade/gcc-4.8.0/local/bin/g++" "--with-gsl-incdir=/home/jade/gsl-1.16/local/include" "--with-gsl-libdir=/home/jade/gsl-1.16/local/lib" "--with-gviz-incdir=/tools/graphviz/current/include" "--with-gviz-libdir=/tools/graphviz/current/lib" "--all"

Still no difference. The same exact error occurs. :frowning: Still undefines for C++ stdlib routines.[/quote]

I’ve just tried with my custom-built g++ 4.8.2 (no gsl or gviz) and ROOT (5-34-00-patches) was built successfully.
I’m setting PATH/LD_LIBRARY_PATH etc. for my g++ so when configuring, I’m using g++/gcc instead of absolute paths.

How do you know you actually linked the correct std library set? I think it’s really dependent on how your current compiler differs from the default compiler, then maybe you can notice the difference in the build. If there’s not much difference, you probably can’t notice it on the build. For instance in my case, the current compiler I’m using is very different from the default compiler (current compiler is very old; unfortunately I don’t have privs in changing that, which is what led me down this road). This is why it’s noticeable on my build (e.g. libraries are so very different between the two compilers).

I didn’t actually apply any patches. I just checked out root and did this:
git checkout -b v5-34-12 v5-34-12
Switched to a new branch ‘v5-34-12’

Would this be the same as checking out v5-34-00 and applying the patches? If so it still failed for the v5-34-12.

In anycase, I got it to build by explicitly passing the LDFLAGS to the make command. I had first figured this out by explicitly executing the linking line that failed with adding the -L(path to where my gcc library was located). Once I did that, it seems to build. I have no idea why it’s not sufficient to just set this in the LD_LIBRARY_PATH … I had it in there, but it didn’t seem to make a difference in the build.

It seems that setting the --with-cxx (and/or --with-ld, etc) in the configure is not sufficient to have it work with a different compiler/linker. One should also be able to pass in the LDFLAGS in the configure, but that too didn’t work either (that is LDFLAGS="$LDFLAGS …" ./configure …). The only way it was going to accept the LDFLAGS for the build was do:
make LDFLAGS="$LDFLAGS … whatever option you need to add"
where I had to add -L for my case (well I placed my added options before $LDFLAGS).
Once I did this, root succeeded in building

Regardless, the --with-cxx/ld,etc should have worked but doesn’t. One shouldn’t have to pass some additional stuff to make or configure to get this working (setting the LD_LIBRARY_PATH to include the gcc libs clearly did not work).

I’m sorry, I’m skipping your long and very detailed post. Yes, probably, something is wrong and blah-blah-blah.
But if you really want/need to build ROOT with “non-system” compiler, you can just follow my advice, however bizzare/illogical etc. it is.

If not - good luck.

I know, that my ROOT was compiled/linked with a right library, since I can check the dependencies - and I see that the resulting executable/libraries depend on the C++ library from my custom built g++ (4.8.2), and I’m on Mac OS 10.9 with clang as the system compiler and its library (on mac I’m using otool with special options to check the dependencies).

So, if you really want to build ROOT - try to do what I suggested: set the PATH/LD_LIBRARY_PATH in such way that g++/gcc means your custom g++/gcc; configure ROOT with --with… you already did it and with “relative” path instead of absolute path. I can not guarantee it works for you, it worked for me and you can use it as a workaround, at least you can try.

If not - ok - probably a good idea would be to submit a bug report in a JIRA if you want.
But at least you can have a ROOT built with a “non-standard” compiler right now.

Hi tpochen,
I did get it working but in an unconventional way. As I noted, using the PATH/LD_LIBRARY_PATH didn’t work. The only way I could get it working was add the path via LDFLAGS when running make.

Still I think this is a bug in the --with-cxx/ld options in the configure. It also noted in the --help option, that one could pass the specified compiler along with options to be used with the compiler. Passing the compiler works but it certainly did not accept options.

This option in configure might have worked on your mac, but I don’t know if one has tried it on a linux. One shouldn’t have to pass an LDFLAGS of the path of the specified compiler to make, to get it working.

[quote=“jade2”]Hi tpochep,
I did get it working but in an unconventional way. As I noted, using the PATH/LD_LIBRARY_PATH didn’t work. The only way I could get it working was add the path via LDFLAGS when running make.

[/quote]

Ok, I see, I have not tried it on linux yet (and after all I have is only Ubuntu), so I assumed my “recipe” can help on linux also.

I totally agree, --with should be enough to build successfully, otherwise there is no reason in all these --with-…, so I was just suggesting a temporary workaround.

Actually, I’ve tried several different things on my Mac today. I had the same linker errors as you do :frowning: and it only worked for me in a way I’ve described/suggested.

[quote=“tpochep”]
Actually, I’ve tried several different things on my Mac today. I had the same linker errors as you do :frowning: and it only worked for me in a way I’ve described/suggested.[/quote]

That’s odd that you only got it to work with a relative path than an absolute path. I would have thought that the absolute path should definitely work. I’m not sure what the consequences (if any) is of using the relative path…
I know I got the LDFLAGS working with the absolute path to my built std library…

I think they should at least be specific on what additional things one should do if one is to venture using the --with-cxx/ld. Seems it’s a hit or miss to get it working… and it was hard to figure out what configure actually did with that option. It was hard to figure out how using this option, is different from just appropriately setting the PATH such that it’ll always pick up your specific compiler. I thought the --with-cxx/ld option would have appropriately setup the include and linking path, but clearly did not. My guess is, I could have just built this without bothering with the --with-cxx/ld option, making sure that my path was set correctly (and passing the LDFLAGS to make).

Anyway, thanks for helping me out! :smiley: