7 years, 6 months ago.

undefined reference to

Hello,

I use SW4STM32 to program a STM32F429-DISCO with mbed, but when I compile, I have some error "undefined reference to". However the includes are there.

Someone knows what I are my faults?

main.cpp

#include "../mbed/mbed.h"
			
DigitalOut led1(LED1);
DigitalIn led2 (LED2);
Timer timer;

int main(void)
{
	int begin, end;

	for(;;){
		timer.start();
		led1 = !led1;
		end = timer.read_us();
		printf("Toggle the led takes %d us", end - begin);

	        wait(500);
	}
}

/../src/../mbed/drivers/DigitalIn.h:60: undefined reference to `gpio_init_in'
src/main.o: In function `mbed::DigitalOut::DigitalOut(PinName)':
/../src/../mbed/drivers/DigitalOut.h:55: undefined reference to `gpio_init_out'
src/main.o: In function `main':
/../src/main.cpp:27: undefined reference to `mbed::Timer::start()'
/../src/main.cpp:29: undefined reference to `mbed::Timer::read_us()'
src/main.o: In function `__static_initialization_and_destruction_0(int, int)':
/../src/main.cpp:17: undefined reference to `mbed::Timer::Timer()'
collect2.exe: error: ld returned 1 exit status
make: *** [test.elf] Error 1

Hello !! I am facing the same problems with mine. This problems seems to be there with many of us, but cant find any feasible solutions online. If you have found a solution or a workaround, could you please let me know?

posted by Sathyaprakash Heramba 29 Oct 2017

2 Answers

6 years, 10 months ago.

I have the same issue, any clue?

6 years, 10 months ago.

Can you try with :

#include "mbed.h"

instead ? Remove "../mbed/"