0

I am trying to compile my source code using riscv64-unknown-elf-g++ compiler into a binary file but I am getting this warning and unable to generate exec file:

warning for library: libofdm.a the table of contents is empty (no object file members in the library define global symbols)

referring to this issue before:

Can't make my c++ file into a library with compiler

as suggested in the above answer the same toolchain is used to compile the object file to create the library. Even though I am getting the error. Below I am attaching the whole command line used to compile.

Last login: Thu Jul  9 12:50:56 on ttys000

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
(base) k:~ cd /Users/yuli/Documents/version3/cpp/
(base) k:~ ls
CMakeLists.txt  src     test
(base) k:~ mkdir build_riscv
(base) k:~ cd build_riscv
(base) k:~ cmake ..
-- The C compiler identification is AppleClang 11.0.3.11030032
-- The CXX compiler identification is AppleClang 11.0.3.11030032
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/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: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Compiling RISCV
CMAKE_CXX_COMPILER: /usr/local/opt/riscv-gnu-toolchain/bin/riscv64-unknown-elf-g++
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yuli/Documents/version3/cpp/build_riscv
(base) k:~ make
Scanning dependencies of target ofdm
[ 33%] Building CXX object CMakeFiles/ofdm.dir/src/transmitter.cpp.o
[ 66%] Building CXX object CMakeFiles/ofdm.dir/src/configuration.cpp.o
[100%] Linking CXX static library libofdm.a
warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: warning for library: libofdm.a the table of contents is empty (no object file members in the library define global symbols)
[100%] Built target ofdm
(base) k:~ 

and FYI I am using mac machine. I am Specifying this because I saw in a post with "clang warnings macOS #3331".

clang warnings macOS #3331

CMakeLists.txt as follows:

cmake_minimum_required(VERSION 3.13)
project(ofdmchain)

set(CMAKE_CXX_COMPILER "/usr/local/opt/riscv-gnu-toolchain/bin/riscv64-unknown-elf-g++")

add_definitions(-DCOMPILES_ON_PC -Wall -Wextra)

configure_file(${CMAKE_SOURCE_DIR}/src/config.hpp.in ${CMAKE_BINARY_DIR}/config.hpp)

if("${CMAKE_CXX_COMPILER}" MATCHES ".*riscv64-unknown-elf-g\\+\\+")
  message(STATUS "Compiling RISCV")
  SET(RISCV 1)
else()
  message(STATUS "Compiling X86")
  SET(RISCV 0)
endif()

message("CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")

add_library(ofdm
  src/transmitter.cpp
  src/configuration.cpp

  src/ofdm.hpp
  src/datatypes.hpp
  )
target_include_directories(ofdm PRIVATE ${CMAKE_SOURCE_DIR}/../reference_matlab)
target_include_directories(ofdm PRIVATE ${CMAKE_SOURCE_DIR}/src/)

if (NOT ${RISCV})
  add_executable(unit_tests
    test/catch_main.cpp
    test/test_sanity.cpp
    test/test_utilities.cpp
    test/test_transmitter.cpp
    )
  target_include_directories(unit_tests PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
  target_include_directories(unit_tests PUBLIC ${CMAKE_SOURCE_DIR}/src)
  target_link_libraries(unit_tests ofdm)
endif()
Yulia
  • 31
  • 8
  • That's just a warning? It seems to build just fine, and the link explains why you get the warning. – o11c Jul 09 '20 at 17:13
  • If you get errors at some other time, please post them. I don't understand why you think you're mixing architectures, perhaps there is some problem there? – o11c Jul 09 '20 at 17:15
  • In my build directory, there should be an exec file but it isn't generating. – Yulia Jul 09 '20 at 17:15
  • I am just referring that is it. Not mixing up anything. – Yulia Jul 09 '20 at 17:16
  • 1
    Are you sure it's not in a subdirectory, e.g. `src`? Sometimes recursive build systems like `cmake` don't put files where you expect. – o11c Jul 09 '20 at 17:18
  • please provide a [mre] – Alan Birtles Jul 09 '20 at 17:18
  • Put your CMakeLists.txt in the question – user253751 Jul 09 '20 at 17:27
  • @o11c I am sure it isn't in any subdirectory! cross-verified it. – Yulia Jul 09 '20 at 17:27
  • Shouldn't it be `add_library(ofdm STATIC` or `add_library(ofdm SHARED`? – user253751 Jul 09 '20 at 17:56
  • 1
    Also. Which file are you looking for? Your CMakeLists *specifically* says to *not* compile unit_tests on RISCV. – user253751 Jul 09 '20 at 17:56
  • I am looking for unit_tests exec file! – Yulia Jul 09 '20 at 18:07
  • I just tried the same on the Linux machine! now there is no warning. But even the same exec file unit_tests is not generating! I checked all the folders where the compiler is installed and all the project folders as well! Am I doing something wrong in CMakeLists.txt file??? – Yulia Jul 14 '20 at 17:29

0 Answers0