LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-23-2004, 11:14 PM   #1
xviddivxoggmp3
Member
 
Registered: Feb 2004
Location: scanf
Distribution: Redhat Enterprise 4.4 AS
Posts: 236

Rep: Reputation: 30
Question c++ libraries and slackware 9.1


does slackware have the c++ libraries native?
i have attempted to compile a c++ program with gcc, but it just creates a bunch of errors that i'm not familiar with.
i'm new to gcc and slackware, and do not know if it is user error, lack of libraries, or a little of both.

Last edited by xviddivxoggmp3; 02-23-2004 at 11:15 PM.
 
Old 02-23-2004, 11:17 PM   #2
Kovacs
Member
 
Registered: Jul 2003
Distribution: FreeBSD 8.2 RELEASE
Posts: 607

Rep: Reputation: 32
look in /a and /d on the slack cds, you need to install c++ support for gcc as well.

Last edited by Kovacs; 02-23-2004 at 11:20 PM.
 
Old 02-24-2004, 12:01 AM   #3
xviddivxoggmp3
Member
 
Registered: Feb 2004
Location: scanf
Distribution: Redhat Enterprise 4.4 AS
Posts: 236

Original Poster
Rep: Reputation: 30
i did pick the the install of c++ libraries at install, but the gcc compiler keeps erroring out.
btw...
what is fluxbox.
i just looked at your link.
is it another version of a gui desktop (e.g. gnome, kde)

Last edited by xviddivxoggmp3; 02-24-2004 at 12:03 AM.
 
Old 02-24-2004, 12:52 AM   #4
Kovacs
Member
 
Registered: Jul 2003
Distribution: FreeBSD 8.2 RELEASE
Posts: 607

Rep: Reputation: 32
Post the error messages that gcc is giving you so we have a better idea of what is going on.

Fluxbox is a very lightweight and minimalist window manager (as opposed to a full desktop environment, like kde or gnome). It rocks! http://fluxbox.sourceforge.net/
 
Old 02-24-2004, 07:18 PM   #5
xviddivxoggmp3
Member
 
Registered: Feb 2004
Location: scanf
Distribution: Redhat Enterprise 4.4 AS
Posts: 236

Original Poster
Rep: Reputation: 30
below is the code and the errors i receive from trying to compile a c++ file.
Quote:
gcc hello_world.cpp
Code:
#include<iostream>

main(void)
{
        using std::cout;

        cout<<"hello world";
}
Quote:
/tmp/ccaKQVlf.o(.text+0x19): In function `main':
: undefined reference to `std::cout'
/tmp/ccaKQVlf.o(.text+0x1e): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std
::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits
<char> >&, char const*)'
/tmp/ccaKQVlf.o(.text+0x4a): In function `__static_initialization_and_destructio
n_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccaKQVlf.o(.text+0x79): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccaKQVlf.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

Last edited by xviddivxoggmp3; 02-24-2004 at 08:14 PM.
 
Old 02-25-2004, 12:58 AM   #6
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
heh, re-name.......
Code:
hello_world.cpp >>> hello_world.c
2........ g++ -o hello_world hello_world.c
it should compile........

Last edited by 320mb; 02-25-2004 at 12:59 AM.
 
Old 02-25-2004, 03:52 AM   #7
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
If you are trying to compile a C++ program you need to have /d/gcc-g++ installed. You will probably also need /a/cxx-libs
 
Old 02-25-2004, 12:22 PM   #8
amos
Member
 
Registered: Dec 2002
Location: Bolton, UK
Distribution: Kubuntu
Posts: 224

Rep: Reputation: 30
If I was doing this, I'd first change the program to read:


Code:
#include<iostream>
using namespace std;

int main()
{
        cout << "hello world" << endl;
	return 0;
}
Then after saving it as "hello.cpp", I'd compile it by doing

g++ hello.cpp

g++ is the way to invoke gcc's c++ compiler, this would of course result in an executable called "a.out", so if i wanted to produce some other output I'd do:

g++ hello.cpp -o helloworld

Which should result in an executable called "helloworld".

Hope this helps.

You'd probably be better of posting this sort of query in the "Programming" forum in future, as it seems more relevant.


Cheers
Amos
 
Old 02-25-2004, 06:02 PM   #9
xviddivxoggmp3
Member
 
Registered: Feb 2004
Location: scanf
Distribution: Redhat Enterprise 4.4 AS
Posts: 236

Original Poster
Rep: Reputation: 30
thank you for your help.
i was thinking that gcc needed a switch to recognize the c++ code.
I'm used to programming for w32.
Doesn't the rules of coding for linux change from w32?
I'm new to linux.
The code you wrote.
Quote:
Code:
#include<iostream>
using namespace std;

int main()
{
        cout << "hello world" << endl;
	return 0;
}
this seems to me standard w32 programming.
Sorry for my sloppy programming.
aren't you required to code c++ in a linux format?
can you cascade using std statements?
Code:
using  std::cout,std::cin;
sorry for posting this in the wrong forum.
I thought it was originally a native library question for slackware specific ditros.

Last edited by xviddivxoggmp3; 02-25-2004 at 06:05 PM.
 
Old 02-26-2004, 04:00 PM   #10
amos
Member
 
Registered: Dec 2002
Location: Bolton, UK
Distribution: Kubuntu
Posts: 224

Rep: Reputation: 30
If I removed the "using namespace std;" line then I would have modified the code like this:

Code:
#include<iostream>

int main()
{
        std::cout << "hello world" << std::endl;
        return 0;
}
Otherwise it wouldn't work. Alternatively I could do:

Code:
#include<iostream.h>

int main()
{
        cout << "hello world" << endl;
        return 0;
}
Which would give me messages during compilation telling me that iostream.h was now deprecated, and could I in future use iostream instead. But the code would still compile and run.

Hope this helps. I'm no C++ guru, but I know a little bit, mainly from trying to work out why my own programs won't compile.

Cheers
Amos
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
erased glib libraries on slackware 10, need help on boot salviadud Linux - Newbie 1 03-05-2005 12:00 PM
Problem with djvu libraries in Slackware Sader Slackware 1 02-04-2005 05:42 AM
Qt libraries sempuritoza Linux - Newbie 4 01-20-2005 03:00 PM
Libraries lyar1031 Linux - Software 0 08-31-2004 08:23 PM
g++ libraries ofada Programming 1 04-09-2004 12:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration