[Windows] c file compiling

Hi pepe, I wrote this in the prompt

root.exe -l -n -q cors_plot.cxx < file-gamma.list

it worked but there is a problem, after few seconds it stopped, so it selected just few events (8 events)…


Hi,

You can simply compile it from a Visual Studio command prompt with the following commands (after renaming the file cors_plot.cpp). For release (optimized) mode:

For debug mode:

This will produce a cors_plot.exe application
N.B. You have to use the same configuration (debug/release) than ROOT itself.

Cheers, Bertrand.

Hi bellenote, thank but unfortuntaly it doesn’t work…i have an error (see attachment)…
Do you know the reason?

PS. In the command for linux/mac I know my teacher used Minuit, but I don’t have Minuit, do you think thi is the reason?

Two things:

First, don’t run in “C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC”, you don’t have write permissions there.

You could do what is shown in the screen capture (adapting to your version of Visual studio and the location of your installation of ROOT)


Then you said you were using Visual Studio 2013 and I see on your screenshot that you are using 2010, so if you have downloaded ROOT built with VS 2013, this is not going to work…

Cheers, Bertrand.

Hi bellenote, I 've root vc2010. I did as you showed me, so I compiled the file, but I’ve the same problem tha I had using the .cxx file of pepe le pew… I setted the file-gamma.list to seletct 300000 events (EAS induced by gamma) , but the software selects just 8 events…, I tried using other file too (EAS induced by proton) but now it selected just 2 events…

When I compiled, I had a warning

Destination of memory copy is too small 

Do you think this is the reason? Do you know the solution?
Thanks


In my private message, I’ve shown you some warnings that my compiler generated (the last three are real problems which should be fixed in the source code): [...]$ `root-config --cxx --cflags` -O2 -W -Wall -o cors_plot cors_plot.cxx `root-config --libs` cors_plot.cxx: In function ‘void pamafill()’: cors_plot.cxx:970:14: warning: unused variable ‘ipartyp’ [-Wunused-variable] const int ipartyp[202] = { ^ cors_plot.cxx:1017:9: warning: unused variable ‘chptext’ [-Wunused-variable] char chptext[][20] = {" ", ^ cors_plot.cxx: In function ‘int cors_plot(int)’: cors_plot.cxx:440:26: warning: array subscript is above array bounds [-Warray-bounds] pdata[numbthi] = zdata[0]; ^ cors_plot.cxx:400:63: warning: iteration 5734u invokes undefined behavior [-Waggressive-loop-optimizations] for( ii=0; ii<=numbstd; ii++ ) rdata[ii] = sdata[ii+1]; ^ cors_plot.cxx:400:10: note: containing loop for( ii=0; ii<=numbstd; ii++ ) rdata[ii] = sdata[ii+1]; ^ [...]$ The “Destination of memory copy is too small” warning is one of them (g++ issued “array subscript is above array bounds”).
The “cors_plot” may misbehave due to these problems (i.e. it is possible that you get fewer events than expected due to these unfixed problems).
I told you to forward my modified code to your supervisor. I assume, [s]he is expected to fix these problems.
Note that with my modifications, “cors_plot.cxx” can be used as both, a “Standalone Application” and a “ROOT Script”.
So, you can simply run (“root” or “root.exe”): root -l -n -q cors_plot.cxx < file-gamma.list or: root -l -n -q cors_plot.cxx++ < file-gamma.list When running ROOT 5, you can also use: root [0] .x cors_plot.cxx < file-gamma.list or: root [0] .x cors_plot.cxx++ < file-gamma.list
cors_plot.cxx (50 KB)

See also:
Compiler Warning (Level 1) C4789
And:
What does C4789 mean?

And as Pepe pointed out, you should fix those warning in your code first, and check with your supervisor. This is most probably not a ROOT issue…

thanks pepe and thanks belle note. But I have the root file created by my supervisor (compiling the cors_plot.c using MAC) and the root file has 30000 events as setted in the file-gamma.list… why doesn’t it have just 8 events?

PS Pepe what OS and what compiler did you use?

I use Linux with gcc 4.8.4 and 5.4.0 and they both give the same warnings when I try: `root-config --cxx --cflags` -O2 -W -Wall -o cors_plot cors_plot.cxx `root-config --libs`

My teacher isn’t the autor of the software, other teacher is. He wrote instructions to use it at CNAF (he saved the .outu files at CNAF) and to compile he wrote:

In the string there is the command -lMinuit, can it be the reason? have we to compile calling Minuit too? And yesterday an assistent of my supervisor wrote me:

[quote]You need that your compiler has all options of the string, especially Minuit (because I know you correct installed ROOT)[/quote], so maybe is it important to all Minuit too?

On Windows, if you omit a necessary library (like Minuit), the linker will complain (just try to remove libTree.lib from the list), so it is most probably not needed if the compiler doesn’t complain…
And to solve your issue you can use the Visual Studio Debugger:

But you need to know how to debug code…

The “cors_plot.cxx” source code does not use Minuit at all, so the library is not needed.
If your supervisor is not the author, then contact the original guy.

This is so strange…I don’t understand the reason because my teacher compiled without problems…
I tried the debug using visual studio c++ express. When I started it I had the warning in the attachent and i clicked on YES. Now it is still runnning but it is so much time that it doesn’t write on the log. Untill now it wrote this

[quote]‘cors_plot.exe’: Loaded ‘C:\Users\user\Documents\Visual Studio 2010\Projects\cors_plot\Debug\cors_plot.exe’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\ntdll.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\kernel32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\KernelBase.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libRIO.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libCore.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libHist.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\msvcp100.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\msvcr100.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\user32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\gdi32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\shell32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\msvcrt.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libCint.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libThread.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libMatrix.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\cfgmgr32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\windows.storage.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\combase.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\rpcrt4.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\sspicli.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\cryptbase.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libMathCore.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\bcryptprimitives.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\sechost.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\advapi32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\shlwapi.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\kernel.appcore.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\SHCore.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\powrprof.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\profapi.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\oleaut32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\IPHLPAPI.DLL’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\wsock32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\ws2_32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\liblzma.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\imm32.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmm.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmmbase.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Unloaded ‘C:\Windows\SysWOW64\winmmbase.dll’
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmmbase.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmmbase.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Unloaded ‘C:\Windows\SysWOW64\winmmbase.dll’
‘cors_plot.exe’: Unloaded ‘C:\Windows\SysWOW64\winmmbase.dll’
‘cors_plot.exe’: Unloaded ‘C:\Windows\SysWOW64\winmm.dll’
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\nsi.dll’, Cannot find or open the PDB file
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\dhcpcsvc.dll’, Cannot find or open the PDB file
The thread ‘Win32 Thread’ (0x1c1c) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x1c18) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x1bc0) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x1f2c) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x12f8) has exited with code 0 (0x0).
[/quote]


