User avatar
mad-hatter
Posts: 419
Joined: Sun Feb 26, 2012 2:58 pm
Location: By the UK seaside

A question on Geany.

Tue Sep 04, 2012 7:49 pm

Hello,

Trying to buid a 'C' program that uses bcm2835.h, with this command in a teminal

"gcc -o myprog myprog.c -l bcm2835"

Compiles and runs fine. sudo ./myprog

In Geany, compiles fine, no errors.
If I try a build or execute, lots of errors,
complaining about undefined reference to 'bcm2835'.

Is there something I set in Geany to get round this?

Regards

User avatar
PeterO
Posts: 5623
Joined: Sun Jul 22, 2012 4:14 pm

Re: A question on Geany.

Tue Sep 04, 2012 8:11 pm

You need to create a project (if you havn't done so already).

Menu Project / Properties / Build

Add "-l bcm2835" to the end of the Build command . <<<<< AARRGGHHH typo !!!! Should be -lbcm2835 with no space !

HTH

PeterO
Last edited by PeterO on Tue Jul 11, 2017 6:37 am, edited 1 time in total.
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
mad-hatter
Posts: 419
Joined: Sun Feb 26, 2012 2:58 pm
Location: By the UK seaside

Re: A question on Geany.

Wed Sep 05, 2012 3:38 pm

Hi

Thanks for the help, changed things as below and everything works fine.

Geany / Project / Properties / Build

Compile :- gcc -Wall -c "%f"
Build :- gcc -Wall -o "%e" "%f" -l bcm2835
Execute :- "sudo" "./%e"

Regards

miaomiao
Posts: 22
Joined: Fri Jun 30, 2017 4:07 am

Re: A question on Geany.

Tue Jul 11, 2017 3:45 am

PeterO wrote:You need to create a project (if you havn't done so already).

Menu Project / Properties / Build

Add "-l bcm2835" to the end of the Build command .

HTH

PeterO

Dear Sir,
I am trying to use urg04lx laser scanner on Raspberry Pi 2 use Geany (c language). When scanner receive 10 data, it will need to check whether the data larger than 30mm,if yes light up one LED. So I have to use bcm2835 library and urg library. After many times tries. I changed my build command in Geany to

compile: gcc -Wall -c "%f" -l / home/pi/urg_library/include/c -l bcm2835 -lm working directory: /home/pi/urg_library/samples/c
build: gcc -Wall -o "%e"*h working directory: /home/pi/urg_library/samples/c
make: make working directory: /home/pi/urg_library/samples/c

I can bulid and compile succefully, but make failed. Geany showed:

make (in directory: /home/pi/urg_library/samples/c)
gcc -O2 -I../../include/c -c -o open_urg_sensor.o open_urg_sensor.c
make: Warning: File '../../build_rule.mk' has modification time 40310815 s in the future
gcc -O2 -I../../include/c sensor_parameter.c open_urg_sensor.o ../../src/liburg_c.a -lm `/bin/sh ld_wsock.sh` `/bin/sh ld_setupapi.sh` -o sensor_parameter
gcc -O2 -I../../include/c -c -o get_distance.o get_distance.c
gcc get_distance.o open_urg_sensor.o ../../src/liburg_c.a -lm `/bin/sh ld_wsock.sh` `/bin/sh ld_setupapi.sh` -o get_distance
get_distance.o: In function `main':
get_distance.c:(.text.startup+0x10): undefined reference to `bcm2835_init'
get_distance.c:(.text.startup+0x30): undefined reference to `bcm2835_gpio_fsel'
get_distance.c:(.text.startup+0x38): undefined reference to `bcm2835_gpio_set'
<builtin>: recipe for target 'get_distance' failed
collect2: error: ld returned 1 exit status
make: *** [get_distance] Error 1
Compilation failed.

What should I do? Thank you very much.

User avatar
PeterO
Posts: 5623
Joined: Sun Jul 22, 2012 4:14 pm

Re: A question on Geany.

Tue Jul 11, 2017 6:38 am

See my edit to previous reply from 2012 !!! :oops: . Remove the space between -l and bcm2835
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

miaomiao
Posts: 22
Joined: Fri Jun 30, 2017 4:07 am

Re: A question on Geany.

Tue Jul 11, 2017 6:53 am

PeterO wrote:See my edit to previous reply from 2012 !!! :oops: . Remove the space between -l and bcm2835
PeterO

Thank you, I removed the space already. Still could not make.
Build and compile are successful. Make failed with same error message I posted previously.

Return to “C/C++”