Question

It looks like some work has been done to make pthread-win32 work with x64, but there are no build instructions. I have tried simly building with the Visual Studio x64 Cross Tools Command Prompt, but when I try to link to the lib from an x64 application, it can't see any of the function exports. It seems like it is still compiling the lib as x86 or something.

I've even tried adding /MACHINE to the makefile in the appropriate places, but it doesn't help. Has anyone gotten this to work?

Was it helpful?

Solution 2

Until it's officially released, it looks like you have to check out the CVS head to get version 2.9 of the library. Version 2.9 has all the x64 patches, but you will still have problems if you try to compile the static library from the command line.

The only workaround I know of is to use the DLLs instead of statically linking the LIB.

OTHER TIPS

For me, I just use a 64-bit windows compiler (mingw-w64 cross compiler in this particular case) then make (with2.9.1) like:

$ make clean GC-static 

Then how I install it for use (some of this may not be needed, of course),

cp libpthreadGC2.a $mingw_w64_x86_64_prefix/lib/libpthread.a
cp pthread.h sched.h semaphore.h $mingw_w64_x86_64_prefix/include

then to use it, you have to define this (example ffmpeg configure line to use it):

--extra-cflags=-DPTW32_STATIC_LIB 

Anyhow that's one way.

Another way is to do the same then modify the *.h files and remove all references to dllexport from the headers (or manually define DPTW32_STATIC_LIB in the headers).

ex:

 sed 's/ __declspec (dllexport)//g;s/ __declspec (dllimport)//g'

(ref: zeranoe build scripts)

Here's how I did it (VS2015). Should work for older Visual Studios too.

1) Download the release .zip from SourceForge
2) Unpack to a clean folder- should see "pthreads.2"
3) Open up your Visual Studio command prompt, navigate to "pthreads.2." 4) Run "nmake", no arguments. It produces a help message listing all the legal commands you can give 'nmake' to build it. For more info, see "pthreads.2\FAQ" file which explains their 3 different flavors of 'cleanup' handling.

I would suggest building "VC" and "VC-debug" (and maybe the static ones of those) only. The 'real' pthreads is a C system library on POSIX platforms like Linux, so only those combos are going to give you the exact same C error behavior on Windows that you'd get on Linux, FreeBSD, etc.

This message might help.

to expand kgriffs answer one has to do two more things to actually build a 64bit DLL and not 32bit DLL.

First download latest pthreads via CVS (as suggested here)

1) use 64bit build tools - achieved by loading correct VC environment settings in command line (more about it here):

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat amd64

(change the 11.0 to whatever version you are using)

2) As it is written in the pthreads Makefile:

TARGET_CPU is an environment variable set by Visual Studio Command Prompt as provided by the SDK (VS 2010 Express plus SDK 7.1) PLATFORM is an environment variable that may be set in the VS 2013 Express x64 cross development environment

which means, that if it was not done by the vcvars (in my case it wasn't) you need to set TARGET_CPU or PLATFORM (just in case I set them both):

set TARGET_CPU=x64 set PLATFORM=x64

3) and now the final step:

nmake clean VC nmake clean VC-debug

this will make a 64bit DLL files (and proper import library and PDB). I can verify that it works with Visual Studio 2012.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top