Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 15
Question Basic RH 9.0 gcc question


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>

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.

Old 01-04-2004, 10:00 AM   #2
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

Old 01-05-2004, 12:34 AM   #3
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
Registered: Sep 2003
Posts: 71

Original Poster
Rep: Reputation: 15

Tried it, and of course it worked.

I figured it was something simple.



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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:17 AM.

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