Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 6 months ago.
code not compiling
Hi,
I'm trying to overcome this error.
working code in a
--------
- include "QEI.h"
Motor Encoder Pinout Declarations
- define LEFT_CH_A p11
- define LEFT_CH_B p12
DigitalIn chanA(LEFT_CH_A); DigitalIn chanB(LEFT_CH_B);
- define RIGHT_CH_A p29
- 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
Importbutton - Go to the
Librariestab - Type
QEIinto the search box and hit Enter - Select the
QEIlibrary (the first line on the list) and click on theImport!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>>