Error: string() no default constructor fileRead. (fixed)

I compiled the string.dll ( see this topic: root.cern.ch/phpBB2/viewtopic.php?t=9044 )
I copied the dll and try to run my example file read programm:

[code]// reading a text file
#include
#include
#include
using namespace std;

int main () {
string line;
ifstream myfile (“example.txt”);
if (myfile.is_open()) {
while (! myfile.eof()) {
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << “Unable to open file”;
return 0;
}[/code]

Now i get:

C:\Users\Lis\Documents\work\cint_learn>cint.exe -IC:\Users\Lis\Documents\work\ci nt-svn\cint\inc -IC:\Users\Lis\Documents\work\cint-svn\cint\include -IC:\Users\L is\Documents\work\cint-svn\cint\stl -IC:\Users\Lis\Documents\work\cint-svn\refle x\inc fileRead.cxx Error: string() no default constructor fileRead.cxx(8) !!! return from main() function

Do I need to change some .h files or do I need to copy any .h files to use string.dll ?
Thanks Louis.

Hi Louis,

can you check whether string.dll got loaded? You could run “class string” - it should show you the members of string, and it should tell you that they are defined in string.dll. Where did you copy string.dll too?

Cheers, Axel.

Interresting.
class string gives me:

C:\Users\Lis\Documents\work\cint_learn>cint.exe -IC:\Users\Lis\Documents\work\ci nt-svn\cint\inc -IC:\Users\Lis\Documents\work\cint-svn\cint\include -IC:\Users\L is\Documents\work\cint-svn\cint\stl -IC:\Users\Lis\Documents\work\cint-svn\refle x\inc class string Note: posix.dll is not found. Do 'sh setup' in $CINTSYSDIR/lib/posix directory i f you use UNIX. Error: Symbol fpos_tpos is not defined in current scope C:\Users\Lis\Documents\ work\cint-svn\cint\inc\G__ci.h(1142)

If I try to compile posix.dll I get:
awake24.de/paste/database/9fe126443.php

Thanks for your help.
Greets Louis

Fixed it:

C:\Users\Lis\Documents\work\cint-svn\cint\lib\posix>link -nologo -ignore:4049 - ignore:4217 -ignore:4221 -incremental:no -DLL -implib:posix.lib -out:posix.dll w inposix.obj G__c_posix.obj -LIBPATH:"..\..\..\lib" libCint.lib Advapi32.lib k ernel32.lib user32.lib Creating library posix.lib and object posix.exp

Links the library without problems.
Still get:

C:\Users\Lis\Documents\work\cint_learn>cint.exe -IC:\Users\Lis\Documents\work\ci nt-svn\cint\inc -IC:\Users\Lis\Documents\work\cint-svn\cint\include -IC:\Users\L is\Documents\work\cint-svn\cint\stl -IC:\Users\Lis\Documents\work\cint-svn\refle x\inc class string Error: Symbol fpos_tpos is not defined in current scope C:\Users\Lis\Documents\ work\cint-svn\cint\inc\G__ci.h(1142)

And the string.dll is in cint/stl (Sorry forgotten to tell you that).
Greets Louis

Hi Louis,

you should not specify any CINT include paths to CINT. What does
$ cint
cint> L string
cint> class string
show?

Cheers, Axel.

If I start without include dirs:

[code]C:\Users\Lis\Documents\work\cint_learn>cint.exe

cint : C/C++ interpreter (mailing list ‘cint@root.cern.ch’)
Copyright© : 1995~2005 Masaharu Goto (gotom@hanno.jp)
revision : 5.17.00, Dec 21, 2008 by M.Goto

No main() function found in given source file. Interactive interface started.
‘h’:help, ‘q’:quit, ‘{statements;}’ or ‘p [expr]’ to evaluate

cint.exe> L string
Error: cannot open file “string” (0)
!!!Dictionary position rewound… !!!Error recovered!!!
cint.exe> class string
Error: class,struct,union or type string not defined (0)
!!!Dictionary position rewound… !!!Error recovered!!!
cint.exe>[/code]

I should try to recompile cint and change it’s compilation flags, so that I do not need the include paths anymore, right?

Ah the commands you told me really helped. At least I know why this happens:

[code]C:\Users\Lis\Documents\work\cint-svn\cint\lib\dll_stl>cint.exe -w2 -zstring -nG
cpp_string.cxx -D__MAKECINT -DG__MAKECINT -c-1 -A -I"…\cint\inc" -I
"…\cint\include" -DG__REDIRECTIO -DG__SHAREDLIB -DG__WIN32 -DWIN32 -D_WIN
32 -DG__NEWSTDHEADER -D_CRT_SECURE_NO_DEPRECATE=1 -DCC_WSDK61 -DMKINC_CWD -DIOSE
_CWD -DG__HAVE_CONFIG -DG__NOMAKEINFO -Z0 str.h
Note: link requested for unknown typedef string::value_type str.h(39)
Note: link requested for unknown class string::iterator str.h(42)
Note: link requested for unknown class string::const_iterator str.h(43)
Note: link requested for unknown class _Ranit<char,long,char*,char&> str.h(44)
Note: link requested for unknown class iterator<random_access_iterator_tag,char,
long,char*,char&> str.h(45)
Note: link requested for unknown typedef string::pointer str.h(56)
Note: link requested for unknown typedef string::const_pointer str.h(57)
Note: link requested for unknown typedef string::reference str.h(58)
Note: link requested for unknown typedef string::difference_type str.h(59)
Note: link requested for unknown typedef string::size_type str.h(60)
Note: link requested for unknown typedef string::traits_type str.h(61)
Warning: #pragma link, function operator==(const string&,const string&) not foun
d str.h(63)
Warning: #pragma link, function operator!=(const string&,const string&) not foun
d str.h(64)
Warning: #pragma link, function operator<(const string&,const string&) not found
str.h(65)
Warning: #pragma link, function operator>(const string&,const string&) not found
str.h(66)
Warning: #pragma link, function operator<=(const string&,const string&) not foun
d str.h(67)
Warning: #pragma link, function operator>=(const string&,const string&) not foun
d str.h(68)
Warning: #pragma link, function operator+(const string&,const string&) not found
str.h(69)
Warning: #pragma link, function operator+(char,const string&) not found str.h(70
)
Warning: #pragma link, function operator+(const string&,char) not found str.h(71
)
Warning: #pragma link, function operator<(const char*,const string&) not found s
tr.h(75)
Warning: #pragma link, function operator>(const char*,const string&) not found s
tr.h(76)
Warning: #pragma link, function operator==(const char*,const string&) not found
str.h(77)
Warning: #pragma link, function operator!=(const char*,const string&) not found
str.h(78)
Warning: #pragma link, function operator<=(const char*,const string&) not found
str.h(79)
Warning: #pragma link, function operator>=(const char*,const string&) not found
str.h(80)
Warning: #pragma link, function operator+(const char*,const string&) not found s
tr.h(81)
Warning: #pragma link, function operator<(const string&,const char*) not found s
tr.h(83)
Warning: #pragma link, function operator>(const string&,const char*) not found s
tr.h(84)
Warning: #pragma link, function operator==(const string&,const char*) not found
str.h(85)
Warning: #pragma link, function operator!=(const string&,const char*) not found
str.h(86)
Warning: #pragma link, function operator<=(const string&,const char*) not found
str.h(87)
Warning: #pragma link, function operator>=(const string&,const char*) not found
str.h(88)
Warning: #pragma link, function operator+(const string&,const char*) not found s
tr.h(89)
Warning: #pragma link, function swap(string&,string&) not found str.h(91)
Note: link requested for unknown function getline str.h(92)
Note: Link requested for undefined class string (ignore this message) (0)

