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

Can't compile "Hello world" program. Not sure why! #124

Open
BLutherEUNE opened this issue Oct 30, 2019 · 4 comments
Open

Can't compile "Hello world" program. Not sure why! #124

BLutherEUNE opened this issue Oct 30, 2019 · 4 comments

Comments

@BLutherEUNE
Copy link

Hi, I just stared with PyD and I am trying to make it work. I have downloaded the latest release version and unzipped it in my working directory. Also I copied the two files from the documentation (the kind of "hello world" program). I am using windows 10 and python 2.7.12 so I run the command python .\setup.py pydexe but I get the following error

travis_fold:end:pyd_compile-dcaf5080-fb16-11e9-84a3-f859714c6a61
Traceback (most recent call last):
  File ".\setup.py", line 10, in <module>
    build_deimos=True, d_lump=True
  File "C:\Users\PapaniGe\Desktop\learning\project earth\pydtest\pyd\support.py", line 230, in setup
    base_setup(*args, **kwargs)
  File "C:\Users\PapaniGe\AppData\Local\Continuum\Anaconda2\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
  File "C:\Users\PapaniGe\AppData\Local\Continuum\Anaconda2\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Users\PapaniGe\AppData\Local\Continuum\Anaconda2\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Users\PapaniGe\Desktop\learning\project earth\pydtest\pyd\support.py", line 128, in run
    self.per_ext(ext)
  File "C:\Users\PapaniGe\Desktop\learning\project earth\pydtest\pyd\support.py", line 169, in per_ext
    target_lang=language)
  File "C:\Users\PapaniGe\AppData\Local\Continuum\Anaconda2\lib\distutils\ccompiler.py", line 700, in link_executable
    debug, extra_preargs, extra_postargs, None, target_lang)
  File "C:\Users\PapaniGe\Desktop\learning\project earth\pydtest\pyd\dcompiler.py", line 750, in link
    return DCompiler.link(self, *args, **kwargs)
  File "C:\Users\PapaniGe\Desktop\learning\project earth\pydtest\pyd\dcompiler.py", line 520, in link
    library_dirs = list(set(_build_ext_library_dirs() + library_dirs))
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'

It appears that it tries to add two lists but the one is empty, so it breaks. Any thoughts?

@ariovistus
Copy link
Owner

looks like _build_ext_library_dirs() is trying to get library dirs out of distutils. I'm wondering if you haven't installed pyd as a python module? in C:\Users\PapaniGe\Desktop\learning\project earth\pydtest, run python setup.py install

@BLutherEUNE
Copy link
Author

Thanks. So, after setting up the library paths correctly I got rid of that error. I managed to build the hello world examples for both extending and embedding python on windows 7, but I have a problem on windows 10.

In particular for the extending example ( https://pyd.readthedocs.io/en/latest/extend.html ) lld-link complains with stuff like lld-link: error: unknown directive: EXETYPE. I fixed these by removing all lines except LIBRARY "hello.pyd" in my python_dll_def.def file, but now I get this error: lld-link: error: subsystem must be defined. I tried to resolve this by adding /subsystem:widows and /subsystem:console using the -L flag in the dmd command that runs behind the scenes, but then I get other linker errors regarding app entry point...

Any idea what to try next? Note that this seems to be a windows 10 issue, I managed to build everything fine on windows 7. Thanks a lot.

@ariovistus
Copy link
Owner

ariovistus commented Nov 2, 2019

I just tried it in win10 and met success. I installed dmd 2.088.1 with the vs2017 build tools. from cmd, I ran

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat

then built and ran examples/hello

python setup.py build
python test.py

which worked, but it did output some warnings:

build\temp.win-amd64-2.7\Release\infra\python_dll_def.def(2) : warning LNK4017: EXETYPE statement not supported for the target platform; ignored
build\temp.win-amd64-2.7\Release\infra\python_dll_def.def(3) : warning LNK4017: SUBSYSTEM statement not supported for the target platform; ignored
build\temp.win-amd64-2.7\Release\infra\python_dll_def.def(4) : warning LNK4017: CODE statement not supported for the target platform; ignored
build\temp.win-amd64-2.7\Release\infra\python_dll_def.def(4) : warning LNK4017: DATA statement not supported for the target platform; ignored

@BLutherEUNE
Copy link
Author

Thanks for the reply. So, one problem I have is that I can't install msvc or the build tools on the windows 10 machine without a license, as this is a corporate machine. I tried installing Windows SDK 7.1, which results in turning the errors into warnings as in your case, but I get a couple of different linker errors afterwards...

Creating library build\lib.win-amd64-2.7\hello.lib and object build\lib.win-amd64-2.7\hello.exp
libcmt.lib(dllcrt0.obj) : error LNK2005: _aenvptr already defined in libcmt.lib(crt0.obj)
libcmt.lib(dllcrt0.obj) : error LNK2005: _wenvptr already defined in libcmt.lib(crt0.obj)
libcmt.lib(dllcrt0.obj) : error LNK2005: __error_mode already defined in libcmt.lib(crt0.obj)
libcmt.lib(dllcrt0.obj) : error LNK2005: __app_type already defined in libcmt.lib(crt0.obj)
libcmt.lib(invarg.obj) : error LNK2019: unresolved external symbol RtlVirtualUnwind referenced in function _call_reportfault
libcmt.lib(gs_report.obj) : error LNK2001: unresolved external symbol RtlVirtualUnwind
libcmt.lib(invarg.obj) : error LNK2019: unresolved external symbol RtlLookupFunctionEntry referenced in function _call_reportfault
libcmt.lib(gs_report.obj) : error LNK2001: unresolved external symbol RtlLookupFunctionEntry
libcmt.lib(chandler.obj) : error LNK2019: unresolved external symbol __imp_RtlUnwindEx referenced in function __C_specific_handler
libcmt.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup
libcmt.lib(jmpuwind.obj) : error LNK2019: unresolved external symbol RtlUnwindEx referenced in function _local_unwind
build\lib.win-amd64-2.7\hello.pyd : fatal error LNK1120: 5 unresolved externals

I'll try to figure this out, but meanwhile, if you have an idea why exactly (and which components of) msvc is / are needed for building these extensions (e.g. Cython doesn't need these -- it works fine with just Visual C++ for Python), please let me know. Thanks again!

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

2 participants