admin管理员组文章数量:1332865
So I'm trying to use the library utf8proc in my project. I've built the library using cmake, which has created a static lib file (utf8proc_static.lib), which I'm referencing in my Build.cs file using PublicAdditionalLibraries.Add. It seems to recognize the lib, since, if I make changes to the path, it immediately complains that it can't find the file, so all seems well on that front. I also included the location of the header file utf8proc.h, using PublicIncludePaths.Add.
In the cpp where I want to use the lib, I'm using #include <utf8proc.h>, and again all seems well, as I can travel to each function's definition over in the utf8proc.c file, using control+lmb. However, when I build the project it tells me there are 5 unresolved externals, and I'm getting 5 LNK2019 errors like this one:
Error LNK2019 unresolved external symbol __imp_utf8proc_iterate referenced in function "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl convertToUnicode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?convertToUnicode@@YA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
I've been troubleshooting for a while but I can't seem to get to the bottom of it. I'm using other dlls and libs, and I'm not having issues with any other library. I think this is the only static lib I'm using though.
I've tried deleting UE's binaries and intermediate folders and regenerating the visual studio project files. Tried adding the folders containing the.lib and .h files to the VC++ directories via VS22 project settings. Out of desperation I've also tried moving the lib file over to the UE project's Binaries/Win64 folder and I've also tried including one of utf8proc's subfolders, which has a few more h and c files, but nothing.
At my wits' end. Any help would be greatly appreciated.
So I'm trying to use the library utf8proc in my project. I've built the library using cmake, which has created a static lib file (utf8proc_static.lib), which I'm referencing in my Build.cs file using PublicAdditionalLibraries.Add. It seems to recognize the lib, since, if I make changes to the path, it immediately complains that it can't find the file, so all seems well on that front. I also included the location of the header file utf8proc.h, using PublicIncludePaths.Add.
In the cpp where I want to use the lib, I'm using #include <utf8proc.h>, and again all seems well, as I can travel to each function's definition over in the utf8proc.c file, using control+lmb. However, when I build the project it tells me there are 5 unresolved externals, and I'm getting 5 LNK2019 errors like this one:
Error LNK2019 unresolved external symbol __imp_utf8proc_iterate referenced in function "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl convertToUnicode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?convertToUnicode@@YA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
I've been troubleshooting for a while but I can't seem to get to the bottom of it. I'm using other dlls and libs, and I'm not having issues with any other library. I think this is the only static lib I'm using though.
I've tried deleting UE's binaries and intermediate folders and regenerating the visual studio project files. Tried adding the folders containing the.lib and .h files to the VC++ directories via VS22 project settings. Out of desperation I've also tried moving the lib file over to the UE project's Binaries/Win64 folder and I've also tried including one of utf8proc's subfolders, which has a few more h and c files, but nothing.
At my wits' end. Any help would be greatly appreciated.
Share edited Nov 22, 2024 at 18:46 genpfault 52.2k12 gold badges91 silver badges149 bronze badges asked Nov 22, 2024 at 6:45 Tarek KhalifaTarek Khalifa 271 silver badge1 bronze badge 1- Are you sure that the library compiled with cmake is compiled using exactly the same version of MSBUILD aka Visual Studio as your Unreal Engine? – LeDYoM Commented Nov 22, 2024 at 9:03
1 Answer
Reset to default 2The clue here is the __imp
in your unresolved names. This means that your compiler is telling the linker that you want to link dynamically. 'Imp' stands for import, and on the Windows platform dynamic linking is commonly done with an import library.
From looking at the utf8proc.h header file it seems that the solution is to add #define UTF8PROC_STATIC
before including the header file.
#define UTF8PROC_STATIC
#include <utf8proc.h>
Alternatively you could use the compiler option to define this symbol.
I could not find this officially documented anywhere, but I expect it will work.
本文标签: Issue with static library linking for C (Unreal Engine 5 project)Stack Overflow
版权声明:本文标题:Issue with static library linking for C++ (Unreal Engine 5 project) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742293622a2448283.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论