kpu / kenlm

KenLM: Faster and Smaller Language Model Queries
http://kheafield.com/code/kenlm/
Other
2.5k stars 513 forks source link

Windows - unresolved external symbol util::ToString ... #135

Closed kryton closed 6 years ago

kryton commented 6 years ago

Hi. I understand you don't actively maintain the windows build, but I thought others might be able to help. I'm using VS2017.

The first thing I needed to do was to fix that GetTempDir was expecting a LWPSTR, not a char*. (my C/C++ is VERY rusty.. so my apologies on the code quality.

diff --git a/util/file.cc b/util/file.cc
index 7ccc2d2..e68329a 100644
--- a/util/file.cc
+++ b/util/file.cc
@@ -530,8 +530,10 @@ std::FILE *FMakeTemp(const StringPiece &base) {
 std::string DefaultTempDirectory() {
 #if defined(_WIN32) || defined(_WIN64)
   char dir_buffer[1000];
-  if (GetTempPath(1000, dir_buffer) == 0)
+  WCHAR unicodeBuffer[1000];
+  if (GetTempPath(1000, unicodeBuffer) == 0)
     throw std::runtime_error("Could not read temporary directory.");
+  wcstombs(dir_buffer, unicodeBuffer, sizeof(dir_buffer));
   std::string ret(dir_buffer);
   NormalizeTempPrefix(ret);
   return ret;

the code all compiled, but now it can't find util::ToString. in various places. I assume this is some missing include or something.

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2001 unresolved external symbol "char * __cdecl util::ToString(unsigned int,char *)" (?ToString@util@@YAPEADIPEAD@Z) build_binary    ...\kenlm\windows\kenlm_x64d.lib(search_hashed.obj) 1   

thanks in advance Ian

kryton commented 6 years ago

ok.. it looks like the SLN file is missing a series of 'util' files. I added them, and change the 'parallel read' so it used the non-threaded version.. but it now builds.

hoping one of your windows contributors can do adjust this in the VS2010 VS file. (I don't have this)