firebase / firebase-cpp-sdk

Firebase C++ SDK
http://firebase.google.com
Apache License 2.0
278 stars 114 forks source link

[FR] Compiling Firebase on Ubuntu 18.04 + Clang 6.0 compiler #223

Open Jaisiero opened 3 years ago

Jaisiero commented 3 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the question here:

Hi there,

I'm trying to compile Firebase for Desktop Linux target and I did it at first running this CMake configuration on my Ubuntu 18.04 distro like:

cmake ../../.. -DPROTOBUF_SRC_ROOT_FOLDER:PATH="/home/jaisiero/Documentos/Repos/FBLinux/protobuf-3.12.0" -DPROTOBUF_PROTOC_EXECUTABLE:FILEPATH="/home/jaisiero/Documentos/Repos/FBLinux/protoc-3.12.0-linux-x86_64/bin/protoc" -DNANOPB_SOURCE_DIR:PATH="/home/jaisiero/Documentos/Repos/FBLinux/nanopb-0.4.4-linux-x86" -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -D_GLIBCXX_USE_CXX11_ABI=0 -DPYTHON_LIBRARY:PATH=/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3.6 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.6

and it worked! I was able to compile Firebase libraries with my default GCC distro buuut I'm trying to link them with another libraries compiled with libc++ and as a result I'm having some link issues. Consequently, I try to compile with Clang running this CMake configuration getting this include error:

cmake ../../.. -DPROTOBUF_SRC_ROOT_FOLDER:PATH="/home/jaisiero/Documentos/Repos/FBLinux/protobuf-3.12.0" -DPROTOBUF_PROTOC_EXECUTABLE:FILEPATH="/home/jaisiero/Documentos/Repos/FBLinux/protoc-3.12.0-linux-x86_64/bin/protoc" -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DPYTHON_LIBRARY:PATH=/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3.6 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.6 -DCMAKE_CXX_COMPILER="/usr/bin/clang++" -DCMAKE_C_COMPILER="/usr/bin/clang" -DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi" -DCMAKE_THREAD_LIBS_INIT="-lpthread" -DCMAKE_HAVE_THREADS_LIBRARY=1 -DCMAKE_USE_WIN32_THREADS_INIT=0 -DCMAKE_USE_PTHREADS_INIT=1 -DTHREADS_PREFER_PTHREAD_FLAG=ON 
-- Downloading external project dependencies...
-- Download complete.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/external/src/firestore-build/external
[  1%] Creating directories for 'boringssl'
[  3%] Creating directories for 'protobuf'
[  4%] Creating directories for 'grpc'
[  7%] Creating directories for 'nanopb'
[  7%] Creating directories for 'abseil-cpp'
[ 11%] Creating directories for 'leveldb'
[ 11%] Creating directories for 'c-ares'
[ 12%] Performing download step (download, verify and extract) for 'boringssl'
[ 14%] Performing download step (download, verify and extract) for 'abseil-cpp'
[ 15%] Performing download step (download, verify and extract) for 'grpc'
[ 17%] Performing download step (download, verify and extract) for 'c-ares'
[ 19%] Performing download step (download, verify and extract) for 'protobuf'
[ 20%] Performing download step (download, verify and extract) for 'leveldb'
[ 22%] Performing download step (download, verify and extract) for 'nanopb'
-- Downloading...
   dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/boringssl-83da28a68f32023fd3b95a8ae94991a07b1f6c62.tar.gz'
   timeout='none'
-- Using src='https://github.com/google/boringssl/archive/83da28a68f32023fd3b95a8ae94991a07b1f6c62.tar.gz'
-- Downloading...
   dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/abseil-cpp-20200225.tar.gz'
   timeout='none'
-- Using src='https://github.com/abseil/abseil-cpp/archive/20200225.tar.gz'
-- Downloading...
   dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/grpc-1.28.0.tar.gz'
   timeout='none'
