• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dynamic library linking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic library linking


  • Subject: Re: Dynamic library linking
  • From: Boyd Collier <email@hidden>
  • Date: Sun, 24 Feb 2013 16:32:51 -0800

I'm just getting started with python, so I'm certainly not qualified to comment on this specific problem.  However, perhaps the following page may be useful to others getting started with python:

http://wolfpaulus.com/journal/mac/installing_python_osx

The site gives detailed instructions on installing what was, when written, the latest version of python (2.7, I believe), which didn't work for me until I redid everything, following the steps given including those given by Simon in a comment.

Boyd



On Feb 24, 2013, at 12:09 PM, ecir hana wrote:

> Hello,
>
> I have a simple program which I can compile but when I tried to link it
> with a dynamic library the linker is not able to find the library, despite
> that it is in the same folder as the program.
>
> The longer version: I want to embed Python 3.3 interpreter into simple C
> program. I'm on MacOS 10.8, which ships with Python 2.7. I downloaded the
> binary distribution of 3.3 version from python.org, copied the dynamic
> library from the bundle to a folder, along with all the headers. The
> library I copied was a file named "Python" which had a symlink pointing to
> it named "libpython3.3m.dylib". Now that the library is in the folder,  I
> renamed it to "python33" so it wouldn't collide with installed "Python" of
> version 2.7.
>
> So the folder has these files: "embed.c", "python33" and "include" folder.
> The "embed.c" containts:
>
>    #include <Python.h>
>
>    int
>    main(int argc, char *argv[])
>    {
>      Py_Initialize();
>      PyRun_SimpleString("print 'test'\n");
>      Py_Finalize();
>      return 0;
>    }
>
> and running "file python33" says:
>
>    python33 (for architecture i386): Mach-O dynamically linked shared
> library i386
>    python33 (for architecture x86_64): Mach-O 64-bit dynamically linked
> shared library x86_64
>
> The problem I have is that when try to run:
>
>    "gcc embed.c -I./include -L. -lpython33"
>
> if breaks with:
>
>    ld: library not found for -lpython33
>
> Please, does anyone know why?
>
> I guess this is not exactly Cocoa-related question but I tried to ask about
> this at various places and I have not found a solution, yet.
>
> I have various theories about why this happens, I would be thankful if
> someone could confirm/reject these:
>
> - I cannot just copy out a dynamic library out of a bundle, I have to
> install the whole Python 3.3 and after it is properly installed at
> particular locations, then I can link with it.
>
> - I'm missing some linker flags. I tried "DYLD_LIBRARY_PATH="."" but it
> didn't help.
>
> - The Python 3.3 library was compiled with different compiler that what I
> use to compile my program with.
>
> PS: it compiles with:
>
>    "gcc embed.c -I./include python33"
>
> but when I tun "./a.out" it breaks with:
>
>    dyld: Library not loaded:
> /Library/Frameworks/Python.framework/Versions/3.3/Python
>    Referenced from: /Users/ecir/Desktop/embed/./a.out
>    Reason: image not found
>    Trace/BPT trap: 5
>
> I would really appreciate any hint on how to solve this, thank you in
> advace!
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Dynamic library linking (From: ecir hana <email@hidden>)

  • Prev by Date: Re: NSButton in NSToolbarItem does not use "small size"
  • Next by Date: Re: NSButton in NSToolbarItem does not use "small size"
  • Previous by thread: Re: Dynamic library linking
  • Next by thread: NSButton in NSToolbarItem does not use "small size"
  • Index(es):
    • Date
    • Thread