LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-09-2011, 05:42 PM   #1
linuxcub
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Rep: Reputation: Disabled
"undefined reference"


Hi guys,

I'm trying to link the following code in linux:

#include "./rsl-v1.42/rsl.h"
void main(int argc, char **argv)
{
Radar *radar;
radar = RSL_anyformat_to_radar("CAT091013010219.RAWLM7B", NULL);
}

with the command line: cc -o code code.o

and in which the function RSL_anyformat_to_radar in declared inside rsl.h

and I receive the following error:

code.o: In function `main':
code.c.text+0x19): undefined reference to `RSL_anyformat_to_radar'
collect2: ld returned 1 exit status

could anybody help me?

thanks a lot
 
Old 08-09-2011, 05:58 PM   #2
allwimb
Member
 
Registered: Aug 2011
Posts: 47

Rep: Reputation: Disabled
when you get a such error that means that the function you're calling doesn't exist or it hasn't been defined. Check if it exists in the header you included.

spring logout

Last edited by allwimb; 12-12-2011 at 05:41 AM.
 
0 members found this post helpful.
Old 08-09-2011, 06:15 PM   #3
linuxcub
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
thanks for quick replying allwimb

the function in question is declared inside rsl.h as:


/* Prototypes for functions. */
/* Alphabetical and grouped by object returned. */


Radar *RSL_africa_to_radar(char *infile);
Radar *RSL_anyformat_to_radar(char *infile, ...);
Radar *RSL_dorade_to_radar(char *infile);

any other suggestion?
 
Old 08-10-2011, 12:28 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by allwimb View Post
when you get a such error that means that the function you're calling doesn't exist or it hasn't been defined. Check if it exists in the header you included.
This is incorrect. It's a linker error. You need to link the object files containing the code for the functions you're using. For gcc, you'd use the -l option (if you have e.g. "libradar.so"), or just put the object files on the command line (e.g. gcc -o code code.o radar.o). Check the man page for your compiler to see what the options are. Presumably, they'll be similar though.

Edit: actually, you're probably using gcc, aren't you?

Last edited by Nylex; 08-10-2011 at 12:51 AM.
 
1 members found this post helpful.
Old 08-10-2011, 12:50 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply



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
Error when "make" the source of CosmoMC: undefined reference to `dpotrf_' limh Linux - Software 1 09-30-2009 02:27 PM
"Multiple definition of" and "undefined reference to" in QT Creator with QJson lib echelon89 Programming 1 05-01-2009 06:48 AM
"undefined reference"linker error for static field w/ C++ astorm Programming 5 08-27-2008 03:00 AM
Undefined Screen " XFree86" reference by serverLayout "XFree86 Configured" comox *BSD 7 01-17-2005 05:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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