Evrytania / LTE-Cell-Scanner

LTE SDR cell scanner optimized to work with very low performance RF front ends (8bit A/D, 20dB noise figure)
GNU Affero General Public License v3.0
584 stars 357 forks source link

Building on OSX fails because cmake defaults to AppleClang despite macports mp-clang-9.0 being the active compiler. #33

Open playaspec opened 5 years ago

playaspec commented 5 years ago

I believe it's related to this discussion:

https://trac.macports.org/ticket/53201

I also had some issues with cmake detecting FFTW, ITPP, and RTLSDR libraries, but resolved those by adding the macports paths to their module files. I suspect that if the compiler issue were sorted out, these hacks would have been unnecessary, but I can't say for sure until I get past this. I will fork, produce patches, and submit a pull request once I've completely solved and successfully built LTE-Cell-Scanner.

The output of cmake .. from the build directory looks like this:

build playaspec$ cmake ..
-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found Boost: /opt/local/include (found version "1.71.0") found components:  thread system chrono date_time atomic
-- Found ITPP: /opt/local/lib/libitpp.dylib
ITPP_DIR set to
-- Looking for sgemm_
-- Looking for sgemm_ - not found
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Found BLAS: /opt/local/lib/libopenblas.dylib
-- Looking for cheev_
-- Looking for cheev_ - found
-- A library with LAPACK API found.
-- Found FFTW: /opt/local/lib/libfftw3.dylib
-- Found RTLSDR: /opt/local/lib/librtlsdr.dylib
-- Found Curses: /opt/local/lib/libcurses.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/playaspec/Documents/_Projects/programming/LTE-Cell-Scanner/build

Needless to say, make fails miserably, and I'm just not well versed enough in the intricacies of cmake to

playaspec commented 5 years ago

I have solved the compiler detection problem! The second comment here:

https://stackoverflow.com/questions/24380456/how-can-i-make-cmake-use-gcc-instead-of-clang-on-mac-os-x

Suggests adding:

set(CMAKE_C_COMPILER "gcc") set(CMAKE_CXX_COMPILER "g++")

Before the project declaration in the CMakeLists.txt. Surely this is a hack that will probably break other things on other platforms. Perhaps it could be wrapped in a conditional if the platform can be determined this early in the configuration process.

The next issue was while compiling. There were four errors in LTE-Cell-Scanner/include/dsp.h:

/Users/playaspec/Documents/_Projects/programming/LTE-Cell-Scanner/include/dsp.h:47:25: error: lvalue required as left operand of assignment
   47 |     coeff.real()=cos(k*t);
      |                         ^
/Users/playaspec/Documents/_Projects/programming/LTE-Cell-Scanner/include/dsp.h:48:25: error: lvalue required as left operand of assignment
   48 |     coeff.imag()=sin(k*t);
      |                         ^
/Users/playaspec/Documents/_Projects/programming/LTE-Cell-Scanner/include/dsp.h: In function 'void fshift_inplace(itpp::cvec&, double, double)':
/Users/gduncan/Documents/_Projects/programming/LTE-Cell-Scanner/include/dsp.h:64:25: error: lvalue required as left operand of assignment
   64 |     coeff.real()=cos(k*t);
      |                         ^
/Users/playaspec/Documents/_Projects/programming/LTE-Cell-Scanner/include/dsp.h:65:25: error: lvalue required as left operand of assignment
   65 |     coeff.imag()=sin(k*t);
      |                         ^

which were solved by the patch suggested in LTE-Cell-Scanner issues 19. These changes really should be applied to the current source tree.

At this point compilation succeeds, but linking with libitpp fails for CellSearch.

build playaspec$ make
[  5%] Building CXX object src/CMakeFiles/LTE_MISC.dir/capbuf.cpp.o
[ 11%] Building CXX object src/CMakeFiles/LTE_MISC.dir/constants.cpp.o
[ 16%] Building CXX object src/CMakeFiles/LTE_MISC.dir/itpp_ext.cpp.o
[ 22%] Building CXX object src/CMakeFiles/LTE_MISC.dir/macros.cpp.o
[ 27%] Building CXX object src/CMakeFiles/LTE_MISC.dir/searcher.cpp.o
[ 33%] Building CXX object src/CMakeFiles/LTE_MISC.dir/common.cpp.o
[ 38%] Building CXX object src/CMakeFiles/LTE_MISC.dir/dsp.cpp.o
[ 44%] Building CXX object src/CMakeFiles/LTE_MISC.dir/lte_lib.cpp.o
[ 50%] Building CXX object src/CMakeFiles/LTE_MISC.dir/from_osmocom.cpp.o
[ 55%] Linking CXX static library libLTE_MISC.a
[ 55%] Built target LTE_MISC
[ 61%] Building CXX object src/CMakeFiles/CellSearch.dir/CellSearch.cpp.o
[ 66%] Linking CXX executable CellSearch
ld: library not found for -litpp
collect2: error: ld returned 1 exit status
make[2]: *** [src/CellSearch] Error 1
make[1]: *** [src/CMakeFiles/CellSearch.dir/all] Error 2
make: *** [all] Error 2

For whatever reason it appears that the FindITPP.cmake module doesn't set ITPP_DIR as it is undefined. Perhaps this is inconsequential. I have tried installing both itpp and itpp-devel ports from Macports, cleaning the build directory and starting new, but it has made no difference. I see no way of explicitly defining the path to the library so the linker can find it.

zenfish commented 4 years ago

On MacOS Mojave it died in the make'ing... a couple of manual runs of the compiler (XCode) with the -L/usr/local/Cellar/itpp/4.3.1/lib option made it compile. Then ran this to resolve a broken dynamic lib - install_name_tool -change libhackrf.0.dylib /usr/local/lib/libhackrf.0.dylib $(which LTE-Tracker ) It runs, but doesn't recognize the hackrf, although hackrf_info shows it just fine. FWIW it's the farthest I've gotten with a mac so far, but still no dice.