firebase / firebase/firebase-cpp-sdk
[Question] Cannot link with Auth on Linux
- Ngôn ngữ chính
- C++
- Star
- 326
- Fork
- 137
- Merge trung bình
- 3 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 5
Mô tả
### [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;
}
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với CMakeLists.txt và demo.cpp được cung cấp, sau đó tái hiện bản build Linux bằng Firebase SDK 12.7.0 và kiểm tra lệnh linker được tạo ra. Theo dõi các target firebase_app và firebase_auth cùng các symbol chưa được phân giải của chúng; issue được hoàn tất khi demo tối thiểu được liên kết thành công mà không có tham chiếu chưa được định nghĩa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- cmake, cpp
- Lĩnh vực
- authentication, build-system, operating-systems
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 30/100