LinuxQuestions.org
Review your favorite Linux distribution.
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 10-23-2012, 09:47 AM   #1
Karvalio
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Rep: Reputation: Disabled
Ubuntu 12.04: undefined reference to `arc4random'


I tried exactly the same thing as this thread:

http://www.linuxquestions.org/questi...ubuntu-729598/

Installed libbsd-dev:
Code:
$ sudo apt-get install libbsd-dev
test.c:
Code:
#include <stdio.h>
#include <stdlib.h>

main()
{
    int x;
    x=arc4random();
    printf("%i\n", x);
    return 0;
}
Tried to compile:
Code:
$ gcc -lbsd -o test test.c
Same error: undefined reference to `arc4random'

Weird, it worked for Greg Marks, but not for me. What could be possibly wrong?

Thanks!

Last edited by Karvalio; 10-23-2012 at 09:48 AM.
 
Old 10-24-2012, 05:39 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153
Welcome to LQ.

Debian / Ubuntu : Hideaway locations for some files in the latest versions.
Ubuntu : from version 11.04 .
Example, location : /usr/lib/i386-linux-gnu/libbsd.so

This will do :
Code:
gcc -lbsd -o test test.c `pkg-config --libs libbsd`
... And the file /usr/lib/i386-linux-gnu/pkgconfig/libbsd.pc
.. will be used to decide the "libbsd" location.

.
 
Old 10-25-2012, 07:05 AM   #3
Karvalio
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Perfect! It worked! Thank you very much!
 
  


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
ntop on Ubuntu: with the error undefined reference to `pcap_parse' pawelch Linux - Newbie 7 11-05-2010 02:44 PM
SQLite3, C++ & Ubuntu - undefined reference to `sqlite3_open' miamagoo Ubuntu 1 06-07-2010 03:25 PM
trouble using arc4random() in C program on Ubuntu Greg Marks Linux - Newbie 2 05-31-2009 01:08 AM
PGPlot in 'C' compiling: undefined reference to `MAIN_` (ubuntu 8.10) SuperNomad Programming 3 02-28-2009 01:33 PM
undefined reference to.... crapodino Programming 1 01-13-2008 08:05 PM


All times are GMT -5. The time now is 06:45 AM.

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