After compiling the newest root version on both MacOS X 10.4.2 and on FC4,
I wanted to recompile my program consisting of eight libraries and a gui.
As usual I deleted everything before recompiling.
While I could compile and run my program on FC4 on my Intel notebook, and could
compile the first six libraries on my Mac, trying to compile the next library
resulted in the following error, although I did not change this library since
many months and it compiled w/o problem on all earlier root versions:
m987p016:~/ROOT/rootcode/xpstest rabbitus$ make -f Makefile4XPSProcessing
c++ -O -pipe -Wall -D_REENTRANT -Wno-long-double -I/Users/rabbitus/ROOT/root/include -c XPSProcessing.cxx
c++ -O -pipe -Wall -D_REENTRANT -Wno-long-double -I/Users/rabbitus/ROOT/root/include -c XPSHybridizer.cxx
c++ -O -pipe -Wall -D_REENTRANT -Wno-long-double -I/Users/rabbitus/ROOT/root/include -c XPSSelector.cxx
c++ -O -pipe -Wall -D_REENTRANT -Wno-long-double -I/Users/rabbitus/ROOT/root/include -c XPSNormalizer.cxx
c++ -O -pipe -Wall -D_REENTRANT -Wno-long-double -I/Users/rabbitus/ROOT/root/include -c XPSPreProcessing.cxx
c++ -O -pipe -Wall -D_REENTRANT -Wno-long-double -I/Users/rabbitus/ROOT/root/include -c XPSNormation.cxx
Generating dictionary XPSProcessingDict.cxx...
c++ -O -pipe -Wall -D_REENTRANT -Wno-long-double -I/Users/rabbitus/ROOT/root/include -c XPSProcessingDict.cxx
XPSProcessingDict.cxx: In function `int G__XPSProcessingDict_351_2_0(G__value*, const char*, G__param*, int)':
XPSProcessingDict.cxx:9250: internal compiler error: in cp_tree_equal, at cp/tree.c:1679
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
{standard input}:90557:FATAL:.abort detected. Assembly stopping.
make: *** [XPSProcessingDict.o] Error 1
Function G__XPSProcessingDict_351_2_0() has the following code:
Thank you for this hint, however, I have the following questions:
1, Since I have used the same makefile in all earlier versions (see the attached
file “Makefile4XPSProcessing.mac”), why did this error generating dictionary not
appear in earlier root versions?
2, Sorrowly, I am not sure how to disable optimization of the dictionary in the
attached makefile w/o disabling also all other optimizations. It would be great if
you could help me.
3, When compiling my program on FC4 I could simplify my makefile by including
"Makefile.arch" from root/test, see attached makefile “Makefile4XPSProcessing.fc4”.
However, trying to use this makefile on my Mac I get many hundred lines of
"warning: unused parameter xxx" and a different error generating dictionary, see:
m895p026:~/ROOT/rootcode/xpstest rabbitus$ make -f Makefile4XPSProcessing.fc4
c++ -O2 -pipe -Wall -W -Woverloaded-virtual -D_REENTRANT -Wno-long-double -I/Users/rabbitus/ROOT/root/include -c XPSProcessing.cxx
/Users/rabbitus/ROOT/root/include/TObject.h:113: warning: 'virtual void TObject::Draw(const Option_t*)' was hidden
XPSUtils.h:194: warning: by 'XPlot::Draw'
/Users/rabbitus/ROOT/root/include/TNamed.h:60: warning: 'virtual void TNamed::SetTitle(const char*)' was hidden
XPSUtils.h:238: warning: by 'void XPlot::SetTitle(const char*, Int_t)'
/Users/rabbitus/ROOT/root/include/TFolder.h:55: warning: 'virtual TObject* TFolder::FindObject(const TObject*) const' was hidden
XPSBase.h:112: warning: by 'XFolder::FindObject'
/Users/rabbitus/ROOT/root/include/TFolder.h:53: warning: 'virtual const char* TFolder::FindFullPathName(const TObject*) const' was hidden
XPSBase.h:107: warning: by 'virtual const char* XFolder::FindFullPathName(const char*) const'
XPSBase.h:144: warning: unused parameter 'set'
XPSBase.h:145: warning: unused parameter 'name'
////////
// etc some hundred lines of warnings
////////
MACOSX_DEPLOYMENT_TARGET=10.4 c++ -dynamiclib -single_module -undefined dynamic_lookup XPSProcessing.o XPSHybridizer.o XPSSelector.o XPSNormalizer.o XPSPreProcessing.o XPSNormation.o XPSProcessingDict.o -o libXPSProcessing.dylib
MACOSX_DEPLOYMENT_TARGET=10.4 c++ -bundle -undefined suppress -Wl,-x -O2 -bind_at_load XPSProcessing.o XPSHybridizer.o XPSSelector.o XPSNormalizer.o XPSPreProcessing.o XPSNormation.o XPSProcessingDict.o \
-o libXPSProcessing.so
/usr/bin/ld: -undefined error, -undefined dynamic_lookup or -undefined define_a_way must be used when -twolevel_namespace is in effect
collect2: ld returned 1 exit status
make: *** [libXPSProcessing.dylib] Error 1
Great, thank you. I am afraid I need to understand makefiles better.
Meanwhile I have updated my Mac to 10.4.3 and also updated the Apple Developer Tools.
Recompiling root and my program works now fine w/o any problems (even with optimization).
The only remaining (minor) problem is my question 3. The warnings and the error remain the same.
(Maybe this is something Mac-specific?)
these are not caused by ROOT, but by the code which you try to compile. O, and there’s one error which I don’t know anything about, as it’s MacOS specific. man ld (or the corresponding help command for MacOS) will probably solve the error /usr/bin/ld: -undefined error, -undefined dynamic_lookup or -undefined define_a_way must be used when -twolevel_namespace is in effect"
/Users/rabbitus/ROOT/root/include/TNamed.h:60: warning: 'virtual void TNamed::SetTitle(const char*)' was hidden
XPSUtils.h:238: warning: by 'void XPlot::SetTitle(const char*, Int_t)'
This means you will not be able to call XPlot::SetTitle(const char*) (defined in XPlot’s base class TFolder) anymore, as it is hidden by XPlot’s version of SetTitle(const char*,Int_t). See the C++ standard on why that is.
XPSBase.h:144: warning: unused parameter 'set' means that the method definition’s parameter list contains a parameter that is not used in the method itself. Simply remove it’s name, as in XPlot::SomeFunc(const char* paramIsUsed, int /* paramUnused*/){...} and gcc will not complain about “unused parameter paramUnused” anymore.
XPSBase.h:144: warning: unused parameter 'set'
XPSBase.h:145: warning: unused parameter 'name'
In XPSBase.h you have a functio likevoid MyFunction(MyClass *set) { /* code NOT using set */ }to solve this issue use:void MyFunction(MyClass * /* set */) { /* code NOT using set */ }
The erros:/Users/rabbitus/ROOT/root/include/TFolder.h:53: warning: 'virtual const char* TFolder::FindFullPathName(const TObject*) const' was hidden
XPSBase.h:107: warning: by 'virtual const char* XFolder::FindFullPathName(const char*) const'
Those are real errors (per se), the simple solution is usually to add
using FindFullPathName;inside your class. However you may also consider whether the signature you used is ‘correct’/‘intended’.
Thank you for these comments, I appreciate them very much, but I need some time to
understand them completely. Nevertheless, please allow me to make some comments already now:
As you know, I am now able to test and compile my program not only on my Mac, but also
on my new Intel Notebook running FC4. Compiling the same code on FC4 with both types of
makefiles results in no warnings and no error at all. Compiling the code on my Mac with
my old makefile also causes no problems. Only the makefile on the Mac where I include
Makefile.arch results in these warnings and error, see the complete output of the compiler
messages in the attached file.
An example class with the warnings is the following:
Surely, I can comment-out these names (I cannot declare this class as abstract base class).
What I do not understand is, that in three out of four cases (2 makefiles on FC4, one
makefile on Mac) the compiler does not complain.
it’s really as simple as: compilers (and their versions) behave differently (esp. when giving additional flags like “-pedantic” or “-Wall” as in your Makefile.arch case), the C++ standard doesn’t always define what compilers have to complain about, and even where it does compilers sometimes don’t care. If you dislike it you can probably figure out the switches to disable these warning - but you’ll have to deal with them on other platforms, too. So the best way to get around it is by “fixing” your code.
It seems that the C++ standard has changed, but I will probably make the corresponding changes in my code.
I do not understand why XPlot::SetTitle(const char*, Int_t) hides TNamed::SetTitle(const char*).
I thought that there is function polymorphism so that SetTitle(const char*, Int_t) is different to SetTitle(const char*)?
Since I do not use namespaces, where do I need to add “using SetTitle;”?
BTW, I have changed the makefile according to the new test examples, and now I can compile my library w/o error
(see new attached makefile).
[quote=“cstrato”]It seems that the C++ standard has changed, but I will probably make the corresponding changes in my code.[/quote]It does change once a while. But I didn’t realize (and don’t think) that this is a new part of the standard…
[quote=“cstrato”]I do not understand why XPlot::SetTitle(const char*, Int_t) hides TNamed::SetTitle(const char*).
I thought that there is function polymorphism so that SetTitle(const char*, Int_t) is different to SetTitle(const char*)?[/quote]Only if they’re on the same “inheritance level”.
[quote=“cstrato”]Since I do not use namespaces, where do I need to add “using SetTitle;”?[/quote]In your derived class XPlot’s declaration. With that you pull the base class’s method into the derived class’s scope - “lifting it onto the same inheritance level”, so to say.
Thank you for this explanation.
Of course, before asking I checked a couple of C++ books. Sorrowly, none of the books
describing the using keyword mentions this case.
the “using method;” syntax is relatively new, it is in the standard but only modern C++ compilers support it, like gcc 4 (and gcc 3 too).
The hiding did always happen, you just happened to never use a compiler that complained about it until now (since we compile ROOT on a zillion different machines we do discover this kind of issues quickly, and that is also a reason why you should try to compile on as many platforms as possible).
Although using gcc, Apple has a different set of default warnings enabled in their version and that is why you get more warnings on MacOS X (like unused arguments, hiding, etc).
Thank you for this explanation. Meanwhile I have added “using” whenever necessary.
However, as you say, only modern compilers support it. Does M$ VC7 support it, too?
Sorrowly, I am not able to compile on many platforms, but menawhile I test my program also on FC4.
In the future I want to try M$ Visual C++ Toolkit 2003, which I have already installed.