Seite 1 von 1

c modul unter os x compilieren

Verfasst: Donnerstag 10. April 2008, 12:02
von hiasl
Hallo,

ich versuche unter Mac OS X ein in C geschriebenes Modul mit gcc zu kompilieren und suche dazu das Pendant zu "python25.lib".

Kann mir jemand einen Tipp geben?

Ciao
Matthias

Verfasst: Donnerstag 10. April 2008, 19:18
von mitsuhiko
gcc installieren? Ohne Fehlermeldung kann ich nur raten was du willst.

Verfasst: Donnerstag 10. April 2008, 20:07
von ne0h
gcc installieren?

gcc ist unter OS X standardmäßig vorinstalliert.



ne0h

Verfasst: Freitag 11. April 2008, 07:48
von hiasl
Im Grunde brauche ich für foo.c (inkludiert Python.h) den passenden gcc Aufruf, der mir die richtige Python-Bibliothek mit dazu linkt.

Verfasst: Freitag 11. April 2008, 10:56
von Leonidas
Wo ist das Problem, die distutils zu nutzen? Dann ist es dir relativ egal welcher Compiler da verwendet wird.

Verfasst: Freitag 11. April 2008, 14:20
von windner
Ich würde auch dringed zu distutils raten, hat bei mir neulich auch auf einem Apple problemlos hingehaut. Wenn du wirklich zu Fuss compilen willst, schau halt einmal im distutils-Quellcode nach, vielleicht findest du dort etwaige Eigenheiten für OS X.

Verfasst: Freitag 11. April 2008, 15:27
von windner
schau halt einmal im distutils-Quellcode nach, vielleicht findest du dort etwaige Eigenheiten für OS X.
Hab kurz drübergeschaut, dabei ist mir folgendes aufgefallen, allerdings hab ich hier nur Python 2.4, meine Information könnte also leicht angestaubt sein.

1.) Auf OSX gibt es eine Variable MACOSX_DEPLOYMENT_TARGET, die für's Übersetzen wichtig scheint:

Code: Alles auswählen

# (sysconfig.py)

    # On MacOSX we need to check the setting of the environment variable
    # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so
    # it needs to be compatible.
2.) Der OSX-Linker verwendet unübliche Parameter-Namen für Pfadangaben:

Code: Alles auswählen

# (unixcompiler.py)

        # XXX Hackish, at the very least.  See Python bug #445902:
        # http://sourceforge.net/tracker/index.php
        #   ?func=detail&aid=445902&group_id=5470&atid=105470
        # Linkers on different platforms need different options to
        # specify that directories need to be added to the list of
        # directories searched for dependencies when a dynamic library
        # is sought.  GCC has to be told to pass the -R option through
        # to the linker, whereas other compilers just know this.
        # Other compilers may need something slightly different.  At
        # this time, there's no way to determine this information from
        # the configuration data stored in the Python installation, so
        # we use this hack.
        compiler = os.path.basename(sysconfig.get_config_var("CC"))
        if sys.platform[:6] == "darwin":
            # MacOSX's linker doesn't understand the -R flag at all
            return "-L" + dir
Vielleicht kommst du ja von hier aus weiter.

Verfasst: Montag 14. April 2008, 08:45
von mitsuhiko
ne0h hat geschrieben:gcc ist unter OS X standardmäßig vorinstalliert.
Dafür liegen dir genug andere Felsen im Weg. Bundles :-/