Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error LNK2001: unresolved external symbol for absl #535

Open
jingtao01 opened this issue Dec 10, 2024 · 6 comments · May be fixed by #539
Open

error LNK2001: unresolved external symbol for absl #535

jingtao01 opened this issue Dec 10, 2024 · 6 comments · May be fixed by #539

Comments

@jingtao01
Copy link

When building from the latest 1.14.0 source code, I encountered numerous LNK2001 errors.

Here are my development environment details:

.NET version: 8.0.404
CMake version: 3.26.3
Visual Studio: 2022

I followed these steps:

  1. dotnet publish Reinterop~ -o .
  2. Opened Unity.
  3. cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug
  4. cmake --build build -j14 --target install --config Debug

After completing these steps, I received multiple LNK2001 errors. Some examples include:

Could you provide any insights into why this might be occurring?

Thank you in advance for your assistance.

s2.lib(s2coords.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20240722::string_view)" (??0LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@PEBDHVstring_view@23@@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(r2rect.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20240722::string_view)" (??0LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@PEBDHVstring_view@23@@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(coder.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20240722::string_view)" (??0LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@PEBDHVstring_view@23@@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] CesiumGeospatial.lib(S2CellID.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20240722::string_view)" (??0LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@PEBDHVstring_view@23@@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(s1interval.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20240722::string_view)" (??0LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@PEBDHVstring_view@23@@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(s2cell_id.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20240722::string_view)" (??0LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@PEBDHVstring_view@23@@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(s2latlng.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20240722::string_view)" (??0LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@PEBDHVstring_view@23@@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(s2coords.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@XZ) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(r2rect.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@XZ) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(coder.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@XZ) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] CesiumGeospatial.lib(S2CellID.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@XZ) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(s1interval.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@XZ) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(s2cell_id.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@XZ) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(s2latlng.cc.obj) : error LNK2001: unresolved external symbol "public: __cdecl absl::lts_20240722::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20240722@absl@@QEAA@XZ) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(s2coords.cc.obj) : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl absl::lts_20240722::log_internal::MakeCheckOpString<__int64,__int64>(__int64,__int64,char const *)" (??$MakeCheckOpString@_J_J@log_internal@lts_20240722@absl@@YAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_J0PEBD@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] s2.lib(r2rect.cc.obj) : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl absl::lts_20240722::log_internal::MakeCheckOpString<__int64,__int64>(__int64,__int64,char const *)" (??$MakeCheckOpString@_J_J@log_internal@lts_20240722@absl@@YAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_J0PEBD@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj] CesiumGeospatial.lib(S2CellID.obj) : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl absl::lts_20240722::log_internal::MakeCheckOpString<__int64,__int64>(__int64,__int64,char const *)" (??$MakeCheckOpString@_J_J@log_internal@lts_20240722@absl@@YAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_J0PEBD@Z) [F:\project\ttttttttttttttttttttttttttttttttt\Packages\com.cesium.unity\native~\build\Runtime\CesiumForUnityNative-Runtime.vcxproj]

@jingtao01
Copy link
Author

I noticed there is a section in the CHANGES.md that says:
'Moved the small amount of Abseil code embedded into the s2geometry library from the absl namespace to the cesium_s2geometry_absl namespace, in order to avoid linker errors when linking against both cesium-native and the full Abseil library.'
Could this be related to the error I'm encountering?

@kring
Copy link
Member

kring commented Dec 12, 2024

@jingtao01 this is most likely cause by the vcpkg abseil dependency getting out of sync. When you run the cmake configure command, you should see a message indicating the .ezvcpkg directory being used. Delete that entire directory and run configure+build again, and hopefully you won't get an error anymore.

@jingtao01
Copy link
Author

@kring
Thank you very much for your help.
My ezpkg directory is located at D:\ezvcpkg\2024.11.16. I emptied this directory and also emptied the native~\build directory, then build and install, but I still encountered the same errors.
I noticed that in version 1.14.0, a new directory native~\vcpkg\ports\abseil was added. Some vcpkg_replace_string perations were performed.
After deleting this directory and clearing both D:\ezvcpkg\2024.11.16 and native~\build directories, the errors disappeared and the build install was successful. I am not quite sure what happened.

@kring
Copy link
Member

kring commented Dec 17, 2024

Oh you know @jingtao01, I think @j9liu ran into a very similar problem in Cesium for Unreal. You should be able to fix it by modifying the absl/portfile.cmake file like this:
CesiumGS/cesium-unreal@6a44c2f

I'm not sure if you're in a position to try it now that you've solved your immediate problem, but if you do try it, please let us know if it works.

@jingtao01
Copy link
Author

@kring
I reset git and cleared the build and ezpkg directories, then I encountered the same link error during the build process.
Then, after clearing the build and ezpkg directories and modifying absl/portfile.cmake, the build was successful without any errors. This commit indeed fixed my issue.

@kring
Copy link
Member

kring commented Dec 17, 2024

Thanks @jingtao01! We'll bring that change over to Unity, too, then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants