Help needed writing LinkDef.h

I have again, thanks to Axel’s help, been able to create a dictionary for netCDF and produce a loadable netcdf.so.

Thinking that since the AIA ANDI interface for mass spec files uses netcdf also, it seems the easiest way to get access to ANDI functions in ROOT would be to create one dictionary using the header files from ANDI and the required netCDF header files included in that one dictionary.

I do not understand how to create #pragmas for some of the constructs in the header files.

I am including my attempt along with errors from rootcint.

Please understand that I realize that this is copyrighted software, I removed those notices to reduce the size of the files and how much passed throught rootcint.

I would appreciate any help on how to write the pragmas. I can continue from an example.

I dont understand from the #pragma file showing all pragmas how to include a function. I would like the write code to open ANDI netCDF files using cint. Do I only need to put in LinkDef.h the exported functions?
ms10aux.c (24.2 KB)
ms10io.h (36.7 KB)
ms10.h (26.1 KB)
andi_toedit.txt (180 KB)
andi_edited.txt (80.1 KB)
rootcinterrors.txt (29 KB)

Hi,

could you replace the offsetof macro by code(&(((s_name*)64))->m_name)-64[/code] Line 996 of your Linkdef.h: you cannot have a #pragma statement spanning multiple lines. And remove all code from the Linkdef file; no function definition should be in there. This: root.cern.ch/viewcvs/trunk/hist/ … iew=markup is what a common Linkdef.h file looks like. And I have no idea what “#pragma link C++ function typedef struct” (line 1094) was meant to do :slight_smile: It’s not a function you try to link - it’s a typedef. CINT does not want to see the definition of the struct or anything else (those should be in the regular package’s header files that you also pass to rootcint). It just needs the “#pragma link C++ typdef EnumLiteral”. Also have a look at the Users Guide, ch 15, “Adding a Class with a Shared Library”.

Let us know if rootcint still complains after fixing these errors!

Cheers, Axel.

I altered my andi_LinkDef.h to use #pragma link C++ struct as was done by
Christian Holm Christensen in the LinkDef.h of HIJING. I get the following (edited)
errors, which I have matched to the ms10io.h line numbers.

]$ rootcint -f G__andi.cxx -c -p -I. -I/usr/local/include -I/opt/cern/root/include netcdfcpp.h ms10.h ms10io.h andi_LinkDef.h
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:315:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:316:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:317:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:318:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:319:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:320:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:321:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:322:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:323:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:324:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:325:
Error: illegal pointer to class object ((MS_Variables*)0) 0x0 139 ms10io.h:341:
Error: illegal pointer to class object ((MS_Admin_Data*)0) 0x0 129 ms10io.h:342:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:343:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:344:
Error: illegal pointer to class object ((MS_Variables*)0) 0x0 139 ms10io.h:352:
Error: illegal pointer to class object ((MS_Raw_Per_Scan*)0) 0x0 134 ms10io.h:354:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:355:
Error: illegal pointer to class object ((MS_Variables*)0) 0x0 139 ms10io.h:356:
Error: illegal pointer to class object ((MS_Raw_Per_Scan*)0) 0x0 134 ms10io.h:358:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:359:
Error: illegal pointer to class object ((MS_Variables*)0) 0x0 139 ms10io.h:360:
Error: illegal pointer to class object ((MS_Raw_Per_Scan*)0) 0x0 134 ms10io.h:362:
Error: illegal pointer to class object ((MS_Dimensions*)0) 0x0 138 ms10io.h:363:
Error: illegal pointer to class object ((MS_Variables*)0) 0x0 139 ms10io.h:364:

.
.
.

Error: illegal pointer to class object ((MS_Raw_Data_Global*)0) 0x0 133 ms10io.h:840:
Error: illegal pointer to class object ((MS_Raw_Data_Global*)0) 0x0 133 ms10io.h:842:
Error: illegal pointer to class object ((MS_Raw_Data_Global*)0) 0x0 133 ms10io.h:844:
Error: illegal pointer to class object ((MS_Raw_Data_Global*)0) 0x0 133 ms10io.h:846:
Error: illegal pointer to class object ((MS_Raw_Data_Global*)0) 0x0 133 ms10io.h:848:
Error: illegal pointer to class object ((MS_Raw_Data_Global*)0) 0x0 133 ms10io.h:850:
Error: illegal pointer to class object ((MS_Raw_Data_Global*)0) 0x0 133 ms10io.h:852:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing G__andi.cxx G__andi.h !!!
Error: rootcint: error loading headers…