-- Using src='https://github.com/grpc/grpc/archive/v1.28.0.tar.gz'
-- Downloading...
   dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/c-ares-e982924acee7f7313b4baa4ee5ec000c5e373c30.tar.gz'
   timeout='none'
-- Using src='https://github.com/c-ares/c-ares/archive/e982924acee7f7313b4baa4ee5ec000c5e373c30.tar.gz'
-- verifying file...
       file='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/leveldb-1.22.tar.gz'
-- Downloading...
   dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/protobuf-29cd005ce1fe1a8fabf11e325cb13006a6646d59.tar.gz'
   timeout='none'
-- Using src='https://github.com/protocolbuffers/protobuf/archive/29cd005ce1fe1a8fabf11e325cb13006a6646d59.tar.gz'
-- File already exists and hash match (skip download):
  file='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/leveldb-1.22.tar.gz'
  SHA256='55423cac9e3306f4a9502c738a001e4a339d1a38ffbee7572d4a07d5d63949b2'
-- Downloading...
   dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/nanopb-0.3.9.5.tar.gz'
   timeout='none'
-- Using src='https://github.com/nanopb/nanopb/archive/nanopb-0.3.9.5.tar.gz'
-- extracting...
     src='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/leveldb-1.22.tar.gz'
     dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/external/src/firestore-build/external/src/leveldb'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 23%] No patch step for 'leveldb'
[ 25%] No update step for 'leveldb'
[ 26%] No configure step for 'leveldb'
[ 28%] No build step for 'leveldb'
[ 30%] No install step for 'leveldb'
[ 31%] No test step for 'leveldb'
[ 33%] Completed 'leveldb'
[ 33%] Built target leveldb
-- [download 100% complete]
-- [download 100% complete]
-- [download 100% complete]
-- [download 100% complete]
-- [download 100% complete]
-- [download 100% complete]
-- [download 0% complete]
-- [download 1% complete]
-- [download 2% complete]
-- [download 3% complete]
-- [download 4% complete]
-- [download 5% complete]
-- [download 6% complete]
-- [download 7% complete]
-- [download 8% complete]
-- [download 9% complete]
-- [download 10% complete]
-- [download 11% complete]
-- [download 12% complete]
-- [download 13% complete]
-- [download 14% complete]
-- [download 15% complete]
-- [download 16% complete]
-- [download 17% complete]
-- [download 18% complete]
-- [download 19% complete]
-- [download 20% complete]
-- [download 21% complete]
-- [download 22% complete]
-- [download 23% complete]
-- [download 24% complete]
-- [download 25% complete]
-- [download 26% complete]
-- [download 27% complete]
-- [download 28% complete]
-- [download 29% complete]
-- [download 30% complete]
-- [download 31% complete]
-- [download 32% complete]
-- [download 33% complete]
-- [download 34% complete]
-- [download 35% complete]
-- [download 36% complete]
-- [download 37% complete]
-- [download 38% complete]
-- [download 39% complete]
-- [download 40% complete]
-- [download 41% complete]
-- [download 42% complete]
-- [download 43% complete]
-- [download 44% complete]
-- [download 45% complete]
-- [download 46% complete]
-- [download 47% complete]
-- [download 48% complete]
-- [download 49% complete]
-- [download 50% complete]
-- [download 51% complete]
-- [download 52% complete]
-- [download 53% complete]
-- [download 54% complete]
-- [download 55% complete]
-- [download 56% complete]
-- [download 57% complete]
-- [download 58% complete]
-- [download 59% complete]
-- [download 60% complete]
-- [download 61% complete]
-- [download 62% complete]
-- [download 63% complete]
-- [download 64% complete]
-- [download 65% complete]
-- [download 66% complete]
-- [download 67% complete]
-- [download 68% complete]
-- [download 69% complete]
-- [download 70% complete]
-- [download 71% complete]
-- [download 72% complete]
-- [download 73% complete]
-- [download 74% complete]
-- [download 75% complete]
-- [download 76% complete]
-- [download 77% complete]
-- [download 78% complete]
-- [download 79% complete]
-- [download 80% complete]
-- [download 81% complete]
-- [download 82% complete]
-- [download 84% complete]
-- [download 86% complete]
-- [download 88% complete]
-- [download 90% complete]
-- [download 93% complete]
-- [download 95% complete]
-- [download 97% complete]
-- [download 99% complete]
-- [download 100% complete]
-- verifying file...
       file='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/c-ares-e982924acee7f7313b4baa4ee5ec000c5e373c30.tar.gz'
