Include linux library in C++ code

Discussion in 'Mac Programming' started by titaniumdecoy, Jan 16, 2008.

  1. titaniumdecoy macrumors member

    Joined:
    Oct 13, 2005
    #1
    I have a library that was built for linux which I want to include in a simple C++ program on my mac. However, I get this error:

    Code:
    ld: warning in <snip>/libsim.a, file is not of required architecture
    Undefined symbols:
      <snip>
    
    Is there some way to get this to work under X11 or similar? I know it works on Fedora Core 5. Thanks.
     
  2. kpua macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    No. The ABIs are different between OSX and Linux. The library needs to be compiled for OSX.
     
  3. numero macrumors regular

    Joined:
    Jul 23, 2002
    Location:
    OR
    #3
    What you have here is a collection of code compiled into a single file for the purposes of other programs being able to call functions from it. The code you have has been compiled for (probably) Intel Linux. It will not work as is for Intel OS X. You will need the original .c files and compile your own (or find it precompiled somewhere).
     
  4. titaniumdecoy thread starter macrumors member

    Joined:
    Oct 13, 2005
    #4
    Damn.

    I know it runs on Fedora Core 5. Does that mean it would run on any linux machine such as Ubuntu or Fedora 7?
     
  5. kpua macrumors 6502

    Joined:
    Jul 25, 2006
    #5
    Given that each Linux distribution is based on essentially the same kernel, one could presume yes.
     
  6. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #6
    I'd check to see if it's available in source or binary form for OSX via MacPorts or Fink.

    If not, you could always install RPM via MacPorts or Fink and get the SIM ICQ (i.e. libsim) RPM source bundle and install it that way.
     
  7. titaniumdecoy thread starter macrumors member

    Joined:
    Oct 13, 2005
    #7
    I found out (to my surprise) that the source was available. I compiled it and packaged it into a static library and it is now working fine, although it launches under X11.
     

Share This Page