C Undefined Reference Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About undefined reference to function error in c Us Learn more about Stack Overflow the company Business Learn more about hiring undefined reference error in c compilation developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the c undefined reference to pow Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up In C programming, what is `undefined c undefined reference to sqrt reference`error, when compiling? [duplicate] up vote 4 down vote favorite 1 This question already has an answer here: What does the “undefined reference to varName” in C mean? 6 answers I have this following simple program I am trying to compile in linux ubuntu. Main.c: #include
C Undefined Reference To Main'
Person1_Constructor(const int age, const int salary) { struct Person1 p; p.age = age; p.salary = salary; return p; }; Person.h: struct Person1 { int age, salary; }; struct Person1 Person1_Constructor(const int age, const int salary); Why do I get the following error ? /tmp/ccCGDJ1k.o: In function `main': Main.c:(.text+0x2a): undefined reference to `Person1_Constructor' collect2: error: ld returned 1 exit status I am using gcc Main.c -o Main to compile. c undefined-reference share|improve this question edited May 2 '15 at 6:07 asked May 2 '15 at 4:44 dimitris93 1,33921023 marked as duplicate by alkc Users with the c badge can single-handedly close c questions as duplicates and reopen them as needed. May 2 '15 at 6:05 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. @Satya uh, why ? I have a Person.c and a Person.h whats wrong with that ? –dimitris93 May 2 '15 at 4:46 gcc two .c files together –user3528438 May 2 '15 at 4:48 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted When you link the progr
at..., Up:Compile-time errors undefined reference to... This c undefined reference to pthread_create' error is often generated because you have typed the name of a http://stackoverflow.com/questions/29998485/in-c-programming-what-is-undefined-referenceerror-when-compiling function or variable incorrectly. For example, the following code: #include
Specific Boards Linux Programming Can't Compile a code!!! I ran into "undefined reference to" error. Getting started with C or http://cboard.cprogramming.com/linux-programming/139019-cant-compile-code-i-ran-into-undefined-reference-error.html C++ | C Tutorial | C++ Tutorial | C and C++ FAQ http://www.linuxquestions.org/questions/programming-9/several-undefined-reference-to-error-when-compiling-a-c-programm-186781/ | Get a compiler | Fixes for common problems Thread: Can't Compile a code!!! I ran into "undefined reference to" error. Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 06-21-2011 #1 andereasmehdi View undefined reference Profile View Forum Posts Registered User Join Date Jun 2011 Posts 10 Can't Compile a code!!! I ran into "undefined reference to" error. hi i use cyqwin machine and i am new in linux. i can not compile a code i ran into these errors: ngram-count.o:ngram-count.cc: (.text+0xa9): undefined reference to `_Opt_Parse' ngram-count.o:ngram-count.cc: (.text+0x11f): undefined reference to `Vocab::Vocab(unsigned int, unsigned int)' ngram-count.o:ngram-count.cc: c undefined reference (.text+0x204): undefined reference to `SubVocab::SubVocab(Vocab&)' ngram-count.o:ngram-count.cc: (.text+0x245): undefined reference to `StopNgramStats::StopNgramStats(Vocab&, SubVocab&, unsigned int)' ngram-count.o:ngram-count.cc: (.text+0x2b5): undefined reference to `File::File(char const*, char const*, int)' ngram-count.o:ngram-count.cc: (.text+0x2f7): undefined reference to `File::~File()' ngram-count.o:ngram-count.cc: (.text+0x31f): undefined reference to `File::File(char const*, char const*, int)'.......................... I checked the include addresses in makefile and all are right. can anybody help me and give me some tips? Thanks 06-21-2011 #2 tabstop View Profile View Forum Posts and the Hat of Guessing Join Date Nov 2007 Posts 14,185 You need to make sure you are compiling all the source files, and then linking together the .o files. So either you've got all the files, and just never bothered to write those six functions, or you are missing the file that contains those functions. 06-21-2011 #3 dwks View Profile View Forum Posts Visit Homepage Frequently Quite Prolix Join Date Apr 2005 Location Canada Posts 8,055 Looks like this ngram-count program is from somewhere on the internet, perhaps the OP didn't write this code. Can you show more output? What make command are you running precisely? Where did you get this
Search Tutorials/Articles Search HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Non-*NIX Forums > Programming Several "undefined reference to" error when compiling a C programm User Name Remember Me? 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 Welcome to LinuxQuestions.org, a friendly and active Linux Community. You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today! Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Are you new to LinuxQuestions.org? Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here. Having a problem logging in? Please visit this page to clear all LQ-related cookies. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click Here to receive this Complete Guide absolutely free. Search this Thread 05-27-2004, 11:27 PM #1 acer_peri Member Registered: Nov 2003 Location: Beijing, China Distribution: Tettnang Posts: 38 Rep: Several "undefined reference to" error when compiling a C programm the program is from Linux.org Code: #include