-- Downloading... done
-- extracting...
     src='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/c-ares-e982924acee7f7313b4baa4ee5ec000c5e373c30.tar.gz'
     dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/external/src/firestore-build/external/src/cares'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 34%] No update step for 'c-ares'
[ 36%] No patch step for 'c-ares'
[ 38%] No configure step for 'c-ares'
[ 39%] No build step for 'c-ares'
[ 41%] No install step for 'c-ares'
[ 42%] No test step for 'c-ares'
[ 44%] Completed 'c-ares'
[ 44%] Built target c-ares
-- verifying file...
       file='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/nanopb-0.3.9.5.tar.gz'
-- Downloading... done
-- extracting...
     src='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/nanopb-0.3.9.5.tar.gz'
     dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/external/src/firestore-build/external/src/nanopb'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 46%] No update step for 'nanopb'
[ 47%] No patch step for 'nanopb'
[ 49%] No configure step for 'nanopb'
[ 50%] No build step for 'nanopb'
[ 52%] No install step for 'nanopb'
[ 53%] No test step for 'nanopb'
[ 55%] Completed 'nanopb'
[ 55%] Built target nanopb
-- verifying file...
       file='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/abseil-cpp-20200225.tar.gz'
-- Downloading... done
-- extracting...
     src='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/abseil-cpp-20200225.tar.gz'
     dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/external/src/firestore-build/external/src/abseil-cpp'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 57%] No update step for 'abseil-cpp'
[ 58%] No patch step for 'abseil-cpp'
[ 60%] No configure step for 'abseil-cpp'
[ 61%] No build step for 'abseil-cpp'
[ 63%] No install step for 'abseil-cpp'
[ 65%] No test step for 'abseil-cpp'
[ 66%] Completed 'abseil-cpp'
[ 66%] Built target abseil-cpp
-- verifying file...
       file='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/protobuf-29cd005ce1fe1a8fabf11e325cb13006a6646d59.tar.gz'
-- Downloading... done
-- extracting...
     src='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/protobuf-29cd005ce1fe1a8fabf11e325cb13006a6646d59.tar.gz'
     dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/external/src/firestore-build/external/src/protobuf'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 68%] No update step for 'protobuf'
[ 69%] No patch step for 'protobuf'
[ 71%] No configure step for 'protobuf'
[ 73%] No build step for 'protobuf'
[ 74%] No install step for 'protobuf'
[ 76%] No test step for 'protobuf'
[ 77%] Completed 'protobuf'
[ 77%] Built target protobuf
-- verifying file...
       file='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/boringssl-83da28a68f32023fd3b95a8ae94991a07b1f6c62.tar.gz'
-- Downloading... done
-- extracting...
     src='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/boringssl-83da28a68f32023fd3b95a8ae94991a07b1f6c62.tar.gz'
     dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/external/src/firestore-build/external/src/boringssl'
-- extracting... [tar xfz]
-- verifying file...
       file='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/grpc-1.28.0.tar.gz'
-- Downloading... done
-- extracting...
     src='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/downloads/grpc-1.28.0.tar.gz'
     dst='/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/external/src/firestore-build/external/src/grpc'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
