Function Main Error Undefined Reference To
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 Us Learn more about Stack Overflow the company
Undefined Reference To Function C Programming
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs undefined reference to a function c++ Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just how to solve undefined reference error in c like you, helping each other. Join them; it only takes a minute: Sign up In C programming, what is `undefined reference`error, when compiling? [duplicate] up vote 4 down vote favorite 1 This question already has an answer
C Undefined Reference To Function In Header File
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
Undefined Reference Error In C Compilation
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,34431023 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 program you need to give both Main.o and Person.o as inputs. Build usually is done in two steps (1) compilation and (2) linking. To compile your sources do: $ gcc -c -o Main.o Main.c $ gcc -c -o Person.o Person.o Then the resulting object files must be linked into a single executable:
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 c undefined reference to pthread_create About Us Learn more about Stack Overflow the company Business Learn more about
C Undefined Reference To Variable
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join undefined reference to function in c linux the 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 main.o:main.c:function main: error: undefined reference http://stackoverflow.com/questions/29998485/in-c-programming-what-is-undefined-referenceerror-when-compiling to 'variable_name' up vote 0 down vote favorite I am a complete newbie to C (started 6 hours ago) and I know there are a wealth of online references that I should (and will) look at in detail, but for now, I have an emergency and need help. I have a project folder containing the following files: boundary_val.c boundary_val.h helper.c helper.h init.c init.h main.c main.o http://stackoverflow.com/questions/23224397/main-omain-cfunction-main-error-undefined-reference-to-variable-name sor.c sor.h uvp.c uvp.h visual.c visual.h makefile main.c should call these other functions found in the listed files. the makefile reads as follows: CC = gcc CFLAGS = -Wall -pedantic -Werror .c.o: ; $(CC) -c $(CFLAGS) $< OBJ = helper.o\ init.o\ boundary_val.o\ uvp.o\ main.o\ sor.o\ visual.o all: $(OBJ) $(CC) $(CFLAGS) -o sim $(OBJ) -lm %.o : %.c $(CC) -c $(CFLAGS) $*.c -o $*.o clean: rm $(OBJ) helper.o : helper.h init.o : helper.h init.h boundary_val.o: helper.h boundary_val.h uvp.o : helper.h uvp.h visual.o : helper.h sor.o : sor.h main.o : helper.h init.h boundary_val.h uvp.h visual.h sor.h when I run make main in the terminal i get the following error: gcc main.o -o main main.o:main.c:function main: error: undefined reference to 'read_parameters' main.o:main.c:function main: error: undefined reference to 'matrix' main.o:main.c:function main: error: undefined reference to 'matrix' main.o:main.c:function main: error: undefined reference to 'matrix' main.o:main.c:function main: error: undefined reference to 'matrix' main.o:main.c:function main: error: undefined reference to 'init_uvp' main.o:main.c:function main: error: undefined reference to 'calculate_dt' main.o:main.c:function main: error: undefined reference to 'boundaryvalues' main.o:main.c:function main: error: undefined reference to 'calculate_fg' main.o:main.c:function main: error: undefined reference to 'calculate_rs' main.o:main.c:function main: error: undefined reference to 'sor' main.o:main.c:function main: error: undefined reference to 'ca
at..., Up:Compile-time errors undefined reference to... This error is often generated because you have typed the name of a undefined reference function or variable incorrectly. For example, the following code: #include