LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-04-2004, 06:47 AM   #1
pjz
Member
 
Registered: Sep 2003
Posts: 71

Rep: Reputation: 15
Question Basic RH 9.0 gcc question


Hi-

I hope someone can help me. I'm running RedHat 9.0 and have just
started my first software development using the bundled gcc/gdb tools.
I'm missing something when it comes to using dynamic memory allocation.
I'm sure it's something super basic, but I must not be looking in the right
places because I can't seem to find out what I need to do despite a good
effort to find out.

In file junk.cpp, I type:

#include <stdio.h>

main()
{
int* dummy;

dummy = new int;

*dummy = 0;

printf ("Integer is %d\n",*dummy);
}

when I compile using "gcc junk.cpp", the compiler comes back with:

/tmp/cc6oZ9ez.o(.text+0x16): In function `main':
: undefined reference to `operator new(unsigned)'
/tmp/cc6oZ9ez.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

I'm missing a library somewhere, I think, but I can't seem to figure out which one.
I'm sure that lots of people use dynamic memory allocation and someone could
right off the top of their head tell me what to do. That would be great. This has
turned into "one of those things" for me and has been frustrating.

cheers
pjz
 
Old 01-04-2004, 10:00 AM   #2
LinuxLala
Senior Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: Fedora 7
Posts: 1,305

Rep: Reputation: 45
I think that you will find more answers in the programming forum. Report this post to a moderator and ask him to move your thread to the programming forum

Cheers.
 
Old 01-05-2004, 12:34 AM   #3
sashhoney
Member
 
Registered: Jul 2003
Distribution: Red Hat, Fedora, Debian
Posts: 85

Rep: Reputation: 15
first point is that 'new' operator is not defined in stdio.h
u have to use malloc for allocating memory in c language
if u want to use new, then use iostream.h, name the file as .cpp and compile it using g++ instead of gcc
 
Old 01-05-2004, 07:57 AM   #4
pjz
Member
 
Registered: Sep 2003
Posts: 71

Original Poster
Rep: Reputation: 15
Thanks.

Tried it, and of course it worked.

I figured it was something simple.

cheers
pjz
 
  


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
6. Installing Basic System Software--- GCC-3.4.1 ukyo Linux From Scratch 8 06-13-2005 08:34 PM
basic compilatoin issues (gcc) poiuytrewq Programming 1 04-07-2005 04:10 AM
Basic Question insyte Linux - Wireless Networking 4 09-16-2004 11:57 AM
A really basic question pilotgi Linux - Newbie 10 10-14-2002 04:57 PM
basic question kurgan70 Linux - General 2 12-06-2001 03:42 PM


All times are GMT -5. The time now is 03:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration