PolySync / oscc

Open Source Car Control 💻🚗🙌
Other
966 stars 278 forks source link

Unit Test Issue - avr-g++ error: shared is not supported #307

Closed TommyBlairesLewis closed 6 years ago

TommyBlairesLewis commented 6 years ago

Expected behavior

Pass the Unit Test and the Property Test

Actual behavior

  1. I got the sys/timeb.h issue and got it solved by export the C library to /usr/include/
  2. I experienced several errors from stdio library and solved by installing apt-get gcc-avr
  3. Now whenever I try to run make run-unit-tests, I always see avr-g++ error: shared is not supported.

Steps to reproduce

Install the framework environment for OSCC and purged the arduino library. Following original OSCC steps to run the Unit test and Property test.

shnewto commented 6 years ago

Hi @TommyBlairesLewis thanks for raising this issue! I'm currently unable to reproduce the behavior your seeing so any more information about your setup would help me investigate further. Minimally the output of uname -a would be useful.

When you say "purged the arduino" library, you mean you followed the steps here https://github.com/PolySync/oscc#pre-requisites?

rebpdx commented 6 years ago

Hi @TommyBlairesLewis the only time I've seen the sys/timeb.h issue is when part of zlib1g-dev or libc6-dev is missing. Can you try apt-get install build-essential zlib1g-dev and let us know if that mitigates the issue?

We haven't installed avr-gcc and such on our side because the Arduino toolchain includes those in /usr/share/arduino-1.8.5/hardware/tools/avr/bin/

TommyBlairesLewis commented 6 years ago

Thanks for responding @shnewto @rebpdx

Here's my current build output after installing the zlib1g-dev

throttle/tests/CMakeFiles/throttle.dir/__/__/common/testing/mocks/Arduino_mock.cpp.obj
[  4%] Building CXX object throttle/tests/CMakeFiles/throttle.dir/__/__/common/testing/mocks/mcp_can_mock.cpp.obj
[  6%] Building CXX object throttle/tests/CMakeFiles/throttle.dir/__/__/common/testing/mocks/DAC_MCP49xx_mock.cpp.obj
[  8%] Linking CXX shared library libthrottle.so
CMakeFiles/throttle.dir/__/src/communications.cpp.obj: In function `publish_throttle_report()':
/home/control-box/oscc/firmware/throttle/src/communications.cpp:45: undefined reference to `MCP_CAN::sendMsgBuf(unsigned long, unsigned char, unsigned char, unsigned char*)'
CMakeFiles/throttle.dir/__/src/communications.cpp.obj: In function `publish_fault_report()':
/home/control-box/oscc/firmware/throttle/src/communications.cpp:64: undefined reference to `MCP_CAN::sendMsgBuf(unsigned long, unsigned char, unsigned char, unsigned char*)'
CMakeFiles/throttle.dir/__/__/common/libs/can/oscc_can.cpp.obj: In function `check_for_rx_frame(MCP_CAN&, can_frame_s*)':
/home/control-box/oscc/firmware/common/libs/can/oscc_can.cpp:39: undefined reference to `MCP_CAN::readMsgBufID(unsigned long*, unsigned char*, unsigned char*)'
/usr/lib/gcc/avr/4.8.2/../../../avr/lib/libc.a(malloc.o): In function `malloc':
/build/buildd/avr-libc-1.8.0/avr/lib/avr2/../../../libc/stdlib/malloc.c:69: undefined reference to `__heap_end'
collect2: error: ld returned 1 exit status
make[3]: *** [throttle/tests/libthrottle.so] Error 1
make[2]: *** [throttle/tests/CMakeFiles/throttle.dir/all] Error 2
make[1]: *** [CMakeFiles/run-unit-tests.dir/rule] Error 2
make: *** [run-unit-tests] Error 2

What am I missing here?

I also did the export CPATH=$CPATH:/usr/include/ for solving the timeb.h issue

uname -a output is

Linux control-oscc-ai 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

shnewto commented 6 years ago

Hi @TommyBlairesLewis, thanks for providing that output. I don't think we've tried building on Ubuntu 14.04 but I'll give it a try myself and see if I can reproduce / resolve what you're seeing.

shnewto commented 6 years ago

@TommyBlairesLewis an update on my side. I don't think there's an easy way to run our unit tests on Ubuntu 14.04. Aside from the avr issues you're running into, our tests depend on custom cgreen and cucumber-cpp libraries that are built for Ubuntu 16.04. The libraries live here https://github.com/PolySync/oscc/tree/master/firmware/common/testing/framework.

I experimented with what it would look like to build them individually for 14.04 and it's pretty labor intensive. I abandoned ship when it started to require building an older version of boost from source and statically linking it to cucumber-cpp in a custom CMakeLists.txt.

If you are still very interested in running the unit tests on Ubuntu 14.04 I'd recommend raising another issue as a feature request and referencing this conversation / issue number so we can track it.

TommyBlairesLewis commented 6 years ago

@shnewto

I can move to 16.04 and try it again. I think the reason we do 14.04 because of the ML stuffs dependencies we wrote. Some of them won't work well with 16.04 even 18. However, for testing purpose only, I don't mind to switch 16.04. We can close this one since it's related to the 14.04 build issue.