[ROOT] string in gcc

From: Ben Kilminster (bjk@fnal.gov)
Date: Thu Nov 13 2003 - 02:52:52 MET


Hi,

At the ROOT prompt, I try to pass a string into an object.    This  
works in my KCC compiled root on my linux PC,  but does not work on my  
gcc 3.3  compiled root on my Mac.  I went through a bunch of emails  
with similar questions on roottalk, but I didn't get anywhere.  I  
believe this feature must be at the CINT level, since the classes do  
compile okay.

Here is the successful running on the kcc compiled root system:

root [0] .L test.cc++
Info in <TUnixSystem::ACLiC>: creating shared library  
/home/bjk/test2/./test_cc.so
root [1] test T
root [2] T.set("value")
offset is value


Here is what happens on the macosx version :

root [0] .L test.cc++
Info in <TUnixSystem::ACLiC>: creating shared library  
/Users/bjk/releases/4.11.1ana/test2/./test_cc.so
ld: warning -prebind has no effect with -bundle
root [1] test T
root [2] T.set("value")
Error: Can't call test::set("value") in current scope FILE:(tmpfile)  
LINE:1
Possible candidates are...
filename       line:size busy function type and name  (in test)
(compiled)        0:0    0 public: void set(string value);
Error: Symbol T is not defined in current scope  FILE:(tmpfile) LINE:1
Error: Failed to evaluate T.set("value")Possible candidates are...
filename       line:size busy function type and name
*** Interpreter error recovered ***


 From the threads on roottalk I have seen,   I have tried a range of  
things to get this to work, such as :

root [0] #include <string>
root [1] using namespace std
root [2] string val = "value"
root [3] .L test.cc++
Info in <TUnixSystem::ACLiC>: creating shared library  
/Users/bjk/releases/4.11.1ana/test2/./test_cc.so
ld: warning -prebind has no effect with -bundle
root [4] test T
root [5] T.set(val)
Error: Can't call test::set(val) in current scope FILE:(tmpfile) LINE:1
Possible candidates are...
filename       line:size busy function type and name  (in test)
(compiled)        0:0    0 public: void set(string value);
Error: Symbol T is not defined in current scope  FILE:(tmpfile) LINE:1
Error: Failed to evaluate T.set(val)Possible candidates are...
filename       line:size busy function type and name
*** Interpreter error recovered ***

------------------------------------------------------------------------ 
-------------------------
The code I am trying to execute is :
test.cc :
#include <iostream>
#include "test.hh"
using namespace std;
test::~test() {
}
test::test(){
}

test.hh :
#include <iostream.h>
class test {
public:
   std::string Offset;
   test();
   ~test();
    inline void set(std::string value)
       {Offset = value;
       std::cout << "offset is " << value << std::endl; }
};


What am I doing wrong here ?

Thanks !
Ben

p.s.  I am using  root 3.10.1 compiled on my Mac osx 10.3 with gcc 3.3.



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET