Export Processing Sketch for Mac on Windows

edited July 2014 in Using Processing

I have just completed a Processing sketch that I would like to share online for users of Windows, Linux, and Mac. The Windows and Linux builds were a piece of cake, but the Mac export does not work on Windows because of the nature of the operating system. Even though I cannot export my sketch for Mac using the traditional methods that Processing offers, could I perhaps do it some other way? I have the libraries that are specific to Mac accessible to me. Now all I need to do is combine them in such a way that the sketch will run. Does anyone have any suggestions for how to go about doing something like this?

Tagged:

Answers

  • I assume that you are using a contributed library - if so which one(s)?

    If you are using OS specific binaries then the following code will detect which OS the sketch is running on

    String platformName;
    
    final byte MACOSX = 0;
    final byte WINDOWS = 1;
    final byte LINUX = 2;
    final byte OTHER = 3;
    byte os;
    
    void setup() {
      os = getOS();
      printOS(os);
    }
    
    byte getOS() {
      String platformName = System.getProperty("os.name");
      platformName = platformName.toLowerCase();
      if (platformName.indexOf("mac") != -1) {
        return MACOSX;
      } else if (platformName.indexOf("windows") != -1) {
        return WINDOWS;
      } else if (platformName.indexOf("linux") != -1) { // true for the ibm vm
        return LINUX;
      } else {
        return OTHER;
      }
    }
    
    void printOS(byte os) {
      switch(os) {
      case MACOSX:
        println("Mac OSX");
        break;
      case WINDOWS:
        println("MS Windows");
        break;
      case LINUX:
        println("Linux");
        break;
      default:
        println("Unrecognised OS");
      }
    }  
    

    then you could use

    System.loadLibrary("library name");

    to load the correct library.

    BTW their maybe a Processing method to report the OS but I couldn't find it.

  • println( javaVersionName );
    println( System.getProperty("java.home")  + "\n" );
    
    println( System.getProperty("os.arch") );
    println( System.getProperty("os.name") );
    println( System.getProperty("os.version") + "\n" );
    
    println( System.getProperty("user.home") );
    println( System.getProperty("user.dir")   + "\n" );
    
    println( sketchPath );
    println( dataPath("") );
    
    exit();
    
  • Answer ✓

    You could use SvgExe to package up the natives you need. It's available right from the Processing IDE, in the "tools" menu.

    (Disclaimer: I am the creator of SvgExe.)

Sign In or Register to comment.