DexterInd / GoPiGo3

The GoPiGo3 is a Raspberry Pi Robot!
https://gopigo.io
Other
96 stars 85 forks source link

Error when compiling leds.cpp #239

Closed forevermirin94 closed 5 years ago

forevermirin94 commented 5 years ago

When I try to compile the leds.cpp program using sudo g++ -o leds leds.cpp ../GoPiGo3.cpp -I.. I get the following errors: /tmp/cc54Rdk4.o:(.data+0x0): multiple definition of spi_file_handle' /tmp/ccr13cUi.o:(.data+0x0): first defined here /tmp/cc54Rdk4.o:(.bss+0x0): multiple definition ofspi_xfer_struct' /tmp/ccr13cUi.o:(.bss+0x0): first defined here /tmp/cc54Rdk4.o:(.bss+0x20): multiple definition of spi_array_out' /tmp/ccr13cUi.o:(.bss+0x20): first defined here /tmp/cc54Rdk4.o:(.bss+0x48): multiple definition ofspi_array_in' /tmp/ccr13cUi.o:(.bss+0x48): first defined here /tmp/cc54Rdk4.o: In function spi_setup()': GoPiGo3.cpp:(.text+0x0): multiple definition ofspi_setup()' /tmp/ccr13cUi.o:leds.cpp:(.text+0x0): first defined here /tmp/cc54Rdk4.o: In function spi_transfer_array(unsigned char, unsigned char*, unsigned char*)': GoPiGo3.cpp:(.text+0x84): multiple definition ofspi_transfer_array(unsigned char, unsigned char, unsigned char)' /tmp/ccr13cUi.o:leds.cpp:(.text+0x84): first defined here /tmp/cc54Rdk4.o: In function fatal_error(char const*)': GoPiGo3.cpp:(.text+0x124): multiple definition offatal_error(char const*)' /tmp/ccr13cUi.o:leds.cpp:(.text+0x124): first defined here /tmp/cc54Rdk4.o:(.bss+0x70): multiple definition of _time' /tmp/ccr13cUi.o:(.bss+0x70): first defined here /tmp/cc54Rdk4.o: In functionget_time()': GoPiGo3.cpp:(.text+0x174): multiple definition of `get_time()' /tmp/ccr13cUi.o:leds.cpp:(.text+0x174): first defined here collect2: error: ld returned 1 exit status

Manufacturer : Dexter Industries Board : GoPiGo3 Serial Number : 0D9DAA74514E3437324A2020FF041C14 Hardware version: 3.x.x Firmware version: 1.0.0 Battery voltage : 4.12 5v voltage : 4.805

g++ version: g++ (Raspbian 6.3.0-18+rpi1+deb9u1) 6.3.0 20170516

I also tried putting the leds.cpp, GoPiGo3.cpp and GoPiGo3.h in one folder and compile it with the following command: sudo g++ -o leds leds.cpp Then I get these errors: /tmp/cclfl8Fd.o: In function main': leds.cpp:(.text+0x1e8): undefined reference toGoPiGo3::detect(bool)' leds.cpp:(.text+0x238): undefined reference to GoPiGo3::set_led(unsigned char, unsigned char, unsigned char, unsigned char)' leds.cpp:(.text+0x258): undefined reference toGoPiGo3::set_led(unsigned char, unsigned char, unsigned char, unsigned char)' leds.cpp:(.text+0x274): undefined reference to GoPiGo3::set_led(unsigned char, unsigned char, unsigned char, unsigned char)' leds.cpp:(.text+0x290): undefined reference toGoPiGo3::set_led(unsigned char, unsigned char, unsigned char, unsigned char)' /tmp/cclfl8Fd.o: In function exit_signal_handler(int)': leds.cpp:(.text+0x374): undefined reference toGoPiGo3::reset_all()' /tmp/cclfl8Fd.o: In function __static_initialization_and_destruction_0(int, int)': leds.cpp:(.text+0x3c4): undefined reference toGoPiGo3::GoPiGo3()' collect2: error: ld returned 1 exit status

What am I doing wrong?