How to operate the port RS232 from ROOT under win?

Dear experts,

is there a way how to communicate from ROOT with the serial port RS232 under windows using WinAPI ?
I have written a ROOT GUI that is supposed to control precision position system MCL.This system is operated via RS232 serial port.
Thanks for your advice.
Best regards
Filip Krizek

You should use some dedicated library doing that.

let me mention a concrete example of a problem I am facing when trying to comunicate with RS232 from ROOT. The code looks like:

[code]#include <TCanvas.h>
#include <Windows.h>

int main() {

// We need to communicate with COM ports using HANDLE, COMSTAT, ...
HANDLE handle;
COMSTAT comstat;

// Some ROOT code
TCanvas *c = new TCanvas();


return 0;

When attempting to run this code with ROOT CINT this error appears:

[quote]ROOT 5.34/25 (v5-34-25@v5-34-25, Jan 12 2015, 15:29:06 on win32)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Processing main.cpp…
#error win32api.dll is not ready. Run ‘setup.bat’ in
%CINTSYSDIR%\lib\win32api d
irectory if you use WinNT/95.
*** Interpreter error recovered ***[/quote]

The file setup.bat was however not creared. Only the files setupbc.bat and setupsc.bat exist.

Do you happen to know where the problem could be?
Or is there other recommended way to establish communication with the serial port RS232 from ROOT?

Thanks for answer + best regards


[quote=“krizek”]Do you happen to know where the problem could be?[/quote]Well, you cannot simply try to execute this code with ROOT (e.g. ROOT doesn’t know anything about COMSTAT…).

[quote=“krizek”]Or is there other recommended way to establish communication with the serial port RS232 from ROOT?[/quote] There is no RS232 communication support in ROOT. You should create an application that uses ROOT and Windows specific code (e.g. RS232 code) together. And this is not a simple task…

Cheers, Bertrand.

Hello Bertrand,
when you say that I

did you have in mind that I should take ROOT libraries and link them to a common project in Microsoft Visual Studio? Is there any manual/tutorial how to do that?

                                Many thanks

Hi Filip,

No, there is no tutorial, you should simply create a solution, add $ROOTSYS/lib in the library path, add $ROOTSYS/include in the include path of Visual Studio, and then select the libraries you want to use, like any other project using external libraries… And since it depends on what you really want to do, and how you want to use ROOT, it is hard to tell precisely the way you should do it…

Cheers, Bertrand.