moffelnijdam
moffelnijdam

Reputation: 5

How do i include a (GPIO) library in my makelfile? (On the Raspberry Pi)

So, I have a simple c program on my Raspberry Pi, that is using the GPIO pins. When I compile it, i have to add -l bcm2835 after the gcc for the library of the GPIO.

Now I have another program which I have to compile with make, so I have to edit my Makefile to include this bcm2835 library.

I know the basics of a makefile but wherever I try to put it in my makefile, it's not working.

Can I have a simple answer to where I have to edit my makefile, it would be highly appreciated.

Upvotes: 0

Views: 473

Answers (1)

Gil
Gil

Reputation: 1538

You can pass it as you would with any other flag.

#makefile

CC=gcc
CFLAGS= -g -c -Wall 
MYLIB= -lbcm2835
program:   dependencies 
 <  TAB IT!>${CC} ${CFLAGS} ${MYLIB} -o Obj dependencies

Upvotes: 1

Related Questions