I have
Code:
$HOME/.local/lib
$HOME/.local/include
And in my .bashrc
Code:
[[ -d ~/.local/include ]] && export CPATH="$HOME/.local/include:$CPATH"
[[ -d ~/.local/lib ]] && export LIBRARY_PATH="$HOME/.local/lib:$LIBRARY_PATH"
I have a file example.h:
Code:
#ifndef __EXAMPLE_H__
#define __EXAMPLE_H__
void example();
#endif
And I file example.cc:
Code:
#include <example.h>
#include <iostream>
using std::cout;
using std::endl;
void example()
{
cout << "Hello, World!" << endl;
}
I'm creating libexample.a
Code:
$ g++ -O2 -Wall -c example.cc
$ ar rsv libexample.a example.o
and placing the header and archive in the appropriate directory.
If I have a utility that uses the library, compiling like this works fine:
Code:
$ g++ -Wall main.cc -lexample
Is there a way not to need the -l? Is the term auto-linking?
Any other comments or suggestions in my attempt at a personal library?