HI Ben, The most likely cause is that your installation of ROOT has not built the cintdlls. In the KCC build, std::string interpreted support is built in. In all other cases the cintdlls need to be built and you need to type: #include <string> To check whether you have the dictionary for the string properly loaded you can do: .files this should list "string.dll". If you do no see "string.dll" (after doing #include <string>) then you have no access (from the interpreter) to the compiled version of std::string and you can NOT pass string to your compiled classes. Note that in root 3.11.00 and above, support for std::string will be built-in on all platform (with no need for #include <string>) Cheers, Philippe. -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Ben Kilminster Sent: Wednesday, November 12, 2003 7:53 PM To: roottalk@pcroot.cern.ch Subject: [ROOT] string in gcc 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