LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Fixed! "Undefined reference to.." errors (https://www.linuxquestions.org/questions/programming-9/fixed-undefined-reference-to-errors-403804/)

talent422 01-15-2006 10:06 PM

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.

:)

ugenn 01-15-2006 10:48 PM

------ *deleted* -----

jtshaw 01-16-2006 08:51 AM

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.


All times are GMT -5. The time now is 10:13 AM.