Results 1 to 7 of 7

Thread: On Mac: "...file was built for unsupported file format.." - SOLVED

  1. #1
    Join Date
    Apr 2010
    Location
    Portland, OR
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default On Mac: "...file was built for unsupported file format.." - SOLVED

    I'm trying to build a Qt application on Mac that statically links third-party libraries (i.e. boost, libjpeg).

    I'm getting this linker warning for each library:

    ...
    ld: warning: in ../../extern/libexif-0.6.19/libexif/.libs/libexif.a, file was built for unsupported file format which is not the architecture being linked (i386)
    Undefined symbols:
    "_exif_get_long", referenced from:
    ExifTagParser:arseEntry(_ExifEntry*, ExifByteOrder) in sbexifinfo.o
    ...


    So even though it's only a warning the linker refuses to use the library and ends up with undefined symbols.

    I've downloaded and compiled the libraries with the default configuration on my Macbook Pro running Snow Leopard. Here are the relevant bits from my .pro file:


    ...
    TEMPLATE = app
    CONFIG += x86 debug_and_release qt warn_on thread
    QT += network xml
    LIBS += ../../extern/libexif-0.6.19/libexif/.libs/libexif.a
    ...

    This happens with all static libraries I try to link. Anybody have an idea how to fix that?

    Thanks much!

    Holger
    Last edited by desertpilot; 13th May 2010 at 06:36.

  2. #2
    Join Date
    May 2010
    Posts
    14
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: On Mac: "...file was built for unsupported file format which is not the architect

    The library you're liking to is not of the same architecture as the library your linking (./../extern/libexif-0.6.19/libexif/.libs/libexif.a).

    libexif.a is an i386 arch. Check your build settings to ensure that you're building an i386 binary or recompile the libexif.a to match your build target arch.

    fyi, If you're using Xcode, then by default Debug mode only builds your platforms native arch. So on a new mac, this would be an x86_64 binary.

  3. #3
    Join Date
    Apr 2010
    Location
    Portland, OR
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: On Mac: "...file was built for unsupported file format which is not the architect

    Quote Originally Posted by jkyle View Post
    The library you're liking to is not of the same architecture as the library your linking (./../extern/libexif-0.6.19/libexif/.libs/libexif.a).

    libexif.a is an i386 arch. Check your build settings to ensure that you're building an i386 binary or recompile the libexif.a to match your build target arch.

    fyi, If you're using Xcode, then by default Debug mode only builds your platforms native arch. So on a new mac, this would be an x86_64 binary.
    Thanks for your help, jkyle! Turns out the libraries by default aren't i386 configured. Probably some multi-architecture mode that the linker doesn't recognize as i386 compatible. I don't see why, frankly. Anyway, I rebuilt the libraries with ./configure CC="gcc -arch i386" CXX="g++ -arch i386" and now the linker is happy. BTW, I'm using Qt Creator and it's building by default only x86. I tried x86_64 but the open source Qt 4.6 build isn't built with 64bit support. Don't need it anyway.

  4. #4

    Default Re: On Mac: "...file was built for unsupported file format.." - SOLVED

    How do you rebuild the libraries? I have the same problem but can't get it to work.

  5. #5
    Join Date
    Jan 2009
    Location
    Portland, Oregon
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: On Mac: "...file was built for unsupported file format.." - SOLVED

    Quote Originally Posted by skizzik View Post
    How do you rebuild the libraries? I have the same problem but can't get it to work.
    That depends on which library. Each one had its own particular way it wanted to be configured for i386. I had to go through each documentation and follow the instructions. Most were happy with ./configure CC="gcc -arch i386" CXX="g++ -arch i386", but not all. Which library is giving you trouble?

  6. #6

    Default Re: On Mac: "...file was built for unsupported file format.." - SOLVED

    libboost_thread-mt.dylib
    libboost_filesystem-mt.dylib
    libboost_program_options-mt.dylib
    libboost_system-mt.dylib

    file libboost_thread-mt.dylib
    gives:
    libboost_thread-mt.dylib: Mach-O 64-bit dynamically linked shared library x86_64
    Last edited by skizzik; 14th October 2010 at 13:10.

  7. #7
    Join Date
    Jun 2012
    Posts
    5
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: On Mac: "...file was built for unsupported file format.." - SOLVED

    I am having the same problem. Can someone tell me what to do with the line below? Where do I put it?

    ./configure CC="gcc -arch i386" CXX="g++ -arch i386"

Similar Threads

  1. Replies: 3
    Last Post: 15th February 2010, 18:27
  2. Replies: 3
    Last Post: 28th March 2009, 16:37
  3. "Cannot run program "C:\Qt\4.3.3\bin\qmake": file not found
    By PeteH in forum Installation and Deployment
    Replies: 1
    Last Post: 7th February 2009, 01:48
  4. Replies: 3
    Last Post: 8th July 2008, 20:37
  5. "Treat wchar_t as Built-in Type" to "yes" link error
    By sungaoyong in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2008, 12:45

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.