Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 01-15-2006, 10:06 PM   #1
LQ Newbie
Registered: Jan 2006
Distribution: Fedora Core 4
Posts: 3

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


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, 10:48 PM   #2
Registered: Apr 2002
Posts: 549

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

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

Rep: Reputation: 67
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.


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 03:00 AM
Error: Make on kismet-2005-08-R1 "undefined reference" zeevolking Linux - Software 1 12-23-2005 08:40 PM
Curl - undefined reference "DES_set_odd_parity" - SOLVED sundialsvcs Linux - Software 0 09-15-2005 09:58 AM
Undefined Screen " XFree86" reference by serverLayout "XFree86 Configured" comox *BSD 7 01-17-2005 05:47 PM
Kernel make bzImage error "undefined reference" w/ Prism2.5 USB driver under 2.6 joachimvb Mandriva 1 09-24-2004 07:43 PM > Forums > Non-*NIX Forums > Programming

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