eclipse / upm

UPM is a high level repository that provides software drivers for a wide variety of commonly used sensors and actuators. These software drivers interact with the underlying hardware platform through calls to MRAA APIs.
MIT License
658 stars 411 forks source link

cmake Fail on https://github.com/intel-iot-devkit/upm #658

Closed lenhuy closed 5 years ago

lenhuy commented 5 years ago

OS: Ubuntu 16.04 Platform: upsquared-UP-APL01 Kernel: #5000-upboard11-Ubuntu SMP

cmake steps: git clone https://github.com/intel-iot-devkit/upm.git mkdir build cd build sudo apt install cmake cmake ..

Error: CMakeFiles/cmTC_c054b.dir/CheckSymbolExists.c.o: In function main': CheckSymbolExists.c:(.text+0x16): undefined reference topthread_create'

Log attached: CMakeError.log

Building C object CMakeFiles/cmTC_025b0.dir/CheckFunctionExists.c.o /usr/bin/cc -Wall -Wno-misleading-indentation -Wno-strict-aliasing -Wno-deprecated-declarations -Werror -Winit-self -Wimplicit -Wsign-compare -Wmissing-parameter-type -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_025b0.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.5/Modules/CheckFunctionExists.c

Propanu commented 5 years ago

Hi @lenhuy, this is likely caused by missing dependencies. Most of them are present in the case of Ubuntu Desktop, but for Ubuntu Server you need to install some manually (e.g. build-essential libc-dev). Check the MRAA's building documentation for additional details, if you can get MRAA to build then UPM will do so too.

P.S. This can also be a cmake bug, but we'll discuss further if dependencies won't fix this for you. In that case please also include the cmake configuration step output.

pylbert commented 5 years ago

I suspect the problem is not a missing thread implementation but one of the other dependencies like @Propanu mentioned.

Can you provide the rest of the CMake output?

Also, verify you have a 'libthread.so' (not libpthreads.so).

For reference...

The CMake find_package call for Threads creates multiple test snippet builds to determine a usable thread implementation. It's normal to see errors in the CMakeError.log for the failing checks (it should hopefully find one and log that to CMakeOutput.log). For example, my CMakeError.log looks nearly identical to yours (the pthread_create fails for two runs (1st, w/o a thread library specified and the 2nd with -lpthreads - note the 's' on pthreads - libpthreads.so prb doesn't exist on your ubuntu machine, but you should see a libpthread.so).

If I look in my CMakeOutput.log, I see the passing thread check:

Determining if the include file pthread.h exists passed with the following output:
Change Dir: /tmp/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_1dbd1/fast"
/usr/bin/make -f CMakeFiles/cmTC_1dbd1.dir/build.make CMakeFiles/cmTC_1dbd1.dir/build
make[1]: Entering directory '/tmp/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_1dbd1.dir/CheckIncludeFile.c.o
/usr/lib/ccache/cc     -o CMakeFiles/cmTC_1dbd1.dir/CheckIncludeFile.c.o   -c /tmp/build/CMakeFiles/CMakeTmp/CheckIncl
udeFile.c
Linking C executable cmTC_1dbd1
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1dbd1.dir/link.txt --verbose=1
/usr/lib/ccache/cc       CMakeFiles/cmTC_1dbd1.dir/CheckIncludeFile.c.o  -o cmTC_1dbd1 -rdynamic·
make[1]: Leaving directory '/tmp/build/CMakeFiles/CMakeTmp'
lenhuy commented 5 years ago

Thank you for quick response.

  1. I had build-essential libc-dev installed
  2. mraa was built successfully
  3. CMakeOutput.log is attached CMakeOutput.log
pylbert commented 5 years ago

@lenhuy,

Can you provide the direct output from the cmake binary (everything after the call to 'cmake ..').

lenhuy commented 5 years ago

upsquared@upsquared-UP-APL01:~/upm$ mkdir build upsquared@upsquared-UP-APL01:~/upm$ cd build upsquared@upsquared-UP-APL01:~/upm/build$ cmake .. -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Warnings as errors enabled (-Werror), disable with -DWERROR=off -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Checking for module 'mraa>=1.9.0' -- Found mraa, version 1.9.0 -- Looking for mraa_iio_init in mraa -- Looking for mraa_iio_init in mraa - found -- Looking for mraa_firmata_init in mraa -- Looking for mraa_firmata_init in mraa - not found -- Looking for mraa_uart_ow_init in mraa -- Looking for mraa_uart_ow_init in mraa - found -- Checking for module 'libbacnet' -- No package 'libbacnet' found -- Checking for module 'libmodbus>=3.1.2' --
-- Checking for module 'libopenzwave' -- No package 'libopenzwave' found -- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR) -- Found Nodejs: /usr/bin/node (found version "6.14.3") -- Found v8: /usr/include/node/v8.h (found version "5.1.281.111") CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message): Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR) (Required is at least version "3.0.5") Call Stack (most recent call first): /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.5/Modules/FindSWIG.cmake:75 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:186 (find_package)

-- Configuring incomplete, errors occurred! See also "/home/upsquared/upm/build/CMakeFiles/CMakeOutput.log". See also "/home/upsquared/upm/build/CMakeFiles/CMakeError.log". upsquared@upsquared-UP-APL01:~/upm/build$ CMakeError.log CMakeOutput.log

Propanu commented 5 years ago

@lenhuy, you are missing SWIG, you can solve this by running sudo apt install swig.

lenhuy commented 5 years ago

cmake successfully after "sudo apt install swig". Thank you.

How do I compile grove-grovelight.cxx in ~/upm/examples/c++/grove-grovelight.cxx? "g++ grove-grovelight.cxx -o grovelight" give error: grove-grovelight.cxx:29:26: fatal error: grovelight.hpp: No such file or directory.

Propanu commented 5 years ago

Hi @lenhuy, sorry for the delay on this. The simplest way is to enable the BUILDEXAMPLES=ON CMake switch. You can also compile by hand, but you have to specify the include path -I, library path -L and linker flags -lupm-grove. Pkg-config can also help here. I highly recommend you use the upm-light library instead of the grove module though, as that has been deprecated.

lenhuy commented 5 years ago

test1.cpp:

include "mraa/common.hpp"

include "mraa/types.h"

include "upm/light.hpp"

int main(int argc, char** argv) { int upm::Light light(512); return 0; }

g++ test1.cp -o test1 -lmraa -lupm-light error: terminate called after throwing an instance of 'std::runtime_error' what(); Light:Light_init() failed. Aborted (core dumped)

Where is the implementation of the constructor Light(unsigned int pin)?

lenhuy commented 5 years ago

Need to be root user to access the GPIOs, so need to include sudo to run "sudo ./test1".