porting linux Qt apps to OS X (for a n00b)

Discussion in 'Mac Programming' started by wmmk, Dec 31, 2006.

  1. macrumors 68020

    wmmk

    Joined:
    Mar 28, 2006
    Location:
    The Library.
    #1
    hello devs!
    just saw that LightCrafts LightZone was upgraded to 2.0 recently, but the price is now $249, which is rather steep. I also found that they give away a Linux binary away for free. Just for fun I downloaded that and tried to run it in X11. Of course, it didn't work. Anyway, considering that OS X is UNIX- based, I'd expect that there's some way to get this to work. What can I do?
    Thanks,
    wmmk
     
  2. macrumors 6502a

    Super Macho Man

    Joined:
    Jul 24, 2006
    Location:
    Hollywood, CA
    #2
    I know that FreeBSD for x86 includes an optional Linux binary compatibility package. Mac OS X is based on FreeBSD but uses a different kernel. So maybe there is a similar solution for OS X (probably not). Of course you would need to have an Intel processor even if it were possible.

    Otherwise you would probably have to use something like Virtual PC (PowerPC Macs) or Parallels/Boot Camp (Intel Macs) and install Linux in a VM.
     
  3. macrumors 68020

    Joined:
    Dec 9, 2004
    #3
    Nothing. OS X isn't Linux and Linux binaries won't work. If you had the source code you could try porting it though.

    --Eric
     
  4. macrumors 604

    GFLPraxis

    Joined:
    Mar 17, 2004
    #4
    You could install Linux into Parallels...
     
  5. Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #5
    See if you can get it using Fink...
     
  6. macrumors 68000

    speakerwizard

    Joined:
    Aug 8, 2006
    Location:
    London
    #6
    couldnt installin x11 help? i think this is out of my league so ill shut up now lol
     
  7. Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #7
    Probably the most expedient solution... I think with systems like Fink, it's not that complex to re-engineer source code to run in Fink on OS X, but this is closed-source app.

    BTW, does anyone use this app? I've never heard of it on photography websites before.
     
  8. macrumors 68030

    risc

    Joined:
    Jul 23, 2004
    Location:
    Melbourne, Australia
    #8
    No; the only way having X11 installed would help is if the app was open source and the OP had the time to compile it (and all it's deps) for OS X. Since this app is closed source though there is no way it will work.
     
  9. Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #9
    Yes, absolutely. X11 is only a small subset of the APIs that the Linux binary needs access to, in order to run.

    I was curious about the linux compatibility layer in BSD so I did some reading about it... can anyone help me understand what I read? :eek:

    1) From what I understand, the linux compatibility layer is a relatively late addition to the FreeBSD kernel, and acts primarily at the kernel level.

    2) OS X uses Mach, which is a somewhat older branching of FreeBSD, at least in the sense that NeXT was working with Mach before Linux really became so prominent as it is now.

    3) So this means that Mach didn't inherit the compatibility layer, and as the kernel is owned by Apple, the fact that the compatibility layer has been developed by the FreeBSD people is pretty much useless towards the goal of an OS X / Linux compatibility layer, because only Apple can implement it by implementing it in their kernel.

    Is that basically correct?

    Don't get me wrong... in this proximal issue, this is nonsense to me. This application is readily available for OS X. If you want it, pay for it. But I'm curious about the general issue.
     
  10. macrumors 601

    Compile 'em all

    Joined:
    Apr 6, 2005
    #10
    Second the Fink advice. If you ever used Debian and apt-get, you will feel at home with fink. You can check as well Darwin ports.
     
  11. macrumors 68030

    risc

    Joined:
    Jul 23, 2004
    Location:
    Melbourne, Australia
    #11
  12. macrumors 601

    Compile 'em all

    Joined:
    Apr 6, 2005
    #12
    Just a minor correction.

    Apple doesn't own the Mach kernel. OS X is based on the XNU kernel which is a hybrid kernel (as opposed to being monolithic or micro kernel). XNU is made up of the Mach kernel and FreeBSD components.

    EDIT: risc beat me to it.
     
  13. macrumors 68030

    risc

    Joined:
    Jul 23, 2004
    Location:
    Melbourne, Australia
    #13
    Closed source apps are not going to be part of Fink or MacPorts. The FreeBSD Linux compatibility is kernel based so you will not find that at either location either.
     
  14. Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #14
    Sorry, I meant own in a project management sense, not in an intellectual property sense. :eek: What I meant is that only Apple can implement a change on the kernel. Which means that the fact that the compatibility layer exists for a relatively close sibling of the OS X kernel doesn't mean that a third-party could just go and implement Linux compatibility in OS X easily.

    But also thank you for clarifying about the hybridity. I keep saying Mach, but I do recognize that what Apple uses is not the current official Mach branch.
     
  15. macrumors 68000

    GeeYouEye

    Joined:
    Dec 9, 2001
    Location:
    State of Denial
    #15
    Well, there's TECHNICALLY nothing stopping you from writing an ELF loader... but one does not exist at present.

    Alternately, you could try downloading it (and binaries of all its dependencies), and running it in OpenFirmware, which DOES have an ELF loader.

    Unfortunately, neither are very practical solutions.
     
  16. thread starter macrumors 68020

    wmmk

    Joined:
    Mar 28, 2006
    Location:
    The Library.
    #16
    no big deal. there is another app which I do have the source for, but I'm a n00b who has no idea about porting stuff. how would I go about this? thanks!:)
     
  17. macrumors 6502

    Joined:
    May 12, 2003
    #17
    Try to compile the source. Look at the errors. Fix them.
     
  18. thread starter macrumors 68020

    wmmk

    Joined:
    Mar 28, 2006
    Location:
    The Library.
    #18
    if it was obj-c, I could at least give this a shot, but it's Qt4. I tried configuring QT mac, but some directories were messed up or something. anyway, how would I go about correcting these errors. would this be obvious?
     
  19. macrumors G4

    Joined:
    Jul 17, 2002
    Location:
    USA
    #19
    Qt is a C++ cross-platform framework. Objective-C is an object-oriented version of the C programming language.

    If you need help, it might be useful to explain which OS, which version of Qt, and which development environment you are using.
     
  20. thread starter macrumors 68020

    wmmk

    Joined:
    Mar 28, 2006
    Location:
    The Library.
    #20
    what i meant by the obj-c thing was that maybe then I could get this working in xcode, which I've used a bit. I'm not a programmer, just a photographer who wants to use a linux HDR creation app, and all of this is a bit over my head.:eek: To answer your question I'm using OS X 10.4.8, trying to use Qt4, and I don't even know what development environment I'm trying to use.

    If it helps, the developer of the app sent me this a while ago
    I know it seems cut and dry, but I just couldn't get Qt to configure properly...
     
  21. macrumors G4

    Joined:
    Jul 17, 2002
    Location:
    USA
    #21
    Instead of worrying about trying to compile an app, you should concern yourself with finding a MacOS X app which does what you need done. If you install the Qt4 frameworks on your Mac, any Qt4-dependent app which you install should just work. Again, which Linux HDR creation app and is there a Mac version of it already?
     
  22. thread starter macrumors 68020

    wmmk

    Joined:
    Mar 28, 2006
    Location:
    The Library.
    #22
    the app is qtpfsgui (I linked to it earlier in this thread), no, there is not a mac version of it, and there is no open source Mac app that does the same thing. I know that there are free HDR mac apps, but they use tone mapping engines that I don't really like the output of, whereas qtpfsgui uses many operators, including the fattal contrast enhancing engine, which I really like. Anyway, this app is only available as platform independent source and Windows exe, so I'll have to compile.
     
  23. thread starter macrumors 68020

    wmmk

    Joined:
    Mar 28, 2006
    Location:
    The Library.
    #23
    does anyone have any tips for this? sorry to bump, but this is really important for me:eek:
    thanks/sorry...
     
  24. macrumors member

    Joined:
    May 14, 2004
    #24
    If it helps, I tried this and QT4 installed fine for me following the instructions in their README file. Basically I did this:

    1. Unzip and untar to desktop
    2. CD into resulting directory
    3. ./configure -universal
    4. make
    5. sudo make install
    6. Add:

    PATH=/usr/local/Trolltech/Qt-4.2.2/bin:$PATH
    export PATH

    to ~/.profile

    I then compiled and installed exiv2 according to the instructions in their README - unzip, untar, cd to resulting directory and:

    1. ./configure --without-zlib (because there was some other dependency I didn't want to fool with just to see if I could get this compiled.)
    2. make
    3. sudo make install

    All of that appeared to go well.

    Now when I went to compile qtpfsgui I got past the qmake stage OK (after changing the location of exiv2 to match the OSX path in the project.pro file as the instructions required).

    At that point I went to make qtpfsgui and I get this:

    src/hdrcreate/createhdr.cpp:15: error: 'open_memstream' was not declared in this scope
    make: *** [generated_obj/createhdr.o] Error 1

    At that point the code looks like:

    Code:
    #ifdef _WIN32
    void       createHDR(QList<QImage*> &list, const float * arrayofexptime, config_triple* chosen_config, bool antighosting, int iterations, const char * outfname) {
        FILE *fpout=fopen(outfname,"wb");
    #else
    QByteArray createHDR(QList<QImage*> &list, const float * arrayofexptime, config_triple* chosen_config, bool antighosting, int iterations){
        //prepare "fake" FILE* where pfs library will write the output hdr to, in pfs stream format.
        char *pfshdr;
        size_t size;
        FILE * fpout=open_memstream(&pfshdr, &size);
    #endif
    
    So we're getting into the unix-specific code correctly and it's failing there. I'm not sure why - maybe open_memstream has some trick to it on OSX. Hopefully this is enough of a clue for someone else to spot what's going on.

    Anyway, I didn't get the whole thing working but I can say that QT4 appears to install fine for me on an Intel Mac (for anyone else who wants to try this, be forewarned that building it takes a good long time) so with any luck you'll be able to get over that hurdle. It was necessary to read the documentation to catch that I had to specify the flag for a universal build and that I needed to add QT to my path so if you didn't do that, that may have been your QT problem.
     
  25. thread starter macrumors 68020

    wmmk

    Joined:
    Mar 28, 2006
    Location:
    The Library.
    #25
    wow! thank you so(!) much!
    this will be immensely helpful!
    I'll get as far as I can with this, then MSN with the dev (he's in Italy) on saturday afternoon. hopefully, there will be a universal OS X build of qtpfsgui by Sunday morning. maybe I'll even photoshop some new buttons to make it mire mac-like!:D
     

Share This Page