MSVS compilation issue
Closed this issue · 2 comments
Hi,
When following the compilation guide written in the readme file, i got the following output:
C:\Users\TEST\Downloads\pthread-win32-master\pthread-win32-master>nmake realclea
n VC
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
if exist *.obj del *.obj
if exist *.def del *.def
if exist *.ilk del *.ilk
if exist *.pdb del *.pdb
if exist *.exp del *.exp
if exist *.map del *.map
if exist *.o del *.o
if exist *.i del *.i
if exist *.res del *.res
if exist *.dll del *.dll
if exist *.lib del *.lib
if exist *.a del *.a
if exist *.manifest del *.manifest
if exist *_stamp del *_stamp
cd tests && "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\
nmake.exe" clean
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
if exist *.dll erase *.dll
if exist *.lib erase *.lib
if exist pthread.h erase pthread.h
if exist semaphore.h erase semaphore.h
if exist sched.h erase sched.h
if exist *.e erase *.e
if exist *.i erase *.i
if exist *.obj erase *.obj
if exist *.pdb erase *.pdb
if exist *.o erase *.o
if exist *.asm erase *.asm
if exist *.exe erase *.exe
if exist *.manifest erase *.manifest
if exist *.pass erase *.pass
if exist *.bench erase *.bench
if exist *.log erase *.log
cl /I. /DHAVE_CONFIG_H /O2 /Ob2 /W3 /MD /nologo /DPTW32_BUILD_INLINED /D
__CLEANUP_C -c pthread.c
pthread.c
c:\users\test\downloads\pthread-win32-master\pthread-win32-master\dll.c(45) : fa
tal error C1189: #error : "Should not compile dynamic library code when apparen
tly trying to build a static lib"
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\Bin\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\Bin\nmake.exe"' : return code '0x2'
Stop.
My configuration is :
Windows 7 64b
MSVS 2010 express
Windows SDK 7.1
FYI, I had the same issue when trying to compile on several computers, with different versions of MSVS.
Thanks for your help.
It seems to be probelms with the sanity checks in dll.c. It's expecting _WINDLL
to be defined but it never is. In the Visual Studio Project, the definition is inherited, but this doesn't seem to be the case if building from the makefile.
As a work around you can add this definition to the makefile so that, for example, line 137 becomes:
@ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /D_WINDLL /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).dll
That is for building with nmake clean VC
, but if you want to build with a different non-static build, change that line instead.
You could also add the definition directly into dll.c instead.
I include the following here in case anyone else runs into the same trouble
In my case I received another error. This is caused by the TARGET_CPU environment variable not being set correctly.
version.rc(52) : error RC2188: D:\...\pthread-win32\RCa08532(406) : fatal error RC1116: RC terminating after preprocessor errors
To fix this, the target cpu can be manually defined in version.rc, by adding, for example, #define PTW32_ARCHx64
, or whichever target is required.
Thanks for your help, this solved the issue.
Shouldn't this be included in the readme ?