danomatika / ofxPd

(maintained) a Pure Data addon for OpenFrameworks using libpd
Other
202 stars 45 forks source link

Cannot open include file: 'pthread': No such file or directory #73

Closed cuinjune closed 3 years ago

cuinjune commented 5 years ago

I tried building ofxPd using Visual Studio 2017 on Windows 10 but it fails with the following error:

Cannot open include file: 'pthread': No such file or directory

Screen Shot 2019-06-18 at 5 03 40 PM

I followed every instructions in your README but I could not build it. (I tried on 32bit and 64bit) I could successfully build ofxPd last year using OF 0.9.8 but not this time with OF 0.10.1 on Windows.

I tried using both pd 0.48.2 and 0.49.0 (I tried building libpd based on each sources) I also put libwinpthread-1.dll inside project's bin folder but I don't know why pd's source files cannot include "pthread.h".

Do you have any idea how to fix this? Any advice would be appreciated!

danomatika commented 5 years ago

Did OF stop including pthread with its sources for windows? In any case, you need to find where the header is and include a path to its folder in the header search paths.

If you don’t know what that means, read up on how to include libraries in C/C++ and Visual Studio.

enohp ym morf tnes

Dan Wilcox danomatika.com robotcowboy.com

On Jun 18, 2019, at 10:15 AM, Zack Lee notifications@github.com wrote:

I tried building ofxPd using Visual Studio 2017 on Windows 10 but it fails with the following error:

Cannot open include file: 'pthread': No such file or directory

I followed every instructions in your README but I could not build it. (I tried on 32bit and 64bit) I could build it successfully last year using OF 0.9.8 but not this time.

I tried using both pd 0.48.2 and 0.49.0 (I tried building libpd based on each sources) I also put libwinpthread-1.dll inside project's bin folder but I don't know why pd's source files cannot include "pthread.h".

Do you have any idea how to fix this? Any advice would be appreciated!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

cuinjune commented 5 years ago

I figured out how to build ofxPd using Visual Studio 2017 on Windows 10. I tested the following using pd-0.49.0.

  1. Download pthreadVC2.lib and pthreadVC2.dll from https://sourceware.org/pub/pthreads-win32/dll-latest/ (x64 and x86 respectively)
  2. Download and build libpd by following these steps https://github.com/danomatika/ofxPd#using-ofxpd-with-visual-studio and generate libpd.lib and pd.dll. (x64 and x86 respectively)
  3. Put libpd.lib and pthreadVC2.lib inside your custom directories such as ofxPd\libs\libpd\lib\Win32 and ofxPd\libs\libpd\lib\Win64.
  4. Put pd.dll, pthreadVC2.dll and libwinpthread-1.dll(find this from libpd\libs folder) inside yourProject\bin folder.
  5. In your Visual Studio project, go to Debug -> Properties -> Linker -> Input section and add the custom paths like the following in Additional Dependencies:
    ..\..\..\addons\ofxPd\libs\libpd\lib\(Win32 or Win64)\libpd.lib
    ..\..\..\addons\ofxPd\libs\libpd\lib\(Win32 or Win64)\pthreadVC2.lib
  6. Go to Debug -> Properties -> C/C++ -> Preprocessor section and add the followings in Preprocessor defines
    PD
    PD_INTERNAL
    HAVE_STRUCT_TIMESPEC
  7. Make sure Debug -> Properties -> C/C++ -> Advanced -> Compile As is set to Default.
  8. Go to Project -> Manage Nuget Packages, In browse Tab search for pthread then select Install[Search Results in Nuget packages].
  9. Open x_vexp_fun.c from ofxPd\libs\libpd\pure-data\src and find the following code in line 540.
    #ifdef _MSC_VER
    /* rint is now advertised as part of the microsoft SDK but my MSVC still
    doesn't find it - so here it is again. */
    static double rint(double x)
    {
        return (floor(x + 0.5));
    }
    #endif

    Change the code to the following:

    #ifdef _WIN32
    #if _MSC_VER < 1900
    /* rint is now advertised as part of the microsoft SDK but my MSVC still
    doesn't find it - so here it is again. */
    static double rint(double x)
    {
        return (floor(x + 0.5));
    }
    #endif
    #endif
  10. Open pd~.c from ofxPd\libs\libpd\pure-data\extra\pd~ and find the following code in line 29.
    #ifdef _MSC_VER
    #pragma warning (disable: 4305 4244)
    #define snprintf sprintf_s
    #define stat _stat
    #endif

    Change the code to the following:

    #ifdef _WIN32
    #if _MSC_VER < 1900
    #pragma warning (disable: 4305 4244)
    #define snprintf sprintf_s
    #define stat _stat
    #endif
    #endif
  11. Now, build and run the project, everything should work fine.
danomatika commented 3 years ago

This should be smoother as newer versions of the Pd source build much better within Visual Studio and info has been added about how to do this for ofxPd: https://github.com/danomatika/ofxPd#adding-libpd-to-a-visual-studio-project