Reputation: 101
I'm trying to deploy my Django website, which is written using Python 2.7, on a windows 64 bit machine (Windows Server 2008 R2). I installed the pre-compiled version of Apache (Apache 2.4.16 x64) from https://www.apachehaus.com/cgi-bin/download.plx (due to lack of option provided by Apache Lounge***), and have checked that Python 2.7 runs on 64 bit and compiles with VC9. I wasn't able to find a pre-built binary for mod_wsgi (for Windows 64 bit and compiled with VC9), so I downloaded the source code for mod_wsgi from https://github.com/GrahamDumpleton/mod_wsgi/releases/tag/4.4.13 and followed the direction from https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst, changing the ap24py27-win64-VC9.mk
file to point at the right directories for APACHE_ROOTDIR
and PYTHON_ROOTDIR
, and using C++ 2008 64-bit Command Prompt to run the command nmake -f ap24py27-win64-VC9.mk clean
. However, this gave me the error:
wsgi_memory.obj : error LNK2019: unresolved external symbol GetProcessMemoryInfo referenced
in function getPeakRSS
mod_wsgi.so : fatal error LINK1120: 1 unresolved externals
NMAKE : fatal error U1077: `"...\Visual C++ for Python\9.0\VC\Bin\amd64\c1.EXE"` :
return code `0x2`
Stop.
I have read the installation and configuration documents for mod_wsgi multiple times and have searched the web including SO for the past few hours to no avail. What am I doing wrong here and how could I fix it?
***I know the official document for installing mod_wsgi warns against using binaries from other sources than Apache Lounge but I don't seem to be able to find the right compiled version (for VC9 and Windows 64 bit) from the site. Could this be a problem and if so, how could I fix it?
Update: following Adelin's suggestion, I was able to get namke -f ap24py27-win64-VC9.mk clean
to run. However, when I try running namke -f ap24py27-win64-VC9.mk
or namke -f ap24py27-win64-VC9.mk install
, I get pages of warnings that say: warning C4820: '...' : '...' bytes padding added after data member '...'
until the compiler quits with
fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
...\mod_wsgi-4.4.13\src\server\wsgi_memory.c<124> : warning C4711: function 'getCurrentRSS' selected for automatic inline expansion
NMAKE: fatal error U1077: '"C:\...\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\c1.EXE"' : return code '0x2'
Stop.
Does anyone have any idea why this might be and how I should go about fixing it?
Upvotes: 4
Views: 2951
Reputation: 8199
I had this same error.
The problem is that the cl.exe
doesn't find the psapi.lib
. This lib includes the function referenced in wsgi_memory.c
- GetProcessMemoryInfo
.
To fix this, you should follow these steps:
psapi.lib
(run a search on C:\
)ap24py27-win64-VC9.mk
file you are using to compile, with
any text editor.mk
file it includes. Most probably common-VC9.mk
common-VC9.mk
) with any text editorLDFLAGS
, append yet another line of /LIBPATH:"PATH_FOUND_AT_STEP_1"\
What a pain in the ass this was for me too :)
P.S. If you don't find psapi.lib
anywhere, it's because you don't have the Windows SDK. I installed both Windows 7 and Windows 8 SDKs and eventually had the psapi.lib
located here C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64
Edit:
To give you a solution for your newest errors in a somewhat general way, whenever nmake
throws "No such file"
errors, the location for the file is not properly referenced in common-VC9.mk
file.
There are two types of files nmake
will look for: .h
or .lib
.
If a .h
is not found, the corresponding path should be properly referenced under the CPPFLAGS
variable of common-VC9.mk
file.
If a .lib
is not found, you need to update LDFLAGS
path accordingly.
How? The same way you included the path for psapi.lib
: locate the file and append the corresponding path to the proper variable: CPPFLAGS
or LDFLAGS
.
Upvotes: 3