Results 1 to 8 of 8

Thread: cross compiling with static libraries

  1. #1
    Join Date
    Mar 2008
    Posts
    44
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default cross compiling with static libraries

    Hello

    I have an application developed under Linux. It is running under W7 (mingw/Qt), but in order to distribute it to some
    interested parties I want to make a distribution with (most of the) libs statically linked.
    In order to do so, I installed under fedora-17 the mingw64 cross compilation set, including the static libs for Qt.
    When building a non-statically bound version, it compiles completely to an executable.
    When adding the QMAKE_LFLAGS += -static to the ".pro" file, compilation starts complaining about
    some references from the libs not being resolved. Most likely they are windows references, but I have no clue
    what libs to add.
    This is the result of the link phase

    x86_64-w64-mingw32-g++ -static -Wl,-s -Wl,-subsystem,console -mthreads -o release/spectrum-viewer.exe object_script.spectrum-viewer.Release -L'/usr/x86_64-w64-mingw32/sys-root/mingw/lib' /home/jan/cross-compiling/dll_64/libfftw3-3.lib /home/jan/cross-compiling/qwt-5.2.2/lib/libqwt.a -L c:\mingw\lib -lole32 -lwinmm -lstdc++ -lusb-1.0 -lQtGui4 -lQtCore4
    /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libQtGui4.a(qapplication.o).text+0x1824): undefined reference to `__imp_CoCreateGuid'
    /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libQtGui4.a(qapplication.o).text+0x1849): undefined reference to `__imp_StringFromGUID2'
    /usr/lib64/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld: /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libQtGui4.a(qapplication.o): bad reloc address 0x0 in section `.data'
    /usr/lib64/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld: final link failed: Invalid operation

    Note that when I add " -lole32 -lwinmm" at the end of the link line, these specific references seem to be resolved, however, some other appear.

    Any help is greatly appreciated

    jan

  2. #2
    Join Date
    Mar 2008
    Posts
    44
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default Re: cross compiling with static libraries (continued)

    OK,
    I found some of the missing symbols (with help from the mingw64-public) mailing list. However, it seems strange that
    when using the static versions of the Qt libs (from the packages in fedora-17) there are further libraries needed that are not specified.
    It seems I have to add "-lole32 -luuid -lgdi32" to the link command line in the generated makefile

    I have still some symbols left that are undefined, and I really have no clue where to find these in the Mingw64 cross environment

    make -f Makefile.Release
    make[1]: Entering directory `/home/jan/cross-compiling/jsdr-3.04/spectrum-viewer'
    x86_64-w64-mingw32-g++ -static -Wl,-s -Wl,-subsystem,console -mthreads -o release/spectrum-viewer.exe object_script.spectrum-viewer.Release -L'/usr/x86_64-w64-mingw32/sys-root/mingw/lib' /home/jan/cross-compiling/qwt-5.2.2/lib/libqwt.a /home/jan/cross-compiling/dll_64/libfftw3-3.lib -lole32 -lwinmm -lstdc++ -lusb-1.0 -lQtGui4 -lQtCore4 -lole32 -lgdi32 -luuid
    /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libQtGui4.a(qaccessible_win.o).text+0x1c56): undefined reference to `__imp_SysAllocStringLen'
    .....
    /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libQtGui4.a(qaccessible_win.o).text+0x2cda): more undefined references to `__imp_SysAllocStringLen' follow
    /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libQtGui4.a(qaccessible_win.o).text+0x3970): undefined reference to `__imp_VariantInit'
    /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libQtGui4.a(qaccessible_win.o).text+0x41d8): undefined reference to `__imp_PlaySoundW'
    /usr/lib64/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld: /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libQtGui4.a(qaccessible_win.o): bad reloc address 0x0 in section `.data'
    /usr/lib64/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld: final link failed: Invalid operation
    collect2: error: ld returned 1 exit status

    If anyone could give a pointer how to locate the libraries for missing symbols in the mingw64 cross compilation environment, it would be a great help

    best
    jan

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: cross compiling with static libraries (continued)

    A quick google produces:
    SysAllocStringLen -> oleaut32.lib
    PlaySoundW -> Winmm.lib
    VariantInit -> oleaut32.lib
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Mar 2008
    Posts
    44
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default Re: cross compiling with static libraries (continued)

    Yes, true, but that does not solve my problem since I need to find the symbols in the libs used by mingw64 in a cross compilation environment,
    So, the question could be restated as: what mingw64 libs correspond to these libs

    Thanks anyway

    best
    jan

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: cross compiling with static libraries (continued)

    This is a question for MinGW forum, you probably will get more help there.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    Mar 2008
    Posts
    44
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default Re: cross compiling with static libraries (continued)

    Solved!!
    It was my mistake, having not set the right option to CONFIG in the
    ".pro" file.

    best
    jan

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: cross compiling with static libraries (continued)

    Will be nice if you share exactly what the mistake was and what the fix is, so other having similar problems can be helped by it.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #8
    Join Date
    Mar 2008
    Posts
    44
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default Re: cross compiling with static libraries (continued)

    When searching how to compile with static libs, I found one mailer who added
    QMAKE_LFLAGS= -static
    which I did, and which gave problems as described.
    Another page on the web gave a more precise detailing of what to do, which
    is essentially set
    CONFIG += static

    which does the trick perfectly (just look for Tutorial for cross compiling).

    So, I compiled my sdr package on Fedora 17, using mingw64 cross compiler tools and
    indeed the resulting software works on windows.
    Still have to configure one or two packages for the whole functionality, but my program works.

    Thankx for the interest
    jan

Similar Threads

  1. Replies: 4
    Last Post: 5th November 2011, 02:38
  2. How to cross-compiling in Qt
    By sanjeet in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 29th April 2011, 19:14
  3. Cross Compiling for MIPS
    By WayneFresh in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 22nd October 2010, 19:25
  4. problem compiling qt application using static external libraries
    By pavan1984 in forum Installation and Deployment
    Replies: 0
    Last Post: 5th October 2010, 12:41
  5. cross compiling
    By tommy in forum Installation and Deployment
    Replies: 1
    Last Post: 8th March 2009, 19:02

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.