5

For a program I was linking the static glibc library (which I modified). My makefile looks something like this.

CXX = g++ CXXFILES = main.c CXXFLAGS = -g -o prog -D_GNU_SOURCE LIBS = ../../nptl/libpthread.a ../../libc.a -lpthread all: $(CXX) $(CXXFILES) $(LIBS) $(CXXFLAGS) 

However, instead of using the static *.a files, I now want to use the dynamic shared object *.so files. Is it enough to replace the *.a files by *.so files in the makefile. If not what is the correct way of doing so. I tried to simply replace the *.a with *.so files in the makefile, but it seems like when I do that the program uses the original glibc (rather than my modified one).

5

1 Answer 1

8

If you don't want to use the standard libraries, you might need the -nostdlib flag. In addition, if you want to dynamically link libraries, you need to tell the linker where they are. -L/dir/containing -lc.

If you don't want to set a LD_LIBRARY_PATH when executing, you'll need to set rpath, -Wl,--rpath=/path/containing.

Sign up to request clarification or add additional context in comments.

1 Comment

Points for pointing out what --rpath does. So that's why so many projects I've downloaded require LD_LIBRARY_PATH in their build.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.