How to specify a library path?

The following example works using my Keyboard library included in quotes
#include "Keyboard.h"

Is there a way to make the include work with angled brackets?
#include <Keyboard.h>

I tried using the -l option without success, probably doing it wrong.

Keyboard.h
1
2
3
4
5
6
7
8
9
10
11
// emuliate arduino-1.0.5\hardware\teensy\cores\usb_hid\usb_api.h
#ifndef Keyboard_h
#define Keyboard_h

class usb_keyboard_class
{
	public:
		void print(char const * const str);
};
extern usb_keyboard_class Keyboard;
#endif 


Keyboard.cpp
1
2
3
4
5
6
7
8
// emuliate arduino-1.0.5\hardware\teensy\cores\usb_hid\usb_api.cpp
#include "Keyboard.h"
#include <iostream>

void usb_keyboard_class::print(char const * const str) { std::cout << str; }

// Preinstantiate Objects //////////////////////////////////////////////////////
usb_keyboard_class Keyboard;


main.cpp
1
2
3
4
5
6
7
#include "Keyboard.h" // this works
//#include <Keyboard.h> // fatal error: Keyboard.h: No such file or directory

int main()
{
	Keyboard.print("test");
}


Makefile
1
2
3
4
5
6
7
8
9
10
all: a.exe

a.exe: main.o Keyboard.o
	g++ -o $@ $^

main.o: main.cpp
	g++ -c $^

Keyboard.o: Keyboard.cpp Keyboard.h
	g++ -c $^


Thank you for taking a look.
man gcc wrote:
-isystem dir
Search dir for header files, after all directories specified by -I but before the standard system directories. Mark it as a system directory, so that it gets the same special treatment as is applied to the standard system directories. If dir begins with "=", then the "=" will be replaced by the sysroot prefix; see --sysroot and -isysroot.
Last edited on
Hi ne555,

None of it makes sense to me. Is there a book that explains this stuff?

This is my attempt at -isystem in the Makefile:
1
2
3
4
5
6
7
8
9
10
all: a.exe

a.exe: main.o Keyboard.o
	g++ -o $@ $^

main.o: main.cpp
	g++ -c $^

Keyboard.o: Keyboard.cpp Keyboard.h
	g++ -c $^ -isystem .


D:\wolf\Documents\teensy\demo_MinGW\library>make
g++ -c main.cpp
main.cpp:2:76: fatal error: Keyboard.h: No such file or directory
 #include <Keyboard.h> // fatal error: Keyboard.h: No such file or directory
                                                                            ^
compilation terminated.
make: *** [main.o] Error 1



Thank you.
Last edited on
Thank you ne555 for the -isystem suggestion, it was perfect.

This book explains static library creation very nicely:
An Introduction to GCC by Brian Gough, 2004 http://www.network-theory.co.uk/docs/gccintro/index.html

This Makefile works as intended:
1
2
3
4
5
6
7
8
9
10
all: a.exe

a.exe: main.cpp libKeyboard.a Keyboard.o
	g++ -Wall -isystem . main.cpp -L. -lKeyboard -o $@

libKeyboard.a: Keyboard.o
	ar cr libKeyboard.a Keyboard.o

Keyboard.o: Keyboard.cpp Keyboard.h
	g++ -Wall -c Keyboard.cpp
Topic archived. No new replies allowed.