Reputation: 21589
I have compiled glibc
which produced libc.a
as a result. How can I link this in makefile. The makefile currently looks something like this.
CXX = g++
CXXFILES = file1.cpp file2.cpp file3.cpp
CXXFLAGS = -O3 -o prog -D_GNU_SOURCE
LIBS = -lpthread
all:
$(CXX) $(CXXFILES) $(LIBS) $(CXXFLAGS)
clean:
rm -f prog *.o
Upvotes: 1
Views: 5780
Reputation: 21589
Modify it like this. Replace LIBPATH with the path where libc.a
is placed.
CXX = g++
CXXFILES = file1.cpp file2.cpp file3.cpp
CXXFLAGS = -O3 -o prog -D_GNU_SOURCE
LIBS = -LIBPATH/libc.a -lpthread
all:
$(CXX) $(CXXFILES) $(LIBS) $(CXXFLAGS)
clean:
rm -f prog *.o
Upvotes: 0
Reputation: 57764
Change the libraries line to be like this:
LIBS = -lc -lpthread
If libc.a
is not in the usual directory, change the library path to look in your directory first.
Upvotes: 1