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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to