0

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 2

1

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
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .