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 building on Windows #82

Open
bdaveh360 opened this issue Jul 27, 2022 · 8 comments
Open

Error building on Windows #82

bdaveh360 opened this issue Jul 27, 2022 · 8 comments

Comments

@bdaveh360
Copy link

Hi All,

I am trying to build pypostal on Windows and have successfully built the postal.lib but when I attempt to "pip install postal" I get this error. Any ideas on how to fix this please?

  "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -I/usr/local/include -IC:\dev\libpostal\headers\include "-IC:\Users\My ser\miniconda3\envs\myenv\include" "-IC:\Users\My ser\miniconda3\envs\myenv\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tcpostal/pyexpand.c /Fobuild\temp.win-amd64-cpython-39\Release\postal/pyexpand.obj -std=c99
  cl : Command line warning D9002 : ignoring unknown option '-std=c99'
  pyexpand.c
  C:\dev\libpostal\headers\include\stdio.h(577): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdio.h(584): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdio.h(590): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdio.h(851): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdio.h(881): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdio.h(1235): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdio.h(1242): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdio.h(1248): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdio.h(1364): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdio.h(1374): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\swprintf.inl(27): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\swprintf.inl(34): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdlib.h(389): error C2085: '_exit': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(389): error C2143: syntax error: missing ';' before 'type'
  C:\dev\libpostal\headers\include\stdlib.h(396): error C2085: '_Exit': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(396): error C2143: syntax error: missing ';' before 'type'
  C:\dev\libpostal\headers\include\stdlib.h(399): error C2085: '_Exit': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(399): error C2143: syntax error: missing ';' before '{'
  C:\dev\libpostal\headers\include\stdlib.h(399): warning C4013: '_exit' undefined; assuming extern returning int
  C:\dev\libpostal\headers\include\stdlib.h(399): error C2065: 'status': undeclared identifier
  C:\dev\libpostal\headers\include\stdlib.h(405): error C2059: syntax error: 'type'
  C:\dev\libpostal\headers\include\stdlib.h(683): error C2491: '_beep': definition of dllimport function not allowed
  C:\dev\libpostal\headers\include\stdlib.h(685): error C2085: '_seterrormode': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(685): error C2143: syntax error: missing ';' before 'type'
  C:\dev\libpostal\headers\include\stdlib.h(686): error C2085: '_sleep': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(686): error C2143: syntax error: missing ';' before 'type'
  C:\dev\libpostal\headers\include\stdlib.h(707): error C2085: 'ecvt': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(708): error C2085: 'fcvt': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(709): error C2085: 'gcvt': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(710): error C2085: 'itoa': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(711): error C2085: 'ltoa': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(712): error C2085: 'putenv': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(716): error C2085: 'swab': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(719): error C2085: 'ultoa': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(720): error C2085: 'onexit': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(726): error C2085: 'lldiv_t': not in formal parameter list
  C:\dev\libpostal\headers\include\stdlib.h(728): error C2061: syntax error: identifier 'lldiv_t'
  C:\dev\libpostal\headers\include\stdlib.h(732): error C2169: 'llabs': intrinsic function, cannot be defined
  C:\dev\libpostal\headers\include\mm_malloc.h(32): error C2054: expected '(' to follow '__inline__'
  C:\dev\libpostal\headers\include\mm_malloc.h(34): error C2085: '_mm_malloc': not in formal parameter list
  C:\dev\libpostal\headers\include\mm_malloc.h(34): error C2143: syntax error: missing ';' before '{'
  C:\dev\libpostal\headers\include\mm_malloc.h(72): error C2054: expected '(' to follow '__inline__'
  C:\dev\libpostal\headers\include\mm_malloc.h(73): error C2085: '_mm_free': not in formal parameter list
  C:\dev\libpostal\headers\include\mm_malloc.h(73): error C2143: syntax error: missing ';' before '{'
  C:\dev\libpostal\headers\include\malloc.h(125): error C2065: '_ALLOCA_S_MARKER_SIZE': undeclared identifier
  C:\dev\libpostal\headers\include\malloc.h(144): error C2065: '_ALLOCA_S_MARKER_SIZE': undeclared identifier
  C:\dev\libpostal\headers\include\math.h(209): error C2065: '__asm__': undeclared identifier
  C:\dev\libpostal\headers\include\math.h(209): error C2146: syntax error: missing ';' before identifier '__volatile__'
  C:\dev\libpostal\headers\include\math.h(209): warning C4013: '__volatile__' undefined; assuming extern returning int
  C:\dev\libpostal\headers\include\math.h(209): error C2143: syntax error: missing ')' before ':'
  C:\dev\libpostal\headers\include\math.h(220): error C2065: '__asm__': undeclared identifier
  C:\dev\libpostal\headers\include\math.h(220): error C2146: syntax error: missing ';' before identifier '__volatile__'
  C:\dev\libpostal\headers\include\math.h(220): error C2143: syntax error: missing ')' before ':'
  C:\dev\libpostal\headers\include\math.h(226): error C2169: 'fabs': intrinsic function, cannot be defined
  C:\dev\libpostal\headers\include\math.h(682): error C2169: 'sinhf': intrinsic function, cannot be defined
  C:\dev\libpostal\headers\include\math.h(688): error C2169: 'coshf': intrinsic function, cannot be defined
  C:\dev\libpostal\headers\include\math.h(694): error C2169: 'tanhf': intrinsic function, cannot be defined
  C:\dev\libpostal\headers\include\math.h(718): error C2169: 'expf': intrinsic function, cannot be defined
  C:\dev\libpostal\headers\include\math.h(891): error C2169: 'powf': intrinsic function, cannot be defined
  C:\dev\libpostal\headers\include\math.h(1157): error C2065: '__asm__': undeclared identifier
  C:\dev\libpostal\headers\include\math.h(1157): error C2146: syntax error: missing ';' before identifier '__volatile__'
  C:\dev\libpostal\headers\include\math.h(1158): error C2143: syntax error: missing ')' before ':'
  C:\dev\libpostal\headers\include\sys/types.h(68): error C2371: 'pid_t': redefinition; different basic types
  C:\Users\My ser\miniconda3\envs\myenv\include\pyconfig.h(190): note: see declaration of 'pid_t'
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> postal

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