314 static MS_Dimension_Data ms_dimensions[] = {
315 { offsetof( MS_Dimensions, _2_byte_dim ), “_2_byte_string”, 2L },
316 { offsetof( MS_Dimensions, _4_byte_dim ), “_4_byte_string”, 4L },
317 { offsetof( MS_Dimensions, _8_byte_dim ), “_8_byte_string”, 8L },
318 { offsetof( MS_Dimensions, _16_byte_dim ), “_16_byte_string”, 16L },
319 { offsetof( MS_Dimensions, _32_byte_dim ), “_32_byte_string”, 32L },
320 { offsetof( MS_Dimensions, _64_byte_dim ), “_64_byte_string”, 64L },
321 { offsetof( MS_Dimensions, _128_byte_dim ), “_128_byte_string”, 128L },
322 { offsetof( MS_Dimensions, _255_byte_dim ), “_255_byte_string”, 255L },
323 { offsetof( MS_Dimensions, range_dim ), “range”, 2L },
324 { offsetof( MS_Dimensions, point_number_dim ), “point_number”, NC_UNLIMITED },
325 { offsetof( MS_Dimensions, error_number_dim ), “error_number”, 1L }

340 static MS_Variable_Data error_variables[] = {
341 { offsetof( MS_Variables, error_log_id ), “error_log”, NC_CHAR,
342 (long)offsetof( MS_Admin_Data, error_log ), 2,
343 { (long)offsetof( MS_Dimensions, error_number_dim ),
344 (long)offsetof( MS_Dimensions, _64_byte_dim ) }}
345 };

I am using netcdfcpp.h, which then included netcdf.h.

g++ -Wall -O2 -c ms10aux.c
g++ -Wall -O2 -c ms10enum.c
g++ -Wall -O2 -c msio.h

all compile with out any warnings.

I am using ROOT 5.19.02, that I compiled on my Fedora 6 coLInux machine.

I have no idea how to write the LinkDef.h for this or what the errors mean. I removed
all #pragma link C++ function thinking with these errors corrected I could try to add
that later.

Thank you in advance for any help.

I discovered the link function problem earlier; I guess a paste that went to the wrong place.
rootcinterrors.txt (25.9 KB)
andi_LinkDef.h (8.98 KB)

Hi,

I don’t think you changed the offsetof macro as I suggested?

Cheers, Axel.

Well I tried. I didnt understand what you meant.

I’m beginning to think that biologists just cant use Physic software.

Reading Chapter 15 as you suggested, perhaps I am not listing things in the LinkDef.h in the proper order? Does the listing of xxx.h files preceeding LinkDef.h matter?

I didnt understand how to change that offset other than what I did.

Sorry if you think I am wasting your time. It is possible that I used a different version of the file andi_LinkDef.h and I changed it but not here.

Hi,

uh, OK, I see where you tried now :slight_smile: I’m very happy to help you to get this working - every time you get stuck it means we didn’t succeed explaining how it works, so it’s really our fault!

The LinkDef.h file only needs to contain #pragma statements, no CPP macro or function of whatever definitions. All definitions are read from the include files that you pass to rootcint on the command line before LinkDef.h. Think of rootcint parsing all header files (so it knows all types and functions etc) and then you tell it with the #pragma statements in the LinkDef.h file which entities you want to have accessible through the interpreter (or for I/O). So I cannot decide which functions should have a #pragma statement: it’s up to you: which variables, which functions, which classes should be accessible to the user? Objects of which classes should be enabled for I/O?

#pragma link statements have the format
#pragma link C++ class classname+;
#pragma link C++ enum enumname;
#pragma link C++ global varname;
#pragma link C++ function globalfuncname(type_of_parameters);
(and a few more)

I saw that you changed the offsetof macro - but it’s read from the regular include file ms10io.h, and that is where you need to change it. I have attached fixed versions of ms10io.h and andi_LinkDef.h. Called with “rootcint -f ms10_dict.cxx -c ms10.h ms10io.h andi_LinkDef.h” I now get errors on unknown NC_CHAR (and similar), nc_type, and unknown class NcFile (plus more classes). I assume that this is due to me not having access to one of the header files that are needed to this to compile. You will have to pass the header files containing the definition of these entities to rootcint (or remove the classes’ #pragma statements if you determine that they are not needed by the users).

Let me know how it works out for you!

Cheers, Axel.
ms10io.h (36.7 KB)
andi_LinkDef.h (9.8 KB)

Thank you.

You wrote:
"I now get errors on unknown NC_CHAR (and similar), nc_type, and unknown class NcFile (plus more classes). I assume that this is due to me not having access to one of the header files that are needed to this to compile.
"
Those are in the netcdfcpp.h header, from netCDF, what I was trying to adapt in February and you fixed the errors for me. That is the netCDF C++ interface, which, using classes, I had no problem finding in the code and including in the LinkDef.h. ANDI (ANalytical Data Interchange) is built on netCDF-2, which did not have a C++ interface yet. I have wondered if I need to write LinkDef.h #pragmas for netcdf.h, which is included in netcdfcpp.h. I’ll soon discover if I do. Why eventually I thought one dictionary was what I needed.

I hope to use the file open, read, etc functions from cint. If I can get something working, I can then add them, I hope.

Reading Chapter 15, I wondered if perhaps the order of inclusion is incorrect from netcdfcpp.h to ms10.h ms10io.h and that if that was part of my problem. Again, I’ll see when I can test this.

Again, thank you. I had hoped to find someone in town using ROOT, but no one I meet in Physics seems to even know what it is.

Using andi_LinkDef.h as you wrote it and the modified ms10io.h: (all netCDF and ANDI *.h files are in the working directory, thus -I.)

$ rootcint -f 26_dict.cxx -c -p -I. -I/opt/cern/root/include netcdfcpp.h ms10.h ms10io.h andi_LinkDef.h
Segmentation fault

produced 26_dict.cxx and 26_dict.h. Compilation (using the command provided to me by CHC) results in:

$ g++ root-config --cflags -c -I. 26_dict.cxx
26_dict.cxx: In function GÇÿvoid G__set_cpp_environment26_dict()GÇÖ:
26_dict.cxx:21: error: expected `}’ at end of input

The following to test if order of ms10.h ms10io.h matter, apparently it does.

$ rootcint -f 26_dict1.cxx -c -p -I. -I/opt/cern/root/include netcdfcpp.h ms10io.h ms10.h andi_LinkDef.h
Error: Symbol ms_admin_expt_texpt_type is not defined in current scope ms10io.h:242:
Error: Symbol ms_data_format_tmass_type is not defined in current scope ms10io.h:243:
Error: Symbol ms_data_format_ttime_type is not defined in current scope ms10io.h:244:
Error: Symbol ms_data_format_tinty_type is not defined in current scope ms10io.h:245:
Error: Symbol ms_data_format_tms_fmt is not defined in current scope ms10io.h:255:
Error: Symbol data_short is not defined in current scope ms10io.h:256:
Error: Symbol data_long is not defined in current scope ms10io.h:257:
Error: Symbol data_float is not defined in current scope ms10io.h:258:
Error: Symbol data_double is not defined in current scope ms10io.h:259:
Segmentation fault

I dont know what ‘Segmentation fault’ means. This is closer to success than I have ever been.

When trying to compile the dict.cxx file:

$ g++ root-config --cflags -I. 26_dict1.cxx
./ms10io.h:231: error: GÇÿms_admin_expt_tGÇÖ does not name a type
./ms10io.h:232: error: GÇÿms_data_format_tGÇÖ does not name a type
./ms10io.h:233: error: GÇÿms_data_format_tGÇÖ does not name a type
./ms10io.h:234: error: GÇÿms_data_format_tGÇÖ does not name a type
./ms10io.h:255: error: GÇÿms_data_format_tGÇÖ does not name a type
./ms10io.h:256: error: GÇÿdata_shortGÇÖ was not declared in this scope
./ms10io.h:257: error: GÇÿdata_longGÇÖ was not declared in this scope
./ms10io.h:258: error: GÇÿdata_floatGÇÖ was not declared in this scope
./ms10io.h:259: error: GÇÿdata_doubleGÇÖ was not declared in this scope
./ms10io.h:259: error: too many initializers for GÇÿGÇÖ
./ms10io.h:259: error: too many initializers for GÇÿGÇÖ
./ms10io.h:259: error: too many initializers for GÇÿGÇÖ
./ms10io.h:259: error: too many initializers for GÇÿGÇÖ
./ms10io.h:344: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:344: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:356: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:356: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:360: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:360: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:364: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:364: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:368: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:368: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:372: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:372: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:376: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:376: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:380: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:380: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:384: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:384: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:387: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:387: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:390: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:390: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:393: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:393: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:396: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:396: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:407: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:407: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:411: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:411: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:415: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:415: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:420: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:420: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:425: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:425: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:437: error: expected primary-expression before GÇÿlongGÇÖ
./ms10io.h:437: error: expected )' before GÇÿlongGÇÖ ./ms10io.h:442: error: expected primary-expression before GÇÿlongGÇÖ ./ms10io.h:442: error: expected)’ before GÇÿlongGÇÖ
./ms10io.h:447: error: expected primary-expression before GÇÿlongGÇÖ
.
.
.
.
./ms10io.h:850: error: expected type-specifier before GÇÿMS_Raw_Data_GlobalGÇÖ
./ms10io.h:850: error: expected ,' before GÇÿMS_Raw_Data_GlobalGÇÖ ./ms10io.h:850: error: expected)’ before GÇÿ,GÇÖ token
./ms10io.h:852: error: expected type-specifier before GÇÿMS_Raw_Data_GlobalGÇÖ
./ms10io.h:852: error: expected ,' before GÇÿMS_Raw_Data_GlobalGÇÖ ./ms10io.h:852: error: expected)’ before GÇÿ,GÇÖ token
./ms10io.h:854: error: expected type-specifier before GÇÿMS_Raw_Data_GlobalGÇÖ
./ms10io.h:854: error: expected ,' before GÇÿMS_Raw_Data_GlobalGÇÖ ./ms10io.h:854: error: expected)’ before GÇÿ,GÇÖ token
26_dict1.cxx: In function GÇÿvoid G__set_cpp_environment26_dict1()GÇÖ:
26_dict1.cxx:21: error: expected `}’ at end of input

Placing netcdfcpp.h after ms10*.h results in:
$ rootcint -f 26_dict2.cxx -c -p -I. -I/opt/cern/root/include ms10.h ms10io.h netcdfcpp.h andi_LinkDef.h
Error: Symbol nc_typecdf_type is not defined in current scope ms10io.h:254:
Error: Symbol NC_SHORT is not defined in current scope ms10io.h:256:
Error: Symbol NC_LONG is not defined in current scope ms10io.h:257:
Error: Symbol NC_FLOAT is not defined in current scope ms10io.h:258:
Error: Symbol NC_DOUBLE is not defined in current scope ms10io.h:259:
Error: Symbol nc_typedatatype is not defined in current scope ms10io.h:295:
Error: Symbol nc_typedatatype is not defined in current scope ms10io.h:306:
Error: Symbol NC_UNLIMITED is not defined in current scope ms10io.h:326:
Segmentation fault

Compiling 26_dict3.cxx results in pretty much the same errors as above.

So order matters!!
The andi_LinkDef.h that you edited ALMOST works. How do I trace the segmentation fault? That seems to be prematurely ending rootcint before the dict file is completely written.

Hi,

yes, that’s pretty close to success :slight_smile: The problem with your headers is that they require a certain inclusion order. That’s bad; those headers should be fixed by their maintainers. If a headers A.h requires types defined in B.h it should either #include B.h or forward declare those types.

Now, assuming that you did in fact put the header files the correct order to work around that problem, rootcint seems to not be able to process it :-/ “Segmentation fault” means that rootcint attempted to execute an illegal instruction (aka crashed). I will need to have a look at what caused it and fix it; I am on vacation until Wed next week, so this might be a bit slow.

The output file cannot be compiled (“missing }”) because it wasn’t written out completely; rootcint stopped writing when it crashed. So I’m afraid you’ll have to wait for us to make some progress.

