Michael Bohanan
Michael Bohanan

Reputation: 5

How do I permanantly add a path to the g++ compiler?

I'm currently using a non standard c++ library in my programs, but linking the library everytime I run the code is getting annoying. Right now I'm using

c++ file.cpp -o file -L/path/to/lib -lLibName

I tried the following:

CPLUS_INCLUDE_PATH=/path/to/lib
export CPLUS_INCLUDE_PATH

but it neither solved the issue nor gave me an error. What am I doing wrong?

Upvotes: 0

Views: 54

Answers (1)

R Sahu
R Sahu

Reputation: 206567

A better option would be use a makefile and run make.

You can edit the makefile to add the necessary compiler and linker options.

GNU Make uses many implicit variables. For your use case, the contents of the Makefile can be as simple as:

CXXFLAGS = -Wall
LDFLAGS = -L/path/to/lib -lLibName

Upvotes: 3

Related Questions