Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

link "make" command to lib and include

Writer Mia Lopez

I want to use make command and link it to the include and lib path.

I am using :

make -I /path_to_include - L /path_to_lib

but it gives me:

nothing to be done for /path_to_lib

(The path is correct.)

2 Answers

You can use below “make” command to link lib and include,

make <filename_without_extension> LDLIBS="-l<lib1> -l<lib2>"

suppose you have server1.cpp file to compile using make command,

make server1 LDLIBS="-lcpprest -lpthread -lssl -lcrypto" LDFLAGS="-L/usr/lib/" CXXFLAGS="-I/usr/include/"

Output will expand the compilation command as,

g++ -I/usr/include/ -L/usr/lib/ server1.cpp -lcpprest -lpthread -lssl -lcrypto -o server1

make does not accept options like -L /path/to/somewhere - these are arguments that need to be given to the compiler and make will not pass them on. You probably need to edit the Makefile appropriately.

Depending on the Makefile, it will often use a variable like CFLAGS, LIBS or LDFLAGS to pass extra options to the compiler. You can set these when you run make: LIBS=-lmylib LDFLAGS=-L/path/to/mylib make. This relies on the Makefile having been written to use such variables however, which one generated by a system like autoconf probably will, but one written by hand may not.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy