Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Static library compatibility amid different intel cpu



  • Hello,
    I am experiencing a problem of compatibility with a static library I created using i7 processor. When I try to link this library on another project on a intel dual core (I think i3), then I have some error like "bad value format" or something like that. I have to recompile the static library unsing i3 to avoid that linkage problem.
    So I am trying to make the static library without optimization for a specific cpu and to achieve this I put in my pro file:
    QMAKE_CXXFLAGS+=-mtune=generic

    but it seems to be not effective...I read about -m32 and -m64 but I don't know if this is the case.
    Is there someone that can help me?


  • Qt Champions 2019

    It should not be related to i7/i3.
    Do you use the same compiler for the other project?
    Which compilers do you use?
    Is your library 32 or 64 bit binary?
    Is the other project built as 32 or 64 bit binary?
    What is the platform (Windows/Linux(MacOS)?



  • Hello, I know that shouldn't impact the cpu...but for some reason the one built by i7 is not working on the i3.
    On both I use Qt 5.6 framework, so same default compiler and chain, exclusively 64bit for the static lib and for the project I am trying to link the library with.
    All project are on linux systems, the only difference is kubuntu on i7 and gentoo on i3


  • Qt Champions 2019

    I'm quite sure the compilers on Kubuntu and Gentoo are not same. That would explain the problem.
    You can check the gcc version on both machines via

    gcc -v
    


  • @jsulm
    But since I am using Qt Creator it should use its own provided compiler...or maybe I am wrong?

    Anyway I will check the gcc version on both system, but they should be both 4.9.x and the ABI should be compatible for the major version



  • @AlterX said:

    But since I am using Qt Creator it should use its own provided compiler...or maybe I am wrong?

    No, QtCreator is only an IDE, it doesn't contain a compiler.

    @AlterX said:

    Anyway I will check the gcc version on both system, but they should be both 4.9.x and the ABI should be compatible for the major version

    Well, this is OK for shared libraries IIRC, but for static ones you need exactly the same compiler and glibc versions, otherwise everything blows up.



  • @JohanSolo said:

    @AlterX said:

    But since I am using Qt Creator it should use its own provided compiler...or maybe I am wrong?

    No, QtCreator is only an IDE, it doesn't contain a compiler.

    Ok I was speaking about Qt framework and not QtCreator only. But I think you are right.

    @AlterX said:

    Anyway I will check the gcc version on both system, but they should be both 4.9.x and the ABI should be compatible for the major version

    Well, this is OK for shared libraries IIRC, but for static ones you need exactly the same compiler and glibc versions, otherwise everything blows up.

    And so what if I want to distribute a static library to be used by everyone?



  • @AlterX said:

    And so what if I want to distribute a static library to be used by everyone?

    Well, either you tell people which compiler / glibc version they should use, or you build one library for each combination you want to support. The last possibility I see is to distribute the sources, so that people who want to use your library just have to compile it.

    Or you can of course distribute a shared library... which is what most people do.



  • @JohanSolo said:

    @AlterX said:

    And so what if I want to distribute a static library to be used by everyone?

    Well, either you tell people which compiler / glibc version they should use, or you build one library for each combination you want to support. The last possibility I see is to distribute the sources, so that people who want to use your library just have to compile it.

    Or you can of course distribute a shared library... which is what most people do.

    If it is like this, then this is really painful...But I used some static libraries from 3rd party...and it was working...can't be just a case I had the same glibc and compiler!



  • @AlterX said:

    If it is like this, then this is really painful...But I used some static libraries from 3rd party...and it was working...can't be just a case I had the same glibc and compiler!

    This goes beyond my expertise... But I think it requires at least the glibc version to be `similar'. Hopefully somebody with additional knowledge can comment on this.



  • @JohanSolo
    Ok anyway thanks...it is always good when ideas meet together!


  • Qt Champions 2019

    Is there a reason why you want to distribute a static library and not shared?



  • Anyway I made an error in the project settings...I was linking a static lib in a dynamic lib.


Log in to reply