LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-15-2006, 11:06 PM   #1
talent422
LQ Newbie
 
Registered: Jan 2006
Distribution: Fedora Core 4
Posts: 3

Rep: Reputation: 0
Fixed! "Undefined reference to.." errors


FYI,

I had been experiencing "undefined reference to" problems in one of the programs I had been writing. I even tried to use the "-l" option when using gcc, but no luck.

My fix? I changed the extension from ".cpp" to ".c". I have no clue why that worked, but it did...

If anyone has an idea how or why that worked, feel free to post.

 
Old 01-15-2006, 11:48 PM   #2
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
------ *deleted* -----

Last edited by ugenn; 01-15-2006 at 11:50 PM.
 
Old 01-16-2006, 09:51 AM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
I'm moving this to programming.. but I probably know why you had problems.


GCC decides what type of file you have based on the file extension. ".cpp" is a C++ file and ".c" is a C file. The problem probably was a result of you compiling a C++ file with gcc without passing the -lstdc++ option. This can be avoided by compiling C++ programs with the g++ executable instead.
 
  


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
"undefined reference"linker error for static field w/ C++ astorm Programming 5 08-27-2008 04:00 AM
Error: Make on kismet-2005-08-R1 "undefined reference" zeevolking Linux - Software 1 12-23-2005 09:40 PM
Curl - undefined reference "DES_set_odd_parity" - SOLVED sundialsvcs Linux - Software 0 09-15-2005 10:58 AM
Undefined Screen " XFree86" reference by serverLayout "XFree86 Configured" comox *BSD 7 01-17-2005 06:47 PM
Kernel make bzImage error "undefined reference" w/ Prism2.5 USB driver under 2.6 joachimvb Mandriva 1 09-24-2004 08:43 PM


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