Link problem with ROOT::Math::Polynomial

The following line of code

ROOT::Math::Polynomial p(1.0,0.0,1.0);

compile and link ok under Visual C++ 8.0 in release mode. But it does not link ok in debug mode. I get the message:
1>TMuster.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function
"public: double const & __thiscall std::_Vector_const_iterator<double,class std::allocator >::operator*(void)const
" (??D?$_Vector_const_iterator@NV?$allocator@N@std@@@std@@QBEABNXZ)

I use ROOT v5.18/00 under Windows XP
Thanks for your help

Hi,

could you recompile your code with “-FIw32pragma.h”, please? I suspect that this is due to a mismatch in MS’s STL implementation - they change the function signatures in debug. Or the /MD vs. /MDd is not matching between ROOT and your builds; you should use root-config --cflagswhich should take care of it. If it’s none of that: could you post TMuster.cxx and the line used to compile and link?

Cheers, Axel.

3 points:

(1) - The code link ok in debug mode if I select /MDd instead of /MD
(2) - What do you mean by recompile your code with “-FIw32pragma.h” ? Do you mean with #input “-FIw32pragma.h” ? I have no file FIw32pragma.h on my computer
(3) - I join the code to this mail, restricted to the line not linking. You can try in in Visual C++ 8.0

Thanks a lot for your help
smuster.tar.gz (1.33 MB)

Hi,

OK so you found it! You have to compile your code with /MDd in debug more, or build ROOT with “./configure --build=debug --disable-winrtdebug”.

Cheers, Axel.

Yes, the code compile and link if I replace /MD by /MDd. But later on, when I try to debug the code, it crashes. In fact, for reasons I do not understand, ROOT::Math::Polynomial is unusable under Visual C++ in debug mode.
I do not compile and link ROOT on my PC. I use the binary version WindowsXP/NT/w2000 with VC++ 8.0, version 5.18/00 (good old tar file). It would be quite unhandy to switch from this ROOT version to the ROOT version compiled and linked in debug mode each time one switches from release to debug mode in Visual C++. There is something indigestible for Visual C++ in the code of ROOT::Math::Polynomial! This is unfortunate, since ROOT::Math::Polynomial has the possibility to find anatically the roots of the polynomial of 4th degree, which would be a big plus for my program Litrani.

Hi,

This is exactly what you have to do. The reason is Microsoft’s implementation of the runtime libs, which are incompatible between release and debug. So you cannot mix the lib used by root and the one used by your code - they have to be identical.

What you can do is build the debug version of you code with /MD. That requests the release version of the runtime library.

Cheers, Axel.

Since the problem only appears with ROOT::Math::Polynomial, I prefer to not use it and to keep the possibility to switch from debug to release mode without changing the ROOT version each time.
Many thanks for your help

Hi,

you do not have to switch ROOT versions, as I said you should be able to simply specify /MD even in a debug build of your code. And this runtime incompatibility will bite you in several cases, without any sensible error message or hints of what went wrong. E.g. anything using STL might fail or produce corrupted results. So I can really only recommend to do this properly…

Cheers, Axel.

No, in debug mode of Visual C++ and with the ROOT version not compiled in debug mode, the Visual C++ linker fails if I use /MD. If I use /MDd, I can compile and link, but the code crashes when I use it.
Interesting that you say it is coming from STL. In fact it is the first time I use something based upon STL. I will continue to avoid it!