Stack trace when trying to print the contents of a TString

I’m trying to do a very simple Hello World type example while trying to compile it outside of root and get it to run. I’ve managed to compile a considerably longer and more complicated thing (a little muon lifetime analysis project) just fine, so I don’t think it’s a problem with the environment/libraries/compiler, I think I’m just managing to do something wrong.

Here is the code:

#include <TString.h>
#include <iostream>

using namespace std;

int main() {
	TString outstring("Hello World");
	cout << outstring << endl;
	return 0;

I’m using the 5.15.06 release on Windows with Visual C++ 8.

I run the following commands:
vcvars32.bat (sets up my environment)
cl hello_world.cpp -c -I C:\root\include -Fohello_world.o
link hello_world.o -LIBPATH:C:\root\lib libCore.lib

and it compiles and links just fine. Yet when I run hello_world.exe, I get this:

=============== STACKTRACE ===============

================ Thread 0 ================
0xf53318 ??
0x2c3f608 ??

================ Thread 1 ================
libCore!`anonymous namespace’::HandleConsoleThread()
0xffffffffe87c8024 ??

================ Thread 2 ================

================ Thread 3 ================
libCore!`anonymous namespace’::GetProgramCounter()
0xffffffffff006aec ??

============= END STACKTRACE =============

I’m not sure what’s going on, but hopefully one of you guys can tell me!

Oh, and if I do a .L hello_world.cpp and then main() in CINT it works just fine.

Thanks for your help!

Create a TApplication object (see examples in $ROOTSYS/test).


First off, thank you very much for your help.

So, does that mean that I need to make a GUI-based application if I’m using a TString?

Also, I noticed after fiddling around in the $ROOTSYS/test folder that the TString.cxx also gives the same stack trace problem when compiled with the VC++ compiler.

After using the TApplication object, as you suggested, it no longer produces a stack trace; however, for future reference, does this mean that I need to stay away from using TString’s to produce output to the console, or is there something else that I can do to prevent the crash?


You must have something badly wrong in your environment. For this simple
program you do not need TApplication (I was assuming that your program contains more)
I have no problems doing (in my $ROOTSYS directory)

cl -c hollings.cxx -nologo -MD -GR -G5 -GX -Iinclude build/win/ -o hollings.exe hollings.obj lib/
Hello World


How weird :S. Are you using VC++ 8? Maybe it has something to do with a version conflict…

I had the Platform SDK in my include/lib path, so I removed it, and it still gives me the stack trace after compilation. Here’s what I did, just to make sure:

Copy/pasted the previous code into the $ROOTSYS directory (in order to mirror what you did as much as I could)

ran vcvars32.bat. Here is the contents of that, just for the record:


@SET FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework
@SET FrameworkVersion=v2.0.50727
@SET FrameworkSDKDir=C:\VS8\SDK\v2.0
@set DevEnvDir=C:\VS8\Common7\IDE
@set PATH=C:\VS8\Common7\IDE;C:\VS8\VC\BIN;C:\VS8\Common7\Tools;C:\VS8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\VS8\VC\VCPackages;C:\Program Files\Microsoft Platform SDK\Bin;%PATH%
@set INCLUDE=C:\VS8\VC\INCLUDE;C:\Program Files\Microsoft Platform SDK\Include;%INCLUDE%
@set LIB=C:\VS8\VC\LIB;C:\VS8\SDK\v2.0\lib;C:\Program Files\Microsoft Platform SDK\Lib;%LIB%
@set LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

Ran: cl hollings.cpp -nologo -MD -GR -G5 -GX -Iinclude /link lib\libCore.lib

and then ran hollings.exe. It gave me the same stack trace. I went back and manually set the LIB, LIBPATH and INCLUDE variables with only the completely necessary paths, and the same thing happened.

Are there any other environment things that could influence the program into dying like that?

Thanks again for your help!

Did you install ROOT yourself with VC++8?
You cannot run a version compiled with VC++7 on a system with VC++8.
You cannot mix code compiled in debug mode with code compiled in non-debug mode (yes, this is Microsoft).
We provide a tar file compiled in non-debug mode with VC++8 at


Ah! No, I just installed the binaries from here:

I just remembered seeing “works with Visual C++ 8.0” in the download link, and put out of my mind any possibility of incompatibility (oops).

I’ll try the tar file and get back to you with the results.

Thanks for your help!

The tar file worked great. Sorry it took so long to get back to you…final exams :confused: .