@marcglobality
Copy link

same here on Mac. This is recent as it used to work...

@marcglobality
Copy link

I recreated the whole thing:

  1. git clone libpostal
  2. make + make install
  3. pip install

and now it works! so maybe it's just about refreshing the cached installation

@bdaveh360
Copy link
Author

Thanks @marcglobality - I just tried the same but seems the error persists so assuming this is a Windows specific thing? Some of the steps for windows are different and they all work down to the last step of pip install which is done as follows:

pip install postal --global-option=build_ext --global-option="-IC:\dev\libpostal\headers\include" --global-option="-LC:\dev\libpostal"

But results in the same error - any advice much appreciated!

@marcglobality
Copy link

where did you find those options? it seems very similar Windows vs Mac: https://github.com/openvenues/libpostal#installation-windows

in any case, I've done almost no coding on Windows, so I don't think can help. Good luck :)

@bdaveh360
Copy link
Author

These are the Windows instructions that are supposed to work:

40c865f

Installing libpostal on Windows

Install msys2 and launch a shell using the MSYS2 MingW 64-bit start menu option. Then:

pacman -S autoconf automake curl git make libtool gcc mingw-w64-x86_64-gcc
git clone https://github.com/openvenues/libpostal
cd libpostal
cp -rf windows/* ./
./bootstrap.sh
./configure --datadir=[...some dir with a few GB of space...]
make
make install

Now start a command prompt which has access to the Microsoft toolchain. This can be done by e.g. installing the Windows 10 SDK and then running the x64 Native Tools Command Prompt.

Assuming your MSYS and Python are installed in some standard locations, you can use this command prompt to build+install the Python library like so:

lib.exe /def:libpostal.def /out:libpostal.lib /machine:x64
pip install postal --global-option=build_ext --global-option="-IC:\msys64\usr\include" --global-option="-L[...libpostal checkout...]"
copy src\.libs\libpostal-1.dll "C:\Python36\Lib\site-packages\postal\libpostal.dll"

@bdaveh360
Copy link
Author

Just to add, I think this relates to the MSVC compiler options being passed perhaps? If anyone has a working Windows environment I would be interested to know which MSVC version you have and if any additional options were passed to cl.exe to get it to compile successfully.

@Deepak00077
Copy link

C:\msys64\mingw64\include\stdlib.h(723,42): error C2085: 'onexit': not in formal parameter list
7>C:\msys64\mingw64\include\stdlib.h(729,68): error C2085: 'lldiv_t': not in formal parameter list
7>C:\msys64\mingw64\include\stdlib.h(731,21): error C2061: syntax error: identifier 'lldiv_t'
7>C:\msys64\mingw64\include\stdlib.h(735,72): error C2169: 'llabs': intrinsic function, cannot be defined
7>C:\msys64\mingw64\include\malloc.h(128,49): error C2065: '_ALLOCA_S_MARKER_SIZE': undeclared identifier
7>C:\msys64\mingw64\include\malloc.h(147,55): error C2065: '_ALLOCA_S_MARKER_SIZE': undeclared identifier
7>C:\msys64\mingw64\include\winnt.h(137,1): fatal error C1189: #error: No supported target architecture.
7>test_xattr_platform.c
7>C:\msys64\mingw64\include\sys/types.h(77,17): error C2628: '_mode_t' followed by 'unsigned' is illegal (did you forget a ';'?)
7>C:\msys64\mingw64\include\sys/types.h(77,17): error C2628: '_mode_t' followed by 'short' is illegal (did you forget a ';'?)
7>C:\msys64\mingw64\include\sys/types.h(77,23): warning C4091: 'typedef ': ignored on left of 'unsigned short' when no variable is declared
7>C:\msys64\mingw64\include\stdio.h(268,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(279,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(293,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(304,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(315,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(332,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(339,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(346,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(360,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(371,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(401,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(414,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(421,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(428,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(458,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(471,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1078,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1089,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1100,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1112,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1119,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1126,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1136,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1147,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1158,5): error C2059: syntax error: 'type'
7>C:\msys64\mingw64\include\stdio.h(1165,5): error C2059: syntax error: 'type'

hey I got this type of error can u help me ?
I have try for all version of visual studio community
instead of mingw I have msys
I have try for both 32 bit and 64 bit

@Deepak00077
Copy link

I am trying to build libarchive with help of visual studio community

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

No branches or pull requests

3 participants