7 years, 6 months ago.

code not compiling

Hi,

I'm trying to overcome this error. working code in a --------

  1. include "QEI.h"

Motor Encoder Pinout Declarations

  1. define LEFT_CH_A p11
  2. define LEFT_CH_B p12

DigitalIn chanA(LEFT_CH_A); DigitalIn chanB(LEFT_CH_B);

  1. define RIGHT_CH_A p29
  2. define RIGHT_CH_B p30

QEI::Encoding encodings; QEI leftEncoder (LEFT_CH_A, LEFT_CH_B, 1); QEI rightEncoder (RIGHT_CH_A, RIGHT_CH_B, 1); ---------- When I move this code to my main it stops working and doesn't compile; I get this error:

Error: Undefined symbol QEI::QEI(PinName, PinName, int, QEI::Encoding) (referred from /build/./main.LPC1768.o).

I have tried writing the code in many ways including:

QEI rightEncoder (RIGHT_CH_A, RIGHT_CH_B, 1); QEI rightEncoder (RIGHT_CH_A, RIGHT_CH_B, 1,encodings); QEI::QEI rightEncoder (RIGHT_CH_A, RIGHT_CH_B, 1);

All of which failed but worked when I tested the code in a simple helloworld like code and it works fine.

1 Answer

7 years, 6 months ago.

Hello Ali,

Undefined symbol usually means that the linker is not able to find the code defining the given symbol (unless it's defined as inline function in the header file). So my guess is that the QEI library is missing in your project. If you work with the online compiler try to:

  • Open your project
  • Click on the Import button
  • Go to the Libraries tab
  • Type QEI into the search box and hit Enter
  • Select the QEI library (the first line on the list) and click on the Import! button (top-right corner)

ADVISE: To have a more readable code published here (on mbed pages) try to mark it up as below (with <<code>> and <</code>> tags, each on separate line at the begin and end of your code)

<<code>>
text of your code
<</code>>