[solved] Linking QtCore on Fedora Linux



  • I am running Fedora Linux 14. After being completely horrified by the Boost thread package, I have been trying to get a simple program using the QtCore classes to link.

    The program I'm trying to build is:

    #include <iostream>
    #include <QtCore/QCoreApplication>

    using namespace std;

    int main(int argc, char *argv[]) {
    QCoreApplication app(argc, argv);
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!

    return 0;
    }

    I am building under Eclipse, using gcc 4.5.1

    I am getting lots of undefined references. I used:

    -L/opt/Qt/5.1.1/gcc_64/lib and -lQt5Core

    I am getting the following link errors:

    Invoking: GCC C++ Linker
    g++ -L/opt/Qt/5.1.1/gcc_64/lib -o "MatchingEngine" ./src/MatchingEngine.o ./src/TransactionRouter.o ./src/TransactionRouter_test.o -lQt5Core
    /usr/bin/ld: warning: libicui18n.so.51, needed by /opt/Qt/5.1.1/gcc_64/lib/libQt5Core.so, not found (try using -rpath or -rpath-link)
    /usr/bin/ld: warning: libicuuc.so.51, needed by /opt/Qt/5.1.1/gcc_64/lib/libQt5Core.so, not found (try using -rpath or -rpath-link)
    /opt/Qt/5.1.1/gcc_64/lib/libQt5Core.so: undefined reference to ucnv_getStandardName_51' /opt/Qt/5.1.1/gcc_64/lib/libQt5Core.so: undefined reference toucol_close_51'
    /opt/Qt/5.1.1/gcc_64/lib/libQt5Core.so: undefined reference to `ucol_strcoll_51'
    [etc...]

    Any suggestions or pointers would be greatly appreciated. I'm searched for the libraries that should be included using QtCore, but I have not found anything. This is frustrating, since Qt is a great library. It puts Boost to shame. Well, it would if I could get it to build.

    I am hoping that someone can provide the set of link flags that I need to build on Linux.

    Many thanks in advance,

    Ian


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You are not linking icu. If you want to know all dependencies, you should use qmake to generate the Makefiles for your project and read them. I would suggest you to use Qt Creator, it would be simpler to develop you C++ application



  • Thank you so much for the reply, Samuel.

    I agree that it would probably be better to use QtCreator, but I've gone done the Eclipse path a ways.

    I have Qt 5.1.1 installed. In Eclipse I added

    libicudata.so.51.1
    libicui18n.so.51.1
    libicuuc.so.51.1

    to the C/C++ Build under the project settings in the Miscellaneous section under C++ Linker. This took care of my undefined symbols.

    Under the Eclipse Run Configurations I added the LD_LIBRARY_PATH variable:

    LD_LIBRARY_PATH /opt/Qt/5.1.1/gcc_64/lib:$LD_LIBRARY_PATH

    I selected "Replace native environment with specified environment"

    This allowed the shared library to be found at run time.

    So it all worked. Well, so far. I have not tried the threaded code yet. But I got "Hello world". And what could go wrong? :-)

    Again, many thanks for your post and your time. This really got me past a road block. I was starting to look at Intel's Threaded Building Block library since I couldn't get Qt to work.

    Best,

    Ian


  • Lifetime Qt Champion

    You're welcome !

    For the threading part you should not have more dependencies. When using other module of Qt (gui, network, etc..) you should ldd the corresponding libraries and you'll see what you need. One package that you will probably need if it's not already installed is the OpenGL dev package (a frequent question on this forum)

    Since you got it working don't forget to update the thread title prepending [solved] so other forum users may know a solution has been found :)

    Happy coding !



  • Thanks for the pointer on the title, Samuel. And for the additional post.

    Best,
    Ian


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.