Cheers, Axel.

The same error problems are occuring with ROOT 5.19.04, which I compiled recently on the following
machine:

$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /cardhu.b/gnatmail/release-gpl/build-cardhu/src/configure --prefix=/usr/gnat
–enable-languages=c,ada --disable-nls --disable-libada --target=i686-pc-linux-gnu
–host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --enable-checking=release --enable-threads=posix
Thread model: posix
gcc version 4.1.3 20070403 for GNAT GPL 2007 (20070402)

$ uname -a
Linux nulinux 2.6.22.18-co-0.8.0 #1 PREEMPT Sat Mar 29 14:40:10 UTC 2008 i686 i686 i386 GNU/Linux

After reading some more of ROOTTALK I discovered an answer suggesting the use of valgrind. Here is
the output, and again using the -v and --show-reachable=yes options as suggested by valgrind.

I have read about undoDB (undo-software.com), which can step backwards in a program. I am not paid to program and so could
download for free, but I’m not sure I would then know how to use it or what the data might mean.

The aborted 05andi.cxx and 05andi.h files are at the bottom, if where they end is of any help.

Thank you.

$ rootcint -f 05andi.cxx -c -p -I. -I/opt/cern/root/include netcdfcpp.h ms10.h ms10io.h
andi_LinkDef.h
Segmentation fault

