pythonic
pythonic

Reputation: 21589

How to link static glibc in your makefile

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

Answers (2)

pythonic
pythonic

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

wallyk
wallyk

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

Related Questions