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 05-12-2010, 03:31 PM   #1
LQ Newbie
Registered: May 2010
Posts: 1

Rep: Reputation: 0
GNU issues: undefined reference to '_rand'


I am trying to compile legacy a code that worked well with f77 and g77 on linux platform. I am trying to use g95 since f77 and g77 are not available. The code is mostly in fortran and uses few c functions among. I am getting the undefined reference error for rand:

(.data+0x4): undefined referenec to '_rand'

I am defining my own function RANDOM and rand in an include file but I am not sure why it is failing to link and giving me such error?

external rand
double precision rand

#define RANDOM rr(nq)

I am puzzled by why g95 is giving me such issues?!

Old 05-12-2010, 11:31 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
Hi, welcome to LQ!

How are you invoking the compiler? For all I know you simply haven't
told it which library to link your old code against. The error you
see is not a compiler error, it's a linker one.

Old 05-13-2010, 04:49 AM   #3
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2018 CentOS6.10 CentOS7.5 + 50+ other Linux OS, for test only.
Posts: 17,054

Rep: Reputation: 3461Reputation: 3461Reputation: 3461Reputation: 3461Reputation: 3461Reputation: 3461Reputation: 3461Reputation: 3461Reputation: 3461Reputation: 3461Reputation: 3461
... f77 and g77 are not available..
f77 and g77 are "always" available.

But you will have to tell, which Linux OS, you are using.

Should be be told by every question :


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
Undefined reference, why? george_mercury Programming 4 05-07-2009 12:15 AM
undefined reference to... dimah Programming 3 12-27-2006 09:57 AM
Undefined reference to: ashlesha Programming 5 11-08-2006 01:07 PM
Undefined Reference ChemicalBurn Programming 2 02-14-2005 03:01 AM
undefined reference mp4-10 Programming 3 01-25-2005 12:38 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:15 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