Marco S Hyman, Stephen J. Butler,

thanks a lot! Indeed, stupid me, I was missing "-L.". I used to use it (as
I copy-pasted above) but somehow when hitting up arrow in terminal I must
have accidentally deleted it. Now it links! So to recap, properly naming
the library ("libpython33.so") and compiling with:

    gcc embed.c -I./include -L. -lpython33

works! Thank you so much people!

The problem is, as Stephen points out, the executable doesn't run:

    Reason: image not found
    Trace/BPT trap: 5

I will read the links about frameworks now...


On Sun, Feb 24, 2013 at 10:20 PM, Stephen J. Butler <
stephen.but...@gmail.com> wrote:

> This is an advanced topic which touches on a lot of OS X details. The
> short of it is, even if you solve your linking problems your Python 3.3
> library won't work.
>
> What you need to is include the entire Python 3.3 framework in your
> Application bundle. Once you've figured out how to do that, linking against
> it is as simple as telling Xcode to link the framework. Here are two links
> some Googling brought up:
>
> Here's the official docs:
>
>
> https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html
>
> Look under "Embedding a Private Framework in Your Application Bundle" and
> start following links. This StackOverflow question touches on the subject:
>
>
> http://stackoverflow.com/questions/1621451/bundle-framework-with-application-in-xcode
>
>
>
> On Sun, Feb 24, 2013 at 2:09 PM, ecir hana <ecir.h...@gmail.com> 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 (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/stephen.butler%40gmail.com
>>
>> This email sent to stephen.but...@gmail.com
>>
>
>
_______________________________________________

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