$ valgrind rootcint -f 05andi.cxx -c -p -I. -I/opt/cern/root/include netcdfcpp.h ms10.h
ms10io.h andi_LinkDef.h
==2946== Memcheck, a memory error detector.
==2946== Copyright © 2002-2006, and GNU GPL’d, by Julian Seward et al.
==2946== Using LibVEX rev 1658, a library for dynamic binary translation.
==2946== Copyright © 2004-2006, and GNU GPL’d, by OpenWorks LLP.
==2946== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==2946== Copyright © 2000-2006, and GNU GPL’d, by Julian Seward et al.
==2946== For more details, rerun with: -v
==2946==
==2946== Invalid read of size 4
==2946== at 0x41AD5C6: G__getvariable (in /opt/cern/root/lib/libCint.so)
==2946== by 0x41B5160: G__getstructmem (in /opt/cern/root/lib/libCint.so)
==2946== by 0x40BF371: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2946== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2946== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2946== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2946== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2946== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2946== by 0x40BFFB3: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2946== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2946== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2946== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2946== Address 0x40 is not stack’d, malloc’d or (recently) free’d
==2946==
==2946== Process terminating with default action of signal 11 (SIGSEGV)
==2946== Access not within mapped region at address 0x40
==2946== at 0x41AD5C6: G__getvariable (in /opt/cern/root/lib/libCint.so)
==2946== by 0x41B5160: G__getstructmem (in /opt/cern/root/lib/libCint.so)
==2946== by 0x40BF371: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2946== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2946== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2946== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2946== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2946== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2946== by 0x40BFFB3: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2946== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2946== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2946== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2946==
==2946== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 20 from 1)
==2946== malloc/free: in use at exit: 576,853 bytes in 11,902 blocks.
==2946== malloc/free: 17,804 allocs, 5,902 frees, 1,494,517 bytes allocated.
==2946== For counts of detected errors, rerun with: -v
==2946== searching for pointers to 11,902 not-freed blocks.
==2946== checked 4,319,248 bytes.
==2946==
==2946== LEAK SUMMARY:
==2946== definitely lost: 0 bytes in 0 blocks.
==2946== possibly lost: 738 bytes in 28 blocks.
==2946== still reachable: 576,115 bytes in 11,874 blocks.
==2946== suppressed: 0 bytes in 0 blocks.
==2946== Reachable blocks (those to which a pointer was found) are not shown.
==2946== To see them, rerun with: --show-reachable=yes
Segmentation fault

