Search code examples
c++flutterwindowsfirebase

Flutter Windows App - "error LNK2001: unresolved external symbol __std_init_once_link_alternate_names_and_abort" After Adding Firebase


I’m working on a Flutter project targeting Windows. Initially, I created a new Flutter project, and the app ran perfectly on Windows without any issues. However, after integrating Firebase (specifically firebase_core and firebase_firestore) into the project and attempting to rerun the app, I encountered a series of linker errors during the build process.

The errors seem to revolve around unresolved external symbols, particularly __std_init_once_link_alternate_names_and_abort and others like __std_find_trivial_2 and __std_min_element_8. Below is the full error output from the build process:

firebase_firestore.lib(1563d4ec1bb2cfbdcd33c8f821a59874_firestore_core.dir_Debug_document_reference.obj) : error LNK2001: unresolved external symbol __std_init_once_link_alternate_names_and_abort [C:\Project\testingproject\build\windows\x64\runner\testingproject.vcxproj]
firebase_firestore.lib(1563d4ec1bb2cfbdcd33c8f821a59874_firestore_core.dir_Debug_firestore.obj) : error LNK2001: unresolved external symbol __std_init_once_link_alternate_names_and_abort [C:\Project\testingproject\build\windows\x64\runner\testingproject.vcxproj]
firebase_firestore.lib(1563d4ec1bb2cfbdcd33c8f821a59874_firestore_core.dir_Debug_field_filter.obj) : error LNK2001: unresolved external symbol __std_init_once_link_alternate_names_and_abort [C:\Project\testingproject\build\windows\x64\runner\testingproject.vcxproj]
firebase_firestore.lib(1563d4ec1bb2cfbdcd33c8f821a59874_firestore_core.dir_Debug_query.obj) : error LNK2001: unresolved external symbol __std_init_once_link_alternate_names_and_abort [C:\Project\testingproject\build\windows\x64\runner\testingproject.vcxproj]
firebase_firestore.lib(4ee4852b7e44084b709f4c86224171f1_absl_str_format_internal.dir_Debug_arg.obj) : error LNK2019: unresolved external symbol __std_find_trivial_2 referenced in function "wchar_t const * __cdecl __std_find_trivial<wchar_t const ,wchar_t>(wchar_t const *,wchar_t const *,wchar_t)" (??$__std_find_trivial@$$CB_W_W@@YAPEB_WPEB_W0_W@Z) [C:\Project\testingproject\build\windows\x64\runner\testingproject.vcxproj]
firebase_firestore.lib(ea039456823ba76e9082b438a5fcc026_grpc.dir_Debug_writing.obj) : error LNK2019: unresolved external symbol __std_min_element_8 referenced in function "__int64 const * __cdecl __std_min_element<__int64 const >(__int64 const *,__int64 const *)" (??$__std_min_element@$$CB_J@@YAPEB_JPEB_J0@Z) [C:\Project\testingproject\build\windows\x64\runner\testingproject.vcxproj]
C:\Project\testingproject\build\windows\x64\runner\Debug\testingproject.exe : fatal error LNK1120: 7 unresolved externals [C:\Project\testingproject\build\windows\x64\runner\testingproject.vcxproj]
Error: Build process failed.
environment:
  sdk: ^3.7.0

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.8
  firebase_core: ^3.12.0
  cloud_firestore: ^5.6.4
  firebase_auth: ^5.5.0

enter image description here

What could be causing these linker errors after adding Firebase to my Flutter Windows project? Is this related to a mismatch in the C++ standard library, Firebase SDK, or something else? How can I resolve this error

Any help or pointers would be greatly appreciated!


Solution

  • I found the solution. I uninstalled Visual Studio, downloaded the latest Visual Studio setup, and used that setup to install C++. Then, I updated all the Firebase packages in the Flutter project.