link problem about X86_64,x86, i386

Discussion in 'Mac Programming' started by ccjimmy, Mar 23, 2011.

  1. ccjimmy macrumors newbie

    Mar 15, 2011
    i'm working with FFMPEG on MAC OSX, my MAC version is 10.6.5
    when I try compile ffmpeg, I used three kind of parameters like belows:

    ./configure --prefix=/Developer/usr --arch=i386 --disable-shared --enable-static --enable-gpl --enable-swscale --enable-zlib --enable-bzlib --enable-ffmpeg --disable-ffplay --disable-ffserver --disable-libfaac --disable-yasm --enable-postproc --enable-avfilter --disable-network --disable-shared --enable-nonfree --enable-libx264(--arch was i386

    ./configure --prefix=/Developer/usr --arch=x86 --disable-shared --enable-static --enable-gpl --enable-swscale --enable-zlib --enable-bzlib --enable-ffmpeg --disable-ffplay --disable-ffserver --disable-libfaac --disable-yasm --enable-postproc --enable-avfilter --disable-network --disable-shared --enable-nonfree --enable-libx264(--arch was X86

    ./configure --prefix=/Developer/usr --disable-shared --enable-static --enable-gpl --enable-swscale --enable-zlib --enable-bzlib --enable-ffmpeg --disable-ffplay --disable-ffserver --disable-libfaac --disable-yasm --enable-postproc --enable-avfilter --disable-network --disable-shared --enable-nonfree --enable-libx264(use default --arch

    after that, make, make install. but when I use XCODE to link the libavcodec.a library, it always says:

    ld: warning: in /Developer/usr/lib/libavcodec.a, file was built for unsupported file format which is not the architecture being linked (i386)
    Undefined symbols:

    whatever the the configuration is as i've mentioned , it leads to link error:

    "_avcodec_open", referenced from:
    MoviePlayer2::Init() in MoviePlayerTest.o

    how can I do that?
  2. kainjow Moderator emeritus


    Jun 15, 2000
    arch should be i386 or x86_64. If you leave it out it'll do whatever is your system's.

    When you keep running make/make install it's going to overwrite the previous library.

    Getting configure/make to build for multiple architectures without using Xcode can be a pain. It might be easier to build it for one arch, move the file, then build it for another and use lipo to combine them.
  3. ccjimmy thread starter macrumors newbie

    Mar 15, 2011
    Really thanks for reply.
    i used thought when I use "./configure", the system just make some preparation for the next "make " command, just like write a bat-like files to tell the "make" how to compile the file, maybe I'm wrong...

    my project is a windows project, and i have already make it executable on MAC OS use XCODE, i just want to play my video on MAC using FFMEPG, so maybe for me, it is easier to use XCODE and link .a file use make-make install than make-make install all of them one by one...

    how could I do???
  4. monsieurpaul macrumors regular

    Oct 8, 2009
    Not sure if it will be of any help but I had some trouble with compiling library for working with Xcode that I manage to resolve. Look this thread.
    You can use the command "file" to check the architectures for which your sources have been compiled.
  5. ccjimmy thread starter macrumors newbie

    Mar 15, 2011
    thanks for reply

    in ur artical, was "cc=gcc" is for ".c" file and "cxx = g++" for ".cpp" file?
    in ffmpeg there is nothing with cpp files, there are .c .h .s(looks like asm) files.

    and my problem is: I just want to link with i386, X86_64 and ppc is not needed..... anyway,thanks very much...

    SOS SOS~~~~~~~~~:(
  6. monsieurpaul macrumors regular

    Oct 8, 2009
    Have you check this page about how to build FFmpeg on Mac OS X ?

    In fact, I am not sure to understand your problem:

    - do you have a problem for building FFmpeg on your system (I presume an Intel 32 bit) ? -> If not, for which architecture your libavcodec.dylib is built ?(check this with the file command in terminal)

    - do you have a problem linking this library in Xcode ? -> check which architectures are in your build settings
  7. ccjimmy thread starter macrumors newbie

    Mar 15, 2011

    yes, I read it carefully....

    my problem is I don't know how to make it work together with ffmpeg and xcode in i386 mode....

    right now, i can link compiled ffmpeg( configure,make, make install) library with xcode in X86_64 mode, but I do not know how to make it work on i386 mode...
  8. ccjimmy, Mar 28, 2011
    Last edited by a moderator: Mar 28, 2011

    ccjimmy thread starter macrumors newbie

    Mar 15, 2011


    in additional, my MAC:

    Mac OS X 10.6.5 (10H574)
    Kernel Version: Darwin 10.5.0
    CPU: 1.83Ghz Intel Core Duo,
    64-bit Kernel and Extensions: No

    Model Name: Mac mini
    Model Identifier: Macmini2,1
    Processor Name: Intel Core 2 Duo
    Processor Speed: 1.83 GHz
    L2 Cache: 2 MB
    Memory: 1 GB
    Bus Speed: 667 MHz
  9. monsieurpaul macrumors regular

    Oct 8, 2009
    Go in the terminal and type this:
    file /Developer/usr/lib/libavcodec.a
    What is the answer ? My guess is that is something like that:
    /Developer/usr/lib/libavcodec.a (for architecture x86_64):	current ar archive random library
    meaning your library is compiled only for x86_64.
    If you want to compile it for both i386 and x86_64 you have (at least) 2 choices:
    - Do as Kainjow said: compile for 1 architecture, move the files elsewhere, compile for the other architecture, then merge the files using the lipo command
    - Compile for both by modifying configure arguments:
    $ ./configure CC="gcc -arch i386 -arch x86_64" CXX="g++ -arch i386 -arch x86_64" CPP="gcc -E" CXXCPP="g++ -E"
    $ make
    $ sudo make install
    You'll have to modify the configure command if you want to install them in /developer/usr/lib. Why do you want to install the lib here and not in /usr/local/lib by the way ?

Share This Page