ufal / udpipe

UDPipe: Trainable pipeline for tokenizing, tagging, lemmatizing and parsing Universal Treebanks and other CoNLL-U files
Mozilla Public License 2.0
364 stars 77 forks source link

Unable to compile REST Server on Windows with TDM-GCC #72

Closed mosynaq closed 6 years ago

mosynaq commented 6 years ago

Hi! I succeeded compiling the exepart of the package using mingw32-make BITS=64 PLATFORM=win-vs -j8 but it seems that there is a problem with the REST Server part. I issue mingw32-make server BITS=64 PLATFORM=win-gcc but I get the following error:

g++ -o .build/rest_server-microrestd-rest_server-rest_server.win-gcc-normal64.o -MMD -MP -std=c++11 -W -Wall -mtune=generic -msse -msse2 -mfpmath=sse -fvisibility=hidden -U_FORTIFY_SOURCE -m64 -O3 -I. -c rest_server/microrestd/rest_server/rest_server.cpp
rest_server/microrestd/rest_server/rest_server.cpp: In member function 'void ufal::microrestd::rest_server::log(Args&& ...)':
rest_server/microrestd/rest_server/rest_server.cpp:522:33: error: there are no arguments to 'localtime_r' that depend on a template parameter, so a declaration of 'localtime_r' must be available [-fpermissive]
   localtime_r(&time_now, &tm_now);
                                 ^
rest_server/microrestd/rest_server/rest_server.cpp:522:33: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
rest_server/microrestd/rest_server/rest_server.cpp: In instantiation of 'void ufal::microrestd::rest_server::log(Args&& ...) [with Args = {const char (&)[28], unsigned int&, const char (&)[19], unsigned int&, const char (&)[11], unsigned int&, const char (&)[25], unsigned int&, const char (&)[17], unsigned int&, char}]':
rest_server/microrestd/rest_server/rest_server.cpp:390:199:   required from here
rest_server/microrestd/rest_server/rest_server.cpp:522:14: error: 'localtime_r' was not declared in this scope
   localtime_r(&time_now, &tm_now);
              ^
rest_server/microrestd/rest_server/rest_server.cpp: In instantiation of 'void ufal::microrestd::rest_server::log(Args&& ...) [with Args = {const char (&)[79]}]':
rest_server/microrestd/rest_server/rest_server.cpp:402:87:   required from here
rest_server/microrestd/rest_server/rest_server.cpp:522:14: error: 'localtime_r' was not declared in this scope
rest_server/microrestd/rest_server/rest_server.cpp: In instantiation of 'void ufal::microrestd::rest_server::log(Args&& ...) [with Args = {const char (&)[11], unsigned int&, const char (&)[22]}]':
rest_server/microrestd/rest_server/rest_server.cpp:407:59:   required from here
rest_server/microrestd/rest_server/rest_server.cpp:522:14: error: 'localtime_r' was not declared in this scope
rest_server/microrestd/rest_server/rest_server.cpp: In instantiation of 'void ufal::microrestd::rest_server::log(Args&& ...) [with Args = {const char (&)[21]}]':
rest_server/microrestd/rest_server/rest_server.cpp:411:29:   required from here
rest_server/microrestd/rest_server/rest_server.cpp:522:14: error: 'localtime_r' was not declared in this scope
rest_server/microrestd/rest_server/rest_server.cpp: In instantiation of 'void ufal::microrestd::rest_server::log(Args&& ...) [with Args = {const char (&)[33]}]':
rest_server/microrestd/rest_server/rest_server.cpp:438:41:   required from here
rest_server/microrestd/rest_server/rest_server.cpp:522:14: error: 'localtime_r' was not declared in this scope
rest_server/microrestd/rest_server/rest_server.cpp: In instantiation of 'void ufal::microrestd::rest_server::log(Args&& ...) [with Args = {const char (&)[9], char (&)[64], char, const char*, char, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&}]':
rest_server/microrestd/rest_server/rest_server.cpp:596:101:   required from here
rest_server/microrestd/rest_server/rest_server.cpp:522:14: error: 'localtime_r' was not declared in this scope
Makefile.builtem:346: recipe for target '.build/rest_server-microrestd-rest_server-rest_server.win-gcc-normal64.o' failed
mingw32-make: *** [.build/rest_server-microrestd-rest_server-rest_server.win-gcc-normal64.o] Error 1

It looks a flag like -fpermissive should be passed but I have no idea how.

foxik commented 6 years ago

This is caused by the fact that localtime_r is not available on Windows -- we use localtime_s for Visual C++, but not for TDM-GCC. I am unsure if localtime_s is available in TDM-GCC, but it should according to time.h header from mingw64-runtime.

Could you please try changing the line https://github.com/ufal/udpipe/blob/ff0bc77d48549446523c7149307e93c2c22bb3ca/src/rest_server/microrestd/rest_server/rest_server.cpp#L519 to

#if defined(_WIN32) && !defined(__CYGWIN__)

If it works, please write me, and I will commit the change permanently.

mosynaq commented 6 years ago

Thanks! It worked for me!

foxik commented 6 years ago

Thanks, I released a bugfix release of MicroRestD and updated it in UDPipe master.