Well, you can try to rebuild your code with debug information (if you’re lucky it will work…):

And don’t worry about those messages, they just tell you that there is no debug information for those libraries.

Now this is the log (I stopped it for error!)

[quote]‘cors_plot.exe’: Loaded ‘C:\Users\Casaburo\Documents\Visual Studio 2010\Projects\cors_plot\Debug\cors_plot.exe’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\ntdll.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\kernel32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\KernelBase.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libRIO.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libCore.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libHist.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\msvcp100.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\msvcr100.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\user32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\gdi32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\shell32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\msvcrt.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libCint.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libThread.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libMatrix.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\cfgmgr32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\windows.storage.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\combase.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\rpcrt4.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\sspicli.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\cryptbase.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\libMathCore.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\bcryptprimitives.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\sechost.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\advapi32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\shlwapi.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\kernel.appcore.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\SHCore.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\powrprof.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\profapi.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\oleaut32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\IPHLPAPI.DLL’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\wsock32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\ws2_32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\root_v5.34.36\bin\liblzma.dll’, Binary was not built with debug information.
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\imm32.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmm.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmmbase.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Unloaded ‘C:\Windows\SysWOW64\winmmbase.dll’
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmmbase.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmmbase.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Unloaded ‘C:\Windows\SysWOW64\winmmbase.dll’
‘cors_plot.exe’: Unloaded ‘C:\Windows\SysWOW64\winmmbase.dll’
‘cors_plot.exe’: Unloaded ‘C:\Windows\SysWOW64\winmm.dll’
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\nsi.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\dhcpcsvc.dll’, Cannot find or open the PDB file
The thread ‘Win32 Thread’ (0x1c1c) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x1c18) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x1bc0) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x1f2c) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x12f8) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x1db4) has exited with code 0 (0x0).
The thread ‘Win32 Thread’ (0x11a0) has exited with code -1073741510 (0xc000013a).
The thread ‘Win32 Thread’ (0x6ac) has exited with code -1073741510 (0xc000013a).
‘cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmm.dll’, Cannot find or open the PDB file
’cors_plot.exe’: Loaded ‘C:\Windows\SysWOW64\winmmbase.dll’, Cannot find or open the PDB file
The thread ‘Win32 Thread’ (0x192c) has exited with code -1073741749 (0xc000004b).
The program ‘[5176] cors_plot.exe: Native’ has exited with code -1073741510 (0xc000013a).
[/quote]

Now I try you compiling again with the debug (but usually I’m not lucky!)!

-------------------UPDATE-------------
Well I treid with the debug, but as I knew…I’m not lucky

[quote=“faca87”]-------------------UPDATE-------------
Well I treid with the debug, but as I knew…I’m not lucky[/quote]What do you mean?

And if you want us to help you, please provide everything needed to run your application. Otherwise I’m afraid you will need to debug it yourself… (you can also take the debug version of ROOT)

[quote=“bellenot”][quote=“faca87”]-------------------UPDATE-------------
Well I treid with the debug, but as I knew…I’m not lucky[/quote]What do you mean?[/quote]
I mean that i tried to compile using

cl -nologo -Z7 -MD -GR -EHsc cors_plot.cpp -I %ROOTSYS%\include /link -debug -LIBPATH:%ROOTSYS%\lib libCore.lib libHist.lib libGpad.lib libRIO.lib libTree.lib but I had the same problem (the warnig and just 8 events selected)

[quote=“bellenot”]And if you want us to help you, please provide everything needed to run your application. Otherwise I’m afraid you will need to debug it yourself… (you can also take the debug version of ROOT)[/quote] Sorry, i closed the debug clicking for error (I didn’t want to click it…) so now I started again the debugginng, when it will finsh I will copy here all the log

I was thinking that my supervisor compiled the file .c; we are compiling a .cpp file and a .cxx file, is it possibile that this is the reason so it doesn’t work fine?

No it doesn’t matter. On Windows, if you don’t want to add a /Tp (compile as C++) compilation flag, changing the extension of a .c file as .cpp just tells the compiler to compile it as C++ code (instead of C)

Well, maybe the author just wants we buy a mac :slight_smile: