[ROOT] TImage, ASImage does not exist in... (the 2nd)

From: Bernd Reinhold (bernd.reinhold@cern.ch)
Date: Tue Apr 13 2004 - 23:23:04 MEST


Hi!

[I sent it accidentally a bit too early, so please ignore the first email. (And perhaps to the wrong address)]

My program (see below for the source!) compiles without error. the executable creates the following output:

(...)
before1
Error in <TUnixSystem::DynamicPathName>: ASImage[.so | .sl | .dl | .a] does not exist in .:/usr/local//lib/root
after1

 *** Break *** segmentation violation
 Generating stack trace...
 0x42029188 in <unknown> from analysis_root_mysql
 0x42017589 in __libc_start_main + 0x95 from analysis_root_mysql
 0x080546b1 in __eh_alloc + 0x49 from analysis_root_mysql
Abort

In the code this is:
        cout << "before1" << endl;
        TImage *img = TImage::Create();
        cout << "after1" << endl;
        gSystem->ProcessEvents();
        img->FromPad(c1);

Is there a problem with TImage? ASImage IS not there, but why is it not?
Is this a problem of my installation of root?
I have 3.10.02. (Compiled from source with gcc 2.96)
configure linux --prefix=/usr/local/ --disable-shared --enable-alien
--enable-table --enable-ldap; gmake; gmake install;
I have CERN RedHat 7.3.4

(The program is trying to integrate ROOT and mysql++ (to explain the headers))

2 other (minor) issues:
1. There is a segmentation violation if I uncomment gROOT... and gDebug...
int main(...)
//      gROOT->Reset();
//      gDebug=7;
2. the compiler complains about the 'kJpeg'. Can you tell me the correct syntax?
img->WriteImage(p.str(), kJpeg);

Thank you for your help. It is highly appreciated.

Bernd.

--------appendix--------
1. the program
2. the makefile (for this program)

#include <iostream>
#include <sqlplus.hh>
//root-includes
#include <TSystem.h>
#include <TROOT.h>
#include <TPad.h>
#include <TH1.h>
#include <TImage.h>
#include <TCanvas.h>
//had them included in the other root-script, executed in CINT
#include <sstream>
#include "string"
#include "Riostream.h"
#include "vector"


int main (int argc, char *argv[]) {
//      gROOT->Reset();
//      gDebug=7;
        string SQLstring;
        Connection connection(use_exceptions);
        Int_t nlines=0;
        try { // the entire main block is one big try block;
                connection.connect("localdb", "hmmm", "lala", "oufff");
        if (argc == 1){
                SQLstring="SELECT pullforce FROM pt_main as M, pt_rawdata as R WHERE M.ID=R.ID and M.status=R.status and M.batch like '%HSA%' and M.status=1";
        } else if (argc == 2){
                SQLstring= argv[1];
        } else {
                //the SQL-query as argument
                cerr << "The program expects either 2 or 1 argument(s). But it found " << argc << " argument(s)." << endl;
                return -1;
        }
        // create a new object and connect based on any (if any) arguments
        // passed to main();
   
        Query query = connection.query();  // create a new query object
       
        // ignore any errors here
        // I hope to make this simpler soon, comment by Sinisa Milosevic
        query << SQLstring.c_str();
        Result res = query.store();
        if(res.empty()) throw BadQuery("the query was empty");

        cout << "query: " << query.preview() << endl;
        cout << "records found: " << res.size() << endl << endl;



//now populate the histogram; here is where root-objects are used for the first time...
//assume only one column (row[0])

        TH1D *h1 = new TH1D("h1", SQLstring.c_str(), 100,0,20);
        TCanvas *c1 = new TCanvas("c1", "thecanvas", 600, 400);
        Row row;
        Result::iterator i;
        for(i=res.begin(); i!=res.end(); i++){
                row=*i;
//              cout << row[0] << endl;
                h1->Fill((double)row[0]);
                nlines++;
        }

        h1->Draw();
        c1->Update();
        ostringstream p;
        p << "/home/reinhold_pcepcmt35/analysis/results/" << res.names(0).c_str() <<".jpg" << ends;


        cout << "before1" << endl;
        TImage *img = TImage::Create();
        cout << "after1" << endl;
        gSystem->ProcessEvents();
        img->FromPad(c1);
        cout << "after2" << endl;      
//      img->WriteImage(p.str(), kJpeg);
        cout << "the jpg-image was stored in the following absolute path: "<< p.str() << endl;
       
        delete h1;
        delete c1;
        delete img;
       
        return 0;

  } catch (BadQuery &er) { // handle any connection or
                          // query errors that may come up
#ifdef USE_STANDARD_EXCEPTION
    cerr << "Error: " << er.what() << endl;
#else
    cerr << "Error: " << er.error << endl;
#endif
    return -1;
  } catch (BadConversion &er) { // handle bad conversions
        cerr << "lines so far: " << nlines << endl;
#ifdef USE_STANDARD_EXCEPTION
    cerr << "Error: " << er.what() << "\"." << endl
         << "retrieved data size: " << er.retrieved
         << " actual data size: " << er.actual_size << endl;
#else
    cerr << "Error: Tried to convert \"" << er.data << "\" to a \""
         << er.type_name << "\"." << endl;
#endif
    return -1;
#ifdef USE_STANDARD_EXCEPTION          
  } catch (exception &er) {
    cerr << "Error: " << er.what() << endl;
    return -1;
#endif         
  }
 
}

---makefile---

analysis_root_mysql: analysis_root_mysql.o
        g++ -oanalysis_root_mysql analysis_root_mysql.o \
        -L/usr/local/mysql//lib/mysql \
        $(shell root-config --libs) \
        -lmysqlclient -lz \
        -L/usr/src/mysql++-1.7.9_patched/sqlplusint/ \
        -lsqlplus      
       
analysis_root_mysql.o: analysis_root_mysql.cpp
        g++ -c analysis_root_mysql.cpp -I/usr/local/mysql//include/mysql \
        -I/usr/src/mysql++-1.7.9_patched/sqlplusint \
        -I/usr/local/include/root



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET