Linker Error Undefined Reference To Makefile
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might makefile undefined reference to function have Meta Discuss the workings and policies of this site About make undefined reference to function Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting
Make Undefined Reference To Main
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2
C Undefined Reference To Function
million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Solving “undefined reference to” errors in a makefile up vote 2 down vote favorite I have a few custom source files in my src directory and a few source files from the Arduino project in my src/base directory. undefined reference to function c++ I compile all source files into objects which are stored in my obj directory using the following make rules: PATHOBJ := obj/ PATHSRC := src/ PATHBIN := bin/ PATHLIB := lib/ PATHTMP := tmp/ PATHARDUINO = $(PATHSRC)base/ enter code here $(PATHOBJ)core_%.o : $(PATHARDUINO)%.c @mkdir -p $(dir $@) $(GCC) $(ALL_CORE_CFLAGS) -c $< -o $@ $(PATHOBJ)bot_%.o : $(PATHSRC)%.c @mkdir -p $(dir $@) $(GCC) $(CFLAGS)-c $< -o $@ As you can see it would compile src/tacho.c to obj/bot_tacho.o and src/base/wiring_analog.c to obj/core_wiring_analog.o. In my makefile I compile all of my source files without any problems. In one of these files (namely src/tacho.c) I have added the following include: #include "base/wiring.h" which contains the prototype to analogRead. The funny thing is that wiring.h only contains the prototype to the 'analogRead' function. It doesn't even bother to include the files that actually define the function, but some nosing around led me to discover that the definition of the function was to be found in src/base/wiring_analog.c. I reckoned i
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
Linker Input File Unused Because Linking Not Done
Learn more about Stack Overflow the company Business Learn more about hiring developers or makefile in c posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow c++ undefined reference to Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Undefined reference maybe makefile is wrong? up vote http://stackoverflow.com/questions/6214211/solving-undefined-reference-to-errors-in-a-makefile 2 down vote favorite 1 I had some issues earlier with declaring my array set of records. Now I think there is something wrong with my Makefile or something. Here is my Makefile: EEXEC = proj1 CC = gcc CFLAGS = -c -Wall $(EXEC) : main.o set.o $(CC) -o $(EXEC) main.o set.o main.o : main.h main.c $(CC) $(CFLAGS) main.c set.o : set.h set.c $(CC) $(CFLAGS) set.c There are http://stackoverflow.com/questions/4130681/undefined-reference-maybe-makefile-is-wrong more functions I have in my set.c file but these are the functions I am testing at the moment: DisjointSet *CreateSet(int numElements); DisjointSet *MakeSet(DisjointSet *S,int ele, int r); void Print(DisjointSet *S); And the errors I am receiving in the terminal is: main.o: In function `main': main.c:(.text+0x19): undefined reference to `CreateSet' main.c:(.text+0x43): undefined reference to `MakeSet' main.c:(.text+0x5f): undefined reference to `Print' c makefile share|improve this question edited Nov 9 '10 at 5:18 asked Nov 9 '10 at 5:04 Jeremy 64228 1 Highlight and press the 0101 button for code formatting :) –Scott Wales Nov 9 '10 at 5:17 Fixed that, most of it. Still getting use to the formatting. –Jeremy Nov 9 '10 at 5:19 add a comment| 3 Answers 3 active oldest votes up vote 5 down vote accepted The errors that you're getting are linker errors, telling you that while linking your program the linker can't find a function named 'CreateSet' (etc.). It's not immediately obvious why that should be the case, because it appears that you're including "set.o" in the build command. To troubleshoot build problems, it's often useful to figure out what make is trying to do, and then run the commands individually on
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 Business Learn http://stackoverflow.com/questions/12507333/cannot-compile-with-makefile-undefined-reference-to-boostre-detail more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags http://stackoverflow.com/questions/19885200/make-fails-to-compile-undefined-reference-to-evp-digestupdate Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Cannot compile with makefile - undefined reference to `boost::re_detail up vote 0 down vote favorite I got an assignment to improve running time of some code. undefined reference The only problem is, I can't even compile it to run it on my machine in the first place. Every time I try, it stops somewhere in the midst of compiling saying this: "undefined reference to `boost::re_detail::put_mem_block(void*)' collect2: ld returned 1 exit status make: * [cpu] Error 1" This is how makefile looks: SHELL = /bin/bash OBJECTS = main.o atom.o molecule.o charges.o pdb.o asa.o amino.o chain.o addition.o string_operation.o pdb_peptide.o protein_chain.o residue_atom.o chain_residue.o residue_contact.o atom_grid.o circles.o atom_space_calculations.o OBJDIR undefined reference to = obj VPATH = src:src/ext:$(OBJDIR) CFLAGS = -O3 -Wall -lm -lboost_regex -L/usr/local/boost/lib HDIRS = src,src/ext,src/qt_redistributable, usr/lib, usr/local/lib, usr/local/lib/include/boost, /usr/local/lib/lib/ IOPTS = $(addprefix -I, $(HDIRS)) cpu : $(addprefix $(OBJDIR)/, $(OBJECTS) $(CPUOBJS)) g++ $(CFLAGS) -o mcpu $^ $(OBJDIR)/%.o : %.cpp g++ $(CFLAGS) $(IOPTS) -c $< -o $@ clean : rm obj/*.o $(PROG) I'm using Linux Mint x64 and I have tried everything I googled out. Installed the whole boost library in usr/local/lib (for no obvious reason because it didn't help), tried to edit LD PATH (I'm very new to Linux and I have no idea if that went right) and lots of stuff, but this thing doesn't seem to go through. Any help appreciated. linux boost reference undefined mint share|improve this question edited Sep 20 '12 at 19:09 Obaid 794927 asked Sep 20 '12 at 6:48 darxsys 6821924 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted One problem with your makefile happens when you link your program. As you can see in these questions with g++ the order of your arguments at link time is really important. You need to put your libraries after your object files. One easy way to solve would be separating your linker flags (LDFLAGS) from the compiler flags (CFLAGS), and then putting LDFLAGS after $^ (your object files) in the link command. CFLAGS = -O3 -Wall L
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 Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up make fails to compile, undefined reference to `EVP_DigestUpdate up vote 2 down vote favorite I am trying to install an open source project on my ubuntu 13:04 but the make process fails on a method in a class called updateDB.c. During compilation, i have this error : updateDB.o: In function `update_cache_hash': /usr/local/src/bgpinspect-0.5/src/updateDB.c:142: undefined reference to `EVP_DigestUpdate' /usr/local/src/bgpinspect-0.5/src/updateDB.c:143: undefined reference to `EVP_DigestFinal_ex' collect2: error: ld returned 1 exit status make[1]: *** [BGPdb] Error 1 make[1]: Leaving directory `/usr/local/src/bgpinspect-0.5/src' make: *** [all] Error 2 This is the method update_cache_hash that fails : static uint16_t update_cache_hash( char *buff, int size ) { unsigned char md_hash[EVP_MAX_MD_SIZE]; unsigned int md_len; uint16_t hash; EVP_DigestUpdate(&global_table.ctx, buff, size ); EVP_DigestFinal_ex(&global_table.ctx, md_hash, &md_len); if ( md_len < 2 ) { ps_log( PS_LOG_ERROR, "EVP_DigestFinal_ex returned a short hash.\n" ); return 0; } hash = ( (uint16_t) md_hash[md_len - 2] << 8 ) | md_hash[md_len - 1]; hash = UPDATE_CACHE_MASK( hash ); return hash; } The top of this class has an include statement #include