Go to Post I believe in my students, I encourage them to fail in their endeavors to find the best formula. There is valuation in failure. - Chief Hedgehog [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 11-11-2015, 07:18 PM
rsaccone rsaccone is offline
Registered User
FRC #3950
 
Join Date: Feb 2013
Location: Glen Head, NY
Posts: 23
rsaccone is an unknown quantity at this point
Errors Linking to navx frc library

Hello,

We've purchased a nav mxp board and are trying to get the software library that comes with it to link with our robot code which at this point is simply trying to just create an instance of the AHRS class. But we are running into linker issues satisfying dependencies. It looks like the navx mxp library (libnavx_frc_cpp.a) is referencing classes in wpi and related libs which come up as unresolved references at link time. For example:

Code:
C:\Users\DriverStation\navx-mxp\cpp\lib\libnavx_frc_cpp.a(AHRS.o): In function `AHRS::SPIInit(SPI::Port, unsigned int, unsigned char)':
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/AHRS.cpp:830: undefined reference to `SPI::SPI(SPI::Port)'
C:\Users\DriverStation\navx-mxp\cpp\lib\libnavx_frc_cpp.a(AHRS.o): In function `AHRS::I2CInit(I2C::Port, unsigned char)':
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/AHRS.cpp:836: undefined reference to `I2C::I2C(I2C::Port, unsigned char)'
C:\Users\DriverStation\navx-mxp\cpp\lib\libnavx_frc_cpp.a(SerialIO.o): In function `SerialIO::GetMaybeCreateSerialPort()':
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:55: undefined reference to `SerialPort::SerialPort(unsigned int, SerialPort::Port, unsigned char, SerialPort::Parity, SerialPort::StopBits)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:56: undefined reference to `SerialPort::SetReadBufferSize(unsigned int)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:57: undefined reference to `SerialPort::SetTimeout(float)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:58: undefined reference to `SerialPort::EnableTermination(char)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:59: undefined reference to `SerialPort::Reset()'
C:\Users\DriverStation\navx-mxp\cpp\lib\libnavx_frc_cpp.a(SerialIO.o): In function `SerialIO::Run()':
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:128: undefined reference to `SerialPort::SetReadBufferSize(unsigned int)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:129: undefined reference to `SerialPort::SetTimeout(float)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:130: undefined reference to `SerialPort::EnableTermination(char)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:131: undefined reference to `SerialPort::Flush()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:132: undefined reference to `SerialPort::Reset()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:145: undefined reference to `SerialPort::Reset()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:146: undefined reference to `SerialPort::Write(char const*, int)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:148: undefined reference to `SerialPort::Write(char const*, int)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:149: undefined reference to `SerialPort::Flush()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:176: undefined reference to `SerialPort::Write(char const*, int)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:182: undefined reference to `SerialPort::GetBytesReceived()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:187: undefined reference to `SerialPort::Read(char*, int)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:230: undefined reference to `SerialPort::Read(char*, int)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:406: undefined reference to `SerialPort::Flush()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:407: undefined reference to `SerialPort::Reset()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:429: undefined reference to `SerialPort::Write(char const*, int)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:431: undefined reference to `SerialPort::Write(char const*, int)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:432: undefined reference to `SerialPort::Flush()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/SerialIO.cpp:439: undefined reference to `SerialPort::GetBytesReceived()'
C:\Users\DriverStation\navx-mxp\cpp\lib\libnavx_frc_cpp.a(RegisterIOSPI.o): In function `RegisterIO_SPI::Init()':
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/RegisterIOSPI.cpp:17: undefined reference to `SPI::SetClockRate(double)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/RegisterIOSPI.cpp:18: undefined reference to `SPI::SetMSBFirst()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/RegisterIOSPI.cpp:19: undefined reference to `SPI::SetSampleDataOnFalling()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/RegisterIOSPI.cpp:20: undefined reference to `SPI::SetClockActiveLow()'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/RegisterIOSPI.cpp:21: undefined reference to `SPI::SetChipSelectActiveLow()'
C:\Users\DriverStation\navx-mxp\cpp\lib\libnavx_frc_cpp.a(RegisterIOI2C.o): In function `RegisterIO_I2C::Write(unsigned char, unsigned char)':
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/RegisterIOI2C.cpp:21: undefined reference to `I2C::Write(unsigned char, unsigned char)'
C:\Users\DriverStation\navx-mxp\cpp\lib\libnavx_frc_cpp.a(RegisterIOI2C.o): In function `RegisterIO_I2C::Read(unsigned char, unsigned char*, unsigned char)':
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/RegisterIOI2C.cpp:33: undefined reference to `I2C::Write(unsigned char, unsigned char)'
C:\Users\Scott\GitHub\navxmxp\roborio\c++\navx_frc_cpp\Debug/..\src/RegisterIOI2C.cpp:34: undefined reference to `I2C::ReadOnly(unsigned char, unsigned char*)'
collect2.exe: error: ld returned 1 exit status
We thought that all we would have to do is add what we think are all the required libraries into the project setup:
wpi, spi, i2c, navx_frc_cpp to the project Properties->C/C++ General->Paths and Symbols->Libraries tab in that order. We've also added the path to the navx_frc_cpp library under the Library Paths Tab. However we still get the linker errors shown above.

We did discover that by adding references to I2C, SPI, and SerialPort into our code causes the program to link without error. Obviously we don't want to have create unnecessary references. Can someone shed light around what we need to do to get the navx library to link correctly to our code?

Below is an example that will now link without error due to the additional references in the code.
Code:
  
     // AHRS is a class that is in the navx frc library.  
     AHRS *ahrs = new AHRS(SPI::Port::kMXP);

    // These classes are in the wpi, i2c, spi libraries.
    I2C *i2c = new I2C(I2C::kOnboard, 23);
    SPI* spi = new SPI(SPI::kOnboardCS0); 
    SerialPort *sport = new 	SerialPort(1500);
Thanks,
Rob Saccone
Team 3950
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:51 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi