LINK : fatal error LNK1104: cannot open file 'python27.lib'

佐手、 提交于 2021-02-18 20:06:20

问题


I was trying to compile pycrypto-2.6.1 from source for Python 2.7.10 64-Bit Windows Version and facing the following error.

Processing pycrypto-2.6.1.tar.gz
Writing c:\users\sivasuba\appdata\local\temp\easy_install-ecznz_\pycrypto-2.6.1\setup.cfg
Running pycrypto-2.6.1\setup.py -q bdist_egg --dist-dir c:\users\sivasuba\appdata\local\temp\easy_install-ecznz_\pycrypto-2.6.1\egg-dist-tmp-us3gka
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
winrand.c
LINK : fatal error LNK1104: cannot open file 'python27.lib'
error: Setup script exited with error: command 'C:\\Users\\sivasuba\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1104

Googling didn't help much. Any help on this would be appreciated.

P.S. I am not looking for pre-complied binaries. The requirement is to build it from source.


回答1:


It seems like your linker doesn't find python27.lib library.

LIB and LIBPATH are windows environment variables which are being used by the linker and compiler.

In which folder do you have python27.lib on your computer?

please confirm that LIB environment variable include the path for the python27.lib

If it didn't solve your problem - try adding python27.lib path also to LIBPATH




回答2:


Doing the following worked for me:

  1. python27.lib is located in 'libs' folder under Python27 (folder where python is installed on windows)
  2. Add 'LIB' environment variable to the that points to the directory/folder containing python27.lib library:




回答3:


This worked here:

On CMakeLists.txt add this line:

link_directories(C:\\python\\libs)

Note that my Python installation is at C:\python




回答4:


if its giving, LINK : fatal error LNK1104: cannot open file 'python26.lib'

Do as following :

1.Right click your project -> go to properties -> Linker -> Input -> Ignore specific Default Libraries -> type 'python26.lib'

Hope this will help ! Thanks. Best regards, Janath Francisco.




回答5:


The most obvious solution is to add the directory to the linker's include directories:

In VS 2015 it is Project settings - Linker - General - Additional Library Directories

You can either edit the line directly, or click the small button on the end of the line and edit via GUI



来源:https://stackoverflow.com/questions/36419747/link-fatal-error-lnk1104-cannot-open-file-python27-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!