473,224 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Can you help with my issue with fstream in my little program here?

I would like to say thanks in advance for insight anyone can shed on
this for me.

Long story short from time to time I need to us C++ to take a list of
file and make an index out of them in html. for this I use fstream both
for input and output. So, i have a simple file that I just change few
things on and I get the output formatted to what I want.

So I installed FC6 on my home system and get out my handy usb drive
because i needed my magic source file:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

fstream fout("index.html", fstream::out );
fstream fin("list.txt", fstream::in);
int main()
{
string in;

while(getline(fin, in))
{
fout << in << endl;
}

return 0;
}
to compile another html file for me. As you can see pretty cut and dry
and to the point.

My problem is compiling this file since I upgraded(?) to FC6 from FC5. I
am using gcc version 4.1.1 20061011 (Red Hat 4.1.1-30) without any
tweaks or changes from a std install.

When I run:
[charowl@localhost *****]$ gcc stuff.cpp

I get:
/tmp/ccxQXTd5.o: In function `__tcf_2':
stuff.cpp:(.text+0xe): undefined reference to `std::basic_fstream<char,
std::char_traits<char::~basic_fstream()'
/tmp/ccxQXTd5.o: In function `__tcf_1':
stuff.cpp:(.text+0x22): undefined reference to `std::basic_fstream<char,
std::char_traits<char::~basic_fstream()'
/tmp/ccxQXTd5.o: In function
`__static_initialization_and_destruction_0(int, int)':
stuff.cpp:(.text+0x53): undefined reference to `std::ios_base::Init::Init()'
stuff.cpp:(.text+0x8b): undefined reference to `std::basic_fstream<char,
std::char_traits<char::basic_fstream(char const*, std::_Ios_Openmode)'
stuff.cpp:(.text+0xc3): undefined reference to `std::basic_fstream<char,
std::char_traits<char::basic_fstream(char const*, std::_Ios_Openmode)'
/tmp/ccxQXTd5.o: In function `__tcf_0':
stuff.cpp:(.text+0x10c): undefined reference to
`std::ios_base::Init::~Init()'
/tmp/ccxQXTd5.o: In function `main':
stuff.cpp:(.text+0x12b): undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char::basic_string()'
stuff.cpp:(.text+0x140): undefined reference to
`std::basic_ostream<char, std::char_traits<char& std::operator<<
<char, std::char_traits<char>, std::allocator<char>
>(std::basic_ostream<char, std::char_traits<char&,
std::basic_string<char, std::char_traits<char>, std::allocator<char
const&)'
stuff.cpp:(.text+0x148): undefined reference to
`std::basic_ostream<char, std::char_traits<char& std::endl<char,
std::char_traits<char(std::basic_ostream<char, std::char_traits<char>
>&)'
stuff.cpp:(.text+0x150): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
>::operator<<(std::basic_ostream<char, std::char_traits<char&
(*)(std::basic_ostream<char, std::char_traits<char&))'
stuff.cpp:(.text+0x163): undefined reference to
`std::basic_istream<char, std::char_traits<char& std::getline<char,
std::char_traits<char>, std::allocator<char(std::basic_istream<char,
std::char_traits<char&, std::basic_string<char,
std::char_traits<char>, std::allocator<char&)'
stuff.cpp:(.text+0x177): undefined reference to `std::basic_ios<char,
std::char_traits<char::operator void*() const'
stuff.cpp:(.text+0x190): undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char::~basic_string()'
stuff.cpp:(.text+0x1a6): undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char::~basic_string()'
/tmp/ccxQXTd5.o:(.eh_frame+0x12): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

and nothing happens. Is my complier broken, my code?

either way it would be nice to know. I have tried using every example
of how to do this that google could find for me on fstream, and now I
ask you. thanks -josh
Dec 28 '06 #1
2 4728
"jjcp" <ch*****@charowl.netwrote in message
news:nX****************@newsfe03.lga...
>I would like to say thanks in advance for insight anyone can shed on this
for me.

Long story short from time to time I need to us C++ to take a list of
file and make an index out of them in html. for this I use fstream both
for input and output. So, i have a simple file that I just change few
things on and I get the output formatted to what I want.

So I installed FC6 on my home system and get out my handy usb drive
because i needed my magic source file:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

fstream fout("index.html", fstream::out );
fstream fin("list.txt", fstream::in);
int main()
{
string in;

while(getline(fin, in))
{
fout << in << endl;
}

return 0;
}
to compile another html file for me. As you can see pretty cut and dry
and to the point.

My problem is compiling this file since I upgraded(?) to FC6 from FC5. I
am using gcc version 4.1.1 20061011 (Red Hat 4.1.1-30) without any tweaks
or changes from a std install.

When I run:
[charowl@localhost *****]$ gcc stuff.cpp

I get:
/tmp/ccxQXTd5.o: In function `__tcf_2':
stuff.cpp:(.text+0xe): undefined reference to `std::basic_fstream<char,
std::char_traits<char::~basic_fstream()'
/tmp/ccxQXTd5.o: In function `__tcf_1':
stuff.cpp:(.text+0x22): undefined reference to `std::basic_fstream<char,
std::char_traits<char::~basic_fstream()'
<snip other errors along same line>

I think it might be as simple as needing
#include <ostream>
#include <istream>

at the top of your program. Include files are allowed to include other
include files, or not as they see fit. Try this and see if it works.
Dec 28 '06 #2

Jim Langston wrote:
"jjcp" <ch*****@charowl.netwrote in message
news:nX****************@newsfe03.lga...
I would like to say thanks in advance for insight anyone can shed on this
for me.

Long story short from time to time I need to us C++ to take a list of
file and make an index out of them in html. for this I use fstream both
for input and output. So, i have a simple file that I just change few
things on and I get the output formatted to what I want.

So I installed FC6 on my home system and get out my handy usb drive
because i needed my magic source file:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

fstream fout("index.html", fstream::out );
fstream fin("list.txt", fstream::in);
int main()
{
string in;

while(getline(fin, in))
{
fout << in << endl;
}

return 0;
}
to compile another html file for me. As you can see pretty cut and dry
and to the point.

My problem is compiling this file since I upgraded(?) to FC6 from FC5. I
am using gcc version 4.1.1 20061011 (Red Hat 4.1.1-30) without any tweaks
or changes from a std install.

When I run:
[charowl@localhost *****]$ gcc stuff.cpp

I get:
/tmp/ccxQXTd5.o: In function `__tcf_2':
stuff.cpp:(.text+0xe): undefined reference to `std::basic_fstream<char,
std::char_traits<char::~basic_fstream()'
/tmp/ccxQXTd5.o: In function `__tcf_1':
stuff.cpp:(.text+0x22): undefined reference to `std::basic_fstream<char,
std::char_traits<char::~basic_fstream()'

<snip other errors along same line>

I think it might be as simple as needing
#include <ostream>
#include <istream>

at the top of your program. Include files are allowed to include other
include files, or not as they see fit. Try this and see if it works.
Why are you using gcc and not g++?

Tolga Ceylan

Dec 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ron Stephens | last post by:
I posted to my web site a fun little program called merlin.py today. Please keep in mind that I am a hobbyist and this is just a little hack, if you look at the code you will see that it is still...
6
by: Rafael | last post by:
Hi Everyone, I need some help with my calculator program. I need my program to do 2 arguments and a 3rd, but the 3rd with different operators. Any help would be great. Here is my code.... ...
38
by: npc | last post by:
Hello! - I have a problem, I need to write a little program a la Mastermind in C (for school). Can anybody help me? please, contact me by e-mail. greets
16
by: mdh | last post by:
Can someone look at this little program and tell me why the last line is not compiling. #include <stdio.h> int main (){ int i, j, k; i=0;
3
by: Arun Nair | last post by:
''' Can anyone help me with this program it just takes probability of the first team and runs the program doesnt takes the probability of the second team even though specified''' from random...
2
by: shblack | last post by:
Please can someone help me with this program. I am in a JAVA programming class and I am having a heck of a time. I am still having a problem with the basic concepts of JAVA but the teacher continues...
1
by: Programmar | last post by:
Hello. I'm new here and was wondering if someone could help me with a program i have in mind. Its not really anything serious, just a bit of fun. If someone could explain or make a program that keeps...
6
by: isabelle | last post by:
help me in this program.... Write a program that prompt the user ti input an integer and then outputs the numbers with digits reversed. for example, if the input is 12345 the output should be...
3
by: devilinthebox | last post by:
I am not really familar with Java and I need help with creating this simple Blackjack program. Here is a layout of how the program should output: If the computer has more than 16 it wins,...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.