$ valgrind -v --show-reachable=yes rootcint -f -5andi.cxx -c -p -I. -I/opt/cern/root/include
netcdfcpp.h ms10.h ms10io.h andi_LinkDef.h
==2952== Memcheck, a memory error detector.
==2952== Copyright © 2002-2006, and GNU GPL’d, by Julian Seward et al.
==2952== Using LibVEX rev 1658, a library for dynamic binary translation.
==2952== Copyright © 2004-2006, and GNU GPL’d, by OpenWorks LLP.
==2952== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==2952== Copyright © 2000-2006, and GNU GPL’d, by Julian Seward et al.
==2952==
–2952-- Command line
–2952-- rootcint
–2952-- -f
–2952-- -5andi.cxx
–2952-- -c
–2952-- -p
–2952-- -I.
–2952-- -I/opt/cern/root/include
–2952-- netcdfcpp.h
–2952-- ms10.h
–2952-- ms10io.h
–2952-- andi_LinkDef.h
–2952-- Startup, with flags:
–2952-- -v
–2952-- --show-reachable=yes
–2952-- Contents of /proc/version:
–2952-- Linux version 2.6.22.18-co-0.8.0 (hn@hn-dt) (gcc version 4.2.1 (SUSE Linux)) #1 PREEMPT Sat Mar 29 14:40:10 UTC 2008
–2952-- Arch and hwcaps: X86, x86-sse1-sse2
–2952-- Valgrind library directory: /usr/lib/valgrind
–2952-- Reading syms from /opt/cern/root/bin/rootcint (0x8048000)
–2952-- Reading syms from /usr/lib/valgrind/x86-linux/memcheck (0x38000000)
–2952-- object doesn’t have a dynamic symbol table
–2952-- Reading syms from /lib/ld-2.5.so (0x4FFA2000)
–2952-- Reading suppressions file: /usr/lib/valgrind/default.supp
–2952-- REDIR: 0x4FFB70F0 (index) redirected to 0x38027D0F (vgPlain_x86_linux_REDIR_FOR_index)
–2952-- Reading syms from /usr/lib/valgrind/x86-linux/vgpreload_core.so (0x4001000)
–2952-- Reading syms from /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so (0x4003000)
==2952== WARNING: new redirection conflicts with existing – ignoring it
–2952-- new: 0x4FFB70F0 (index ) R-> 0x040060C0 index
–2952-- REDIR: 0x4FFB7290 (strlen) redirected to 0x4006290 (strlen)
–2952-- Reading syms from /opt/cern/root/lib/libCint.so (0x4009000)
–2952-- Reading syms from /lib/libdl-2.5.so (0x41127000)
–2952-- Reading syms from /usr/lib/libstdc++.so.6.0.8 (0x41F9D000)
–2952-- object doesn’t have a symbol table
–2952-- Reading syms from /lib/libm-2.5.so (0x410FE000)
–2952-- Reading syms from /lib/libgcc_s-4.1.1-20061011.so.1 (0x41EF0000)
–2952-- object doesn’t have a symbol table
–2952-- Reading syms from /lib/libc-2.5.so (0x4FFBF000)
–2952-- REDIR: 0x5002B640 (rindex) redirected to 0x4005FA0 (rindex)
–2952-- REDIR: 0x5002C4E0 (memset) redirected to 0x4006580 (memset)
–2952-- REDIR: 0x5002B2A0 (strlen) redirected to 0x4006270 (strlen)
–2952-- REDIR: 0x42052D00 (operator new(unsigned)) redirected to 0x4005B19 (operator new(unsigned))
–2952-- REDIR: 0x5002C9D0 (memcpy) redirected to 0x4006C60 (memcpy)
–2952-- REDIR: 0x5002B490 (strncmp) redirected to 0x40062D0 (strncmp)
–2952-- REDIR: 0x50026CB0 (malloc) redirected to 0x400537B (malloc)
–2952-- REDIR: 0x500284C0 (free) redirected to 0x4004F95 (free)
–2952-- REDIR: 0x5002ADB0 (strcpy) redirected to 0x40069F0 (strcpy)
–2952-- REDIR: 0x500269B0 (calloc) redirected to 0x40046A8 (calloc)
–2952-- REDIR: 0x5002B590 (strncpy) redirected to 0x4006DE0 (strncpy)
–2952-- REDIR: 0x42051850 (operator delete(void*)) redirected to 0x4004CAC (operator delete(void*))
–2952-- REDIR: 0x5002AA20 (strcat) redirected to 0x4006660 (strcat)
–2952-- REDIR: 0x5002ABD0 (index) redirected to 0x4006090 (index)
–2952-- REDIR: 0x5002B350 (strnlen) redirected to 0x4006240 (strnlen)
–2952-- REDIR: 0x500286B0 (realloc) redirected to 0x400542A (realloc)
–2952-- REDIR: 0x5002AD40 (strcmp) redirected to 0x4006340 (strcmp)
–2952-- Reading syms from /opt/cern/root/cint/cint/include/stdfunc.dll (0x45D0000)
–2952-- REDIR: 0x4FFB7650 (stpcpy) redirected to 0x4006830 (stpcpy)
–2952-- REDIR: 0x5002C6D0 (stpcpy) redirected to 0x4006910 (stpcpy)
–2952-- REDIR: 0x5002BFE0 (memchr) redirected to 0x4006460 (memchr)
==2952== Invalid read of size 4
==2952== at 0x41AD5C6: G__getvariable (in /opt/cern/root/lib/libCint.so)
==2952== by 0x41B5160: G__getstructmem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BF371: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BFFB3: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== Address 0x40 is not stack’d, malloc’d or (recently) free’d
==2952==
==2952== Process terminating with default action of signal 11 (SIGSEGV)
==2952== Access not within mapped region at address 0x40
==2952== at 0x41AD5C6: G__getvariable (in /opt/cern/root/lib/libCint.so)
==2952== by 0x41B5160: G__getstructmem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BF371: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BFFB3: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952==
==2952== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 20 from 1)
==2952==
==2952== 1 errors in context 1 of 1:
==2952== Invalid read of size 4
==2952== at 0x41AD5C6: G__getvariable (in /opt/cern/root/lib/libCint.so)
==2952== by 0x41B5160: G__getstructmem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BF371: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BFFB3: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== by 0x4095741: G__getitem (in /opt/cern/root/lib/libCint.so)
==2952== by 0x409C719: G__getexpr (in /opt/cern/root/lib/libCint.so)
==2952== by 0x40BF1FD: G__getfunction (in /opt/cern/root/lib/libCint.so)
==2952== Address 0x40 is not stack’d, malloc’d or (recently) free’d
–2952–
–2952-- supp: 20 Fedora-Core-6-hack3-ld25
==2952==
==2952== IN SUMMARY: 1 errors from 1 contexts (suppressed: 20 from 1)
==2952==
==2952== malloc/free: in use at exit: 576,853 bytes in 11,902 blocks.
==2952== malloc/free: 17,804 allocs, 5,902 frees, 1,494,517 bytes allocated.
==2952==
==2952== searching for pointers to 11,902 not-freed blocks.
==2952== checked 4,319,236 bytes.
==2952==
==2952== LEAK SUMMARY:
==2952== definitely lost: 0 bytes in 0 blocks.
==2952== possibly lost: 738 bytes in 28 blocks.
==2952== still reachable: 576,115 bytes in 11,874 blocks.
==2952== suppressed: 0 bytes in 0 blocks.
–2952-- memcheck: sanity checks: 257 cheap, 11 expensive
–2952-- memcheck: auxmaps: 0 auxmap entries (0k, 0M) in use
–2952-- memcheck: auxmaps: 0 searches, 0 comparisons
–2952-- memcheck: SMs: n_issued = 74 (1184k, 1M)
–2952-- memcheck: SMs: n_deissued = 0 (0k, 0M)
–2952-- memcheck: SMs: max_noaccess = 65535 (1048560k, 1023M)
–2952-- memcheck: SMs: max_undefined = 0 (0k, 0M)
–2952-- memcheck: SMs: max_defined = 129 (2064k, 2M)
–2952-- memcheck: SMs: max_non_DSM = 74 (1184k, 1M)
–2952-- memcheck: max sec V bit nodes: 2 (0k, 0M)
–2952-- memcheck: set_sec_vbits8 calls: 6 (new: 2, updates: 4)
–2952-- memcheck: max shadow mem size: 1488k, 1M
–2952-- translate: fast SP updates identified: 11,325 ( 90.8%)
–2952-- translate: generic_known SP updates identified: 712 ( 5.7%)
–2952-- translate: generic_unknown SP updates identified: 423 ( 3.3%)
–2952-- tt/tc: 85,763 tt lookups requiring 93,134 probes
–2952-- tt/tc: 85,763 fast-cache updates, 3 flushes
–2952-- transtab: new 14,800 (368,172 -> 5,517,521; ratio 149:10) [0 scs]
–2952-- transtab: dumped 0 (0 -> ??)
–2952-- transtab: discarded 8 (189 -> ??)
–2952-- scheduler: 25,763,202 jumps (bb entries).
–2952-- scheduler: 257/115,200 major/minor sched events.
–2952-- sanity: 258 cheap, 11 expensive checks.
–2952-- exectx: 30,011 lists, 2,983 contexts (avg 0 per list)
–2952-- exectx: 23,711 searches, 21,168 full compares (892 per 1000)
–2952-- exectx: 0 cmp2, 62 cmp4, 0 cmpAll
Segmentation fault