-- extracting... [analysis]
-- extracting... [rename]
[ 79%] No update step for 'grpc'
[ 80%] No patch step for 'grpc'
[ 82%] No configure step for 'grpc'
[ 84%] No build step for 'grpc'
[ 85%] No install step for 'grpc'
[ 87%] No test step for 'grpc'
-- extracting... [clean up]
-- extracting... done
[ 88%] No patch step for 'boringssl'
[ 90%] No update step for 'boringssl'
[ 92%] Completed 'grpc'
[ 93%] No configure step for 'boringssl'
[ 93%] Built target grpc
[ 95%] No build step for 'boringssl'
[ 96%] No install step for 'boringssl'
[ 98%] No test step for 'boringssl'
[100%] Completed 'boringssl'
[100%] Built target boringssl
-- 
-- 3.11.2.0
-- Check if the system is big endian
-- Searching 16 bit integer
CMake Error at /usr/share/cmake-3.10/Modules/TestBigEndian.cmake:49 (message):
  no suitable type found
Call Stack (most recent call first):
  out/build/destktop_linux64_build/external/src/firestore-build/external/src/leveldb/CMakeLists.txt:32 (test_big_endian)

-- Configuring incomplete, errors occurred!
See also "/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/CMakeFiles/CMakeOutput.log".
See also "/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/CMakeFiles/CMakeError.log".
[CMakeError.log](https://github.com/firebase/firebase-cpp-sdk/files/5754073/CMakeError.log)
[CMakeOutput.log](https://github.com/firebase/firebase-cpp-sdk/files/5754074/CMakeOutput.log)

I see in the official webpage that Firebase can be compile with Clang 5.0 on Ubuntu:

Firebase CPP SDK Setup

I'm currently using Clang 6.0.

I'm pretty sure it's a silly mistake and i hope someone could help me.

Cheers, Jaime.

google-oss-bot commented 3 years ago

I found a few problems with this issue:

alexames commented 3 years ago

Hi @Jaisiero,

I'm not sure off the top of my head what the issue would be based on the error I'm seeing. The error message gives you to other files to look into that have additional diagnostic information:

-- Configuring incomplete, errors occurred!
See also "/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/CMakeFiles/CMakeOutput.log".
See also "/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/CMakeFiles/CMakeError.log".

Take a look at those and see if they clarify what exactly is causing the failure.

Jaisiero commented 3 years ago

Hey @alexames ,

Sure! Here you are:

CMakeError.log CMakeOutput.log

It's full of errors :S

It seems Cmake is not finding:

-lc++abi not found

but I installed clang in my distribution (Ubuntu 18.04) just like that:

sudo apt install clang

Thank you for helping, Jaime.

chkuang-g commented 3 years ago

Taking a look at the log, it seems to have not only link error but also compiler error like

/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:2:10: fatal error: 'winsock2.h' file not found
#include <winsock2.h>
         ^~~~~~~~~~~~
/home/jaisiero/Documentos/Repos/FBLinux/firebase-cpp-sdk/out/build/destktop_linux64_build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:27:19: error: use of undeclared identifier 'strnicmp'; did you mean 'strncmp'?
  return ((int*)(&strnicmp))[argc];
                  ^~~~~~~~
                  strncmp

I suspect that the source might not be compatible to Clang 6.0.

Let me ping the team and see if we have more insight about it.

chkuang-g commented 3 years ago

Does it work if you disable LevelDB build test using -DLEVELDB_BUILD_TESTS=OFF?

Jaisiero commented 3 years ago

Naaah, It doesn't work either.

CMakeError.log CMakeOutput.log

Firebase c++ sdk says:

Firebase docs

Linux libraries For Linux, library versions are provided for 32-bit (i386) and 64-bit (x86_64) platforms.

Note that the Linux libraries were tested using GCC 4.8.0, GCC 7.2.0, and Clang 5.0 on Ubuntu.

When building C++ desktop apps on Linux, link the pthread system library to your project. Consult your compiler documentation for more information. If you're building with GCC 5 or later, define -D_GLIBCXX_USE_CXX11_ABI=0.

However, you might be right and the source is not compatible with this compilator anymore or maybe I'm doing something wrong.

Thanks for your time, Jaime.

chkuang-g commented 3 years ago

I'll put this as a feature request to support Clang 6.0+.