Rapid Prototyping for general microcontroller applications, Ethernet, USB and 32-bit ARM® Cortex™-M3 based designs

Undefined Reference to gpio_init_out although included

19 Aug 2016

Hello,

I just started programming on the LPC1768 and I am now facing some issues regarding the Linker/Compiler of the LPCXpresso IDE. Actually I am programming with Keil uVision since many years, unfortunately the code size limit here is not big enough. That's very unfortunately, because generating Binary-Files with uVision works perfectly.

I just wanted to compile and link the mbed blinky template for my LPC1768 on LPCXpresso.

1. I opened the mbed online compiler and added a new project. Platform LPC1768, Template: Blinky LED Hello World, and checked the point "Update this program and libraries to latest version" (Actual Revision is 123)

2. I exported the project for LPCXpresso

3. I opened LPCXpresso and imported the zip file.

4. My first "Build All" gave the following errors:

c:/nxp/lpcxpresso_8.2.0_647/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld.exe: unrecognized option '-T'
c:/nxp/lpcxpresso_8.2.0_647/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld.exe: use the --help option for usage information
collect2.exe: error: ld returned 1 exit status
make: *** [mbed_blinky.axf] Error 1


14:11:16 Build Finished (took 539ms)

5. After googling I found out that is has something to do with the Linker Scripts, so I checked the following settings: -> Properties for mbed_blinky-project, C/C++ Build, Settings, Tools Settings, MCU c++ Linker, Managed Linker Script:

The checkmark for Manage Linker Script was not checked. The Linker script referenced to "${workspace_loc:/${ProjName}/None}"

6. Now I tried two ways. The first way was deleting the linker script reference. This led to the following error:

./main.o: In function `mbed::DigitalOut::DigitalOut(PinName)':
C:\Users\***\Documents\LPCXpresso_8.2.0_647\workspace\mbed_blinky\mbed/DigitalOut.h:51: undefined reference to `memset'
C:\Users\***\Documents\LPCXpresso_8.2.0_647\workspace\mbed_blinky\mbed/DigitalOut.h:53: undefined reference to `gpio_init_out'
collect2.exe: error: ld returned 1 exit status
make: *** [mbed_blinky.axf] Error 1

7. Second way was checking the checkmark for "Manage Linker Script", this was the output:

./main.o: In function `mbed::DigitalOut::DigitalOut(PinName)':
C:\Users\***\Documents\LPCXpresso_8.2.0_647\workspace\mbed_blinky\mbed/DigitalOut.h:53: undefined reference to `gpio_init_out'
collect2.exe: error: ld returned 1 exit status
make: *** [mbed_blinky.axf] Error 1

With the checked "Manage Linker Scripts" checkmark, it hat no influence which Library I chose (Newlib(semihost),newlib(None) etc) All ways led to the same result.

I just don't understand the error "undefined reference to `gpio_init_out'". The main.cpp includes the mbed.h. mbed.h includes DigitalOut.h, DigitalOut.h includes gpio_api.h, which contains the function header of gpio_init_out. Certainly gpio_init_out is just an example function. It throws the error because its the only function I am referring to.

You can find the project here: /media/uploads/fabian90/mbed_blinky.zip

I worked with mBed Library Revision 123 and LPCXpresso 8.2.0. [Build 657]

I hope someone can help me. I see a lot of people on google having similar problems, but none of the solutions are working for me.

Sincerely, Fabian

25 Jun 2017

Hi Fabian. I have the same problem. I'm trying to compile mbed project with arm-none-eabi and CMake within CLion IDE but I got the same error about gpio_init_out. Please tell me did you solve the problem somehow? Thanks.

Jurica.

27 Oct 2017

Hey guys, were you able to solve this problem? I am facing a similar problem, but mine says undefined reference to _start

18 Jan 2018

Any clue?

13 May 2018

The same problem here... any news from you guys?

26 Oct 2018

Same problem here. Waiting for news about it

04 Dec 2018

Same problem. Just spent a while adding all the include directories to MCUXpresso to get mbed-os to work in a project and the now the actual objects now seem to be wrong.

18 Dec 2018

Same problem.