more 05andi.cxx
/********************************************************

  • 05andi.cxx
  • CAUTION: DON’T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED
  •      FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX().
    
  •      CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE.
    

********************************************************/
#include “05andi.h” //newlink 3678

#ifdef G__MEMTEST
#undef malloc
#undef free
#endif

#if defined(GNUC) && (GNUC > 3) && (GNUC_MINOR > 1)
#pragma GCC diagnostic ignored “-Wstrict-aliasing”
#endif

extern “C” void G__cpp_reset_tagtable05andi();

extern “C” void G__set_cpp_environment05andi() {
G__add_compiledheader("/tmp/rootcint_Gqo1dz.h");

$ more 05andi.h
/********************************************************************

  • 05andi.h
  • CAUTION: DON’T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED
  •      FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX().
    
  •      CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE.
    

********************************************************************/
#ifdef CINT
#error 05andi.h/C is only for compilation. Abort cint.
#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define G__ANSIHEADER
#define G__DICTIONARY
#include "G__ci.h"
extern “C” {
extern void G__cpp_setup_tagtable05andi();
extern void G__cpp_setup_inheritance05andi();
extern void G__cpp_setup_typetable05andi();
extern void G__cpp_setup_memvar05andi();
extern void G__cpp_setup_global05andi();
extern void G__cpp_setup_memfunc05andi();
extern void G__cpp_setup_func05andi();
extern void G__set_cpp_environment05andi();
}

#include “/tmp/rootcint_Gqo1dz.h”

Hi,

thanks for reminding me! This is caused by a bug in CINT: when CINT is told to determine what “&struct.member” is it always determined the member’s value. And as that is pointing to 0x64 that’s not a good idea. This is a structural change, not an easy bug fix for CINT, so I’d appreciate if you could tell me how central this is to your project: do you need the dictionary for ms_dimensions or would the dictionary for MS_Dimension_data be sufficient? Same for MS_Variable_Data versus error_variables etc - all the static structs that use the offsetof() macro. If you only need the definition of the structure but not the static variables then you can simply write [code]#ifndef offsetof

ifdef CINT

define offsetof(s_name,m_name) 0

else

define offsetof(s_name,m_name) (long)(&((s_name*)0)->m_name)

endif

#endif[/code]
and you’ll get a valid dictionary. Let us know!

Cheers, Axel.

Axel:

Thank you for the help. I’m not sure what I need. I read again the netCDF/ANDI definitions and still didnt know.

Then I tried adding your code to the top of my LinkDef.h, but still got a seg fault.

I’m ready now to try something different. I only actually want the Total Ion Count and then the scan data in a Ttree. I see CHC has posted an answer for reading ASCII files into Ttrees and there are other help answers on that.

I think that now I will spend my time trying to convert the ANDI data to ASCII, then create a Ttree from that.

Tspectrum seems made to then process the TIC file, etc.

All along I wanted to use cint to–more–easily learn to C program and open and extract data from the netCDF ANDI files.

I greatly appreciate your help on this. Seems that ANDI is just not made for ROOT access. I did seemingly get a functioning netCDF.so to load in cint.

Again, thank you.

Hi,

I changed the definition of offsetof in ms10io.h. That allowed CINT to build a proper dictionary.

Let me know when you need more help with converting the data - using the dictionary based approach is of course faster; ASCII is more flexible but also slower, and only works for non-hight-energy-physics amounts of data :wink:

Cheers, Axel.

I have a new plan to accomplish this; that is read mass spec ANDI netCDF files with ROOT.

Using AstroROOT as an example, note that there is tf2tree, and a program that reads PIL to produce a program to read the file.

I found cdf2c, which reads a netCDF file and produces a c program that can then read that file.

(I figure I could learn Fortran easier but I can not get the companion cdf2fortran to compile.) (And Fortran to Ttree would then be difficult.)

I have produced the c file for the two example netCDF files that I have.

I realize from the code below that I need to compile with g++ if I am to then dump the c data structures to a Ttree.

But the c program output by the cdf2c will not compile with g++ (it does with gcc).

I had an error that main had to be ‘int’.
I changed main from ‘void’ to int, and that error disappeared. I now get an error that
“bzero was not declared in this scope”

// Initialize start so all elements are zero.

//***********************************************************************
// here is the problem, results in “bzero was not declared in this scope”
// tried ‘int’ ‘void’ but that didn’t work
// What is needed here?

bzero(start, MAX_NC_VARS * sizeof(long));

So if I can fix this, I can then begin to try to create a Ttree.

I assume that the includes and libs against which to link are similar for AstroROOT and the MainEvent.cxx
example in /root/test/.

After I can get a Ttree, everything else will be possible with ROOT and Cint.

What does g++ want for declaring bzero?

cdf2c.cxx is my, hopefully, g++ correct alteration of the software.
ko1.c is the output from cdf2c that g++ can not compile.

I figure that since the mass spec files I am hoping to get from a research grant proposal
would all be the same (but different samples), that creating a loop to read each file into a branch, and
to include the first leaf as the file name will be trivial after I finally get a Ttree.

Thank you.

from tf2tree.cxx, from AstroROOT:

#include <stdio.h>

#include <TFile.h>
#include <TGraphErrors.h>

#include “pil.h”
#include “param_api.h”

#include “TFError.h”
#include “TFTable.h”
#include “TFGroup.h”
#include “TFImage.h”

from /root/test/MainEvent.cxx
// Author: Rene Brun 19/01/97

////////////////////////////////////////////////////////////////////////
//
// A simple example with a ROOT tree
// =================================

#include <stdlib.h>

#include “Riostream.h”
#include “TROOT.h”
#include “TFile.h”
#include “TNetFile.h”
#include “TRandom.h”
#include “TTree.h”
#include “TBranch.h”
#include “TClonesArray.h”
#include “TStopwatch.h”
#include “TTreeCacheUnzip.h”

#include “Event.h”
ko1.c (12.3 KB)
cdf2c.cxx (18.7 KB)

Hi,

I main() is created by the conversion tool you mentioned? If so: leave it in a C file and create a second (C++) file, where you put all the C++ code. You create >= 1 function in the C++ file that will be called from ko1.c, and you declare this function extern “C” - it must be a global function. It will probably be something like int Fill(struct CDFEntry*) returning success or failure.

You now compile ko1.c with gcc and the C++ file with g++. You should be able to link using something like “g++ -o converter ko1.o treefill.o”.

Cheers, Axel.