C:\Users\Lis\Documents\work\cint-svn\cint\lib\dll_stl>cl -I"…\cint\inc"
-DG__REDIRECTIO -DG__SHAREDLIB -DG__WIN32 -DWIN32 -D_WIN32 -DG__NEWSTDHEADER -D_
CRT_SECURE_NO_DEPRECATE=1 -DCC_WSDK61 -DMKINC_CWD -DIOSE_CWD -DG__HAVE_CONFIG -D
G__NOMAKEINFO -O2 -MD -nologo -wd4996 -EHs -TP -GR -wd4181 -c G__cpp_string.
cxx
G__cpp_string.cxx

C:\Users\Lis\Documents\work\cint-svn\cint\lib\dll_stl>link -nologo -ignore:4049
-ignore:4217 -ignore:4221 -incremental:no -DLL -implib:string.lib -out:string.d
ll G__cpp_string.obj -LIBPATH:"…\lib" libCint.lib kernel32.lib user32.
lib
Creating library string.lib and object string.exp[/code]
Do I need to add more include paths or howto fix this problem. I don’t know howto solve this right now. If I add more includepaths the dll does not compile anymore.
Is this a bug, maybe a windows implementation problem?

Thanks Louis

Hi,

This happens when you try to generate the dictionary for string but there is already a string.dll. Before running ‘cint.exe -w2 -zstring …’ step you must delete the string.dll (cint/stl/string.dll).

Cheers,
Philippe.