TinyCAD icon indicating copy to clipboard operation
TinyCAD copied to clipboard

VS2022 build failure. link error with libiconv?

Open g40 opened this issue 1 year ago • 1 comments

Any thoughts on this? Any help welcomed.

Win32 UNICODE build as cloned from Github.

NuGet reports libiconv is present:

image

All other packages are present and link as expected:

image

Truncated error report (all the rest is clean). " 1>Unicode Selected 1>R:\src\cpp\hardware\TinyCAD\src\sqlite\CppSQLite3U.cpp(256,1): warning C4715: 'CppSQLite3DB::execDML': not all control paths return a value 1>sqlite3.c 1>NetList.obj : error LNK2019: unresolved external symbol _libiconv_open referenced in function "void __cdecl to_utf8(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,class std::basic_ofstream<char,struct std::char_traits > &)" (?to_utf8@@YAXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@2@@Z) 1>XMLReader.obj : error LNK2001: unresolved external symbol _libiconv_open 1>XMLWriter.obj : error LNK2001: unresolved external symbol _libiconv_open 1>NetList.obj : error LNK2019: unresolved external symbol _libiconv referenced in function "void __cdecl to_utf8(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,class std::basic_ofstream<char,struct std::char_traits > &)" (?to_utf8@@YAXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@2@@Z) 1>XMLReader.obj : error LNK2001: unresolved external symbol _libiconv 1>XMLWriter.obj : error LNK2001: unresolved external symbol _libiconv 1>NetList.obj : error LNK2019: unresolved external symbol _libiconv_close referenced in function "void __cdecl to_utf8(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,class std::basic_ofstream<char,struct std::char_traits > &)" (?to_utf8@@YAXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@2@@Z) 1>XMLReader.obj : error LNK2001: unresolved external symbol _libiconv_close 1>XMLWriter.obj : error LNK2001: unresolved external symbol _libiconv_close 1>R:\src\cpp\hardware\TinyCAD\Debug\TinyCAD.exe : fatal error LNK1120: 3 unresolved externals 1>Done building project "TinyCad.vcxproj" -- FAILED. "

g40 avatar Aug 29 '24 17:08 g40

I had the same issues as you when using VC2022.

I suspect it may be due to VC2022 uses vc143 build env (and libraries), where as those being published via the NuGet package manager seemed to only support vc142 of libiconv/libjpeg/....

So, I ended up not using any of the NuGet packages and I used the vcpkg packages instead.

The ones I had to locally install were:

  • vcpkg install libiconv:x86-windows
  • vcpkg install libjpeg:x86-windows
  • vcpkg install libjpeg-turbo:x86-windows
  • vcpkg install libpng:x86-windows
  • vcpkg install libssh2:x86-windows (there were some other dependencies that were also built/installed so I did not have to manually install them myself, like zlib)

Also, there was a change I had to make to XMLReader.cpp:152 to account for passing a const char into the iconv function call.

I haven't thoroughly tested it yet, but it did build and run. :)

Image

mlshort avatar Sep 30 '25 18:09 mlshort