c++ - compilation with Makefile fail but success in command line -
I was using a makefile to compile my project and successfully compiled, but when I got a new Lib (Libbcm2835.a) The linked linker (-LBCM 2835) fails, otherwise it compiles and links with any error when using the following commands:
GCC - C ihome _ *. C gcc -o iHome_Start ihome * .o-lbcm2835 - Makefile: # Name of the project (with this name is executable) Target = iHome_Start CC = GCC # Ready to flag here Do CFLAGS = -std = c99 -Wall-I LINKER = GCC-O # Tilt the link here LFLAGS = -lpthread -lbcm2835 # Change this to set the appropriate directory where each file should be SRCDIR =. OBJDIR = BINDIR =. Source: = $ (Wildcard $ (SRCDDR) / * .c) includes: = $ (Wildcard $ (SRCDIR) / * .h) Objects: = $ (Source: $ (SRCDIR) /%. C = $ ( OBJDIR) /%.o) RM = RM-F $ (BINDR) / $ (target): $ (objects) @ $ (link) $ @ $ (LFALGS) $ (objects) @ one "linking complete!" $ (Objects): $ (objdir) /% O: $ (SRCDDI) /% C @ $ (CC) $ (CFLAGS) -C $ < -o $ @ @oo "compiled" $ & lt; "Successfully!" .phone: Clearly clean: @ $ (rm) $ (objects) @ one "cleanup complete!" .PHONEY: Remove Remove: Clear @ $ (RM) $ (BINDR) / $ (target) @ Echo "executable deleted!"
problem
$ $ in liner) $ @ $ (LFLAGS) $ (objects) Linker presents arguments in those orders that they appear. As long as he looks at the libraries, he did not find any object file, so there were no unresolved symbols, so it does not draw anything from the libraries. Swap $ (OBJECTS) and $ (LFLAGS) :
@ $ (LINKER) $ @ $ (objects) $ (LFLAGS) I also recommend renaming I LFLAGS to LIBRARIES .
Comments
Post a Comment