firebase / firebase/firebase-cpp-sdk

[Question] Cannot link with Auth on Linux

Abierto
#1,721 3 comentarios 0 reacciones 0 asignados Ver en GitHub
needs-triage new type: question
Lenguaje dominante
C++
Estrellas
326
Forks
137
Merge medio
3 d 9 h
PR fusionados (30 d)
5

Descripción

### [REQUIRED] Please fill in the following fields:

* Pre-built SDK from the [website](https://firebase.google.com/download/cpp) or open-source from this repo: YES
* Firebase C++ SDK version: 12.7.0
* Main Firebase Components in concern: Auth
* Other Firebase Components in use: App
* Platform you are using the C++ SDK on: Linux
* Platform you are targeting: Desktop

### [REQUIRED] Please describe the question here:

I'm trying out the SDK on Linux, and while I accomplished creating a basic demo with the app module, I'm not able to link properly the auth module using the prebuilt libs.

The error I'm getting is a lot of undefined references and I'm not sure why. Shouldn't they be available in the provided .a files?
```
[main] Building folder: /home/david/data_ssd/Dev/CPP/firebase-demo/build
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/david/data_ssd/Dev/CPP/firebase-demo/build --config Debug --target all -j 14 --
[build] [ 50%] Linking CXX executable firebase-demo
[build] /usr/bin/ld: /home/david/Downloads/firebase_cpp_sdk_12.7.0/firebase_cpp_sdk/libs/linux/x86_64/cxx11/libfirebase_auth.a(9b788918c2ba0e0ffaefa78515169526_auth_desktop.cc.o): in function `firebase::auth::Auth::DestroyPlatformAuth(firebase::auth::AuthData*)':
[build] auth_desktop.cc:(.text+0x3ace): undefined reference to `firebase::internal::FunctionRegistry::UnregisterFunction(firebase::internal::FunctionId)'
[build] /usr/bin/ld: auth_desktop.cc:(.text+0x3ae3): undefined reference to `firebase::internal::FunctionRegistry::UnregisterFunction(firebase::internal::FunctionId)'
[build] /usr/bin/ld: auth_desktop.cc:(.text+0x3af5): undefined reference to `firebase::internal::FunctionRegistry::UnregisterFunction(firebase::internal::FunctionId)'
[build] /usr/bin/ld: auth_desktop.cc:(.text+0x3b0a): undefined reference to `firebase::internal::FunctionRegistry::UnregisterFunction(firebase::internal::FunctionId)'
[build] /usr/bin/ld: auth_desktop.cc:(.text+0x3b1f): undefined reference to `firebase::internal::FunctionRegistry::UnregisterFunction(firebase::internal::FunctionId)'
[build] /usr/bin/ld: /home/david/Downloads/firebase_cpp_sdk_12.7.0/firebase_cpp_sdk/libs/linux/x86_64/cxx11/libfirebase_auth.a(9b788918c2ba0e0ffaefa78515169526_auth_desktop.cc.o):auth_desktop.cc:(.text+0x3b34): more undefined references to `firebase::internal::FunctionRegistry::UnregisterFunction(firebase::internal::FunctionId)' follow
[build] /usr/bin/ld: /home/david/Downloads/firebase_cpp_sdk_12.7.0/firebase_cpp_sdk/libs/linux/x86_64/cxx11/libfirebase_auth.a(9b788918c2ba0e0ffaefa78515169526_auth_desktop.cc.o): in function `firebase::auth::Auth::DestroyPlatformAuth(firebase::auth::AuthData*)':
[build] auth_desktop.cc:(.text+0x3c91): undefined reference to `firebase::app::secure::UserSecureManager::~UserSecureManager()'
[build] /usr/bin/ld: /home/david/Downloads/firebase_cpp_sdk_12.7.0/firebase_cpp_sdk/libs/linux/x86_64/cxx11/libfirebase_auth.a(9b788918c2ba0e0ffaefa78515169526_auth_desktop.cc.o): in function `firebase::auth::InitializeUserDataPersist(firebase::auth::AuthData*)':
[build] auth_desktop.cc:(.text+0x58e8): undefined reference to `firebase::internal::CreateAppIdentifierFromOptions[abi:cxx11](firebase::AppOptions const&)'
[build] /usr/bin/ld: auth_desktop.cc:(.text+0x594b): undefined reference to `firebase::app::secure::UserSecureManager::~UserSecureManager()'
...
[build] clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[build] gmake[2]: *** [CMakeFiles/firebase-demo.dir/build.make:99: firebase-demo] Error 1
[build] gmake[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/firebase-demo.dir/all] Error 2
[build] gmake: *** [Makefile:91: all] Error 2
[proc] The command: /usr/bin/cmake --build /home/david/data_ssd/Dev/CPP/firebase-demo/build --config Debug --target all -j 14 -- exited with code: 2
[driver] Build completed: 00:00:00.227
[build] Build finished with exit code 2
```

Demo below:

### CMakeLists.txt
```cmake
cmake_minimum_required(VERSION 3.10.0)
project(firebase-demo VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(FIREBASE_SDK_PATH "/home/david/Downloads/firebase_cpp_sdk_12.7.0/firebase_cpp_sdk")
set(TARGET_EXE_NAME "firebase-demo")

add_subdirectory(${FIREBASE_SDK_PATH} firebase_sdk)

add_executable(${TARGET_EXE_NAME} demo.cpp)

set(FIREBASE_LIBS
firebase_app
firebase_auth
)

target_link_libraries(${TARGET_EXE_NAME} PUBLIC ${FIREBASE_LIBS})
target_include_directories(${TARGET_EXE_NAME} INTERFACE "${FIREBASE_SDK_PATH}/include")
```

### demo.cpp

```cpp
#include "firebase/app.h"
#include "firebase/auth.h"

int main() {
firebase::App *app = firebase::App::Create(firebase::AppOptions());
firebase::auth::Auth *auth = firebase::auth::Auth::GetAuth(app);
return 0;
}
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.