Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot compile
Forum Updated to NodeBB v4.3 + New Features

Cannot compile

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    El_Professor
    wrote on last edited by aha_1980
    #1

    Hello, I started a small project. I need to use an external library (.a).

    .pro

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = OgameBot
    TEMPLATE = app
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which has been marked as deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            main.cpp \
            mainwindow.cpp
    
    HEADERS += \
            mainwindow.h
    
    FORMS += \
            mainwindow.ui
    
    
    
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libRequests/release/ -lRequests
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../libRequests/debug/ -lRequests
    else:unix: LIBS += -L$$PWD/../libRequests/ -lRequests
    
    INCLUDEPATH += $$PWD/../libRequests
    DEPENDPATH += $$PWD/../libRequests
    
    win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../libRequests/release/libRequests.a
    else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../libRequests/debug/libRequests.a
    else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../libRequests/release/Requests.lib
    else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../libRequests/debug/Requests.lib
    else:unix: PRE_TARGETDEPS += $$PWD/../libRequests/libRequests.a
    

    main.cpp

    #include <QApplication>
    
    #include "mainwindow.h"
    #include "Request.h"
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        HTTP::Request request;
    
        return a.exec();
    }
    

    I just call HTTP::Request which is in the external library.

    Here are the errors in the compilation:

    /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.10 -Wl,-rpath,@executable_path/Frameworks -Wl,-rpath,/Users/jordanbarbe/Qt/5.10.1/clang_64/lib -o OgameBot.app/Contents/MacOS/OgameBot main.o mainwindow.o moc_mainwindow.o   -F/Users/jordanbarbe/Qt/5.10.1/clang_64/lib -L/Users/jordanbarbe/go-workspace/Project/OgameBot/../libRequests/ -lRequests -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL 
    ld: warning: object file (/Users/jordanbarbe/go-workspace/Project/libRequests/libRequests.a(Request.o)) was built for newer OSX version (10.13) than being linked (10.10)
    ld: warning: object file (/Users/jordanbarbe/go-workspace/Project/libRequests/libRequests.a(Headers.o)) was built for newer OSX version (10.13) than being linked (10.10)
    ld: warning: object file (/Users/jordanbarbe/go-workspace/Project/libRequests/libRequests.a(Response.o)) was built for newer OSX version (10.13) than being linked (10.10)
    Undefined symbols for architecture x86_64:
      "_curl_easy_cleanup", referenced from:
          HTTP::Request::~Request() in libRequests.a(Request.o)
          HTTP::Request::~Request() in libRequests.a(Request.o)
      "_curl_easy_getinfo", referenced from:
          HTTP::Request::perform(HTTP::Response&) in libRequests.a(Request.o)
      "_curl_easy_init", referenced from:
          HTTP::Request::Request() in libRequests.a(Request.o)
          HTTP::Request::Request() in libRequests.a(Request.o)
      "_curl_easy_perform", referenced from:
          HTTP::Request::perform(HTTP::Response&) in libRequests.a(Request.o)
      "_curl_easy_reset", referenced from:
          HTTP::Request::Request() in libRequests.a(Request.o)
          HTTP::Request::curlReset() in libRequests.a(Request.o)
          HTTP::Request::Request() in libRequests.a(Request.o)
          HTTP::Request::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
          HTTP::Request::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, HTTP::Headers const&) in libRequests.a(Request.o)
          HTTP::Request::post(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
          HTTP::Request::post(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, HTTP::Headers const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
          ...
      "_curl_easy_setopt", referenced from:
          HTTP::Request::Request() in libRequests.a(Request.o)
          HTTP::Request::curlReset() in libRequests.a(Request.o)
          HTTP::Request::Request() in libRequests.a(Request.o)
          HTTP::Request::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
          HTTP::Request::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, HTTP::Headers const&) in libRequests.a(Request.o)
          HTTP::Request::post(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
          HTTP::Request::post(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, HTTP::Headers const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
          ...
      "_curl_easy_strerror", referenced from:
          HTTP::Request::perform(HTTP::Response&) in libRequests.a(Request.o)
      "_curl_slist_append", referenced from:
          HTTP::Headers::set(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Headers.o)
          HTTP::Headers::set(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Headers.o)
      "_curl_slist_free_all", referenced from:
          HTTP::Headers::~Headers() in libRequests.a(Headers.o)
          HTTP::Headers::clear() in libRequests.a(Headers.o)
          HTTP::Headers::~Headers() in libRequests.a(Headers.o)
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [OgameBot.app/Contents/MacOS/OgameBot] Error 1
    

    here is the library I'm trying to use: lib request

    Thank you for your future answer.

    [Edit ~aha_1980: fixed link]

    aha_1980A 1 Reply Last reply
    0
    • E El_Professor

      Hello, I started a small project. I need to use an external library (.a).

      .pro

      QT       += core gui
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      TARGET = OgameBot
      TEMPLATE = app
      
      # The following define makes your compiler emit warnings if you use
      # any feature of Qt which has been marked as deprecated (the exact warnings
      # depend on your compiler). Please consult the documentation of the
      # deprecated API in order to know how to port your code away from it.
      DEFINES += QT_DEPRECATED_WARNINGS
      
      # You can also make your code fail to compile if you use deprecated APIs.
      # In order to do so, uncomment the following line.
      # You can also select to disable deprecated APIs only up to a certain version of Qt.
      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
      
      SOURCES += \
              main.cpp \
              mainwindow.cpp
      
      HEADERS += \
              mainwindow.h
      
      FORMS += \
              mainwindow.ui
      
      
      
      win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libRequests/release/ -lRequests
      else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../libRequests/debug/ -lRequests
      else:unix: LIBS += -L$$PWD/../libRequests/ -lRequests
      
      INCLUDEPATH += $$PWD/../libRequests
      DEPENDPATH += $$PWD/../libRequests
      
      win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../libRequests/release/libRequests.a
      else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../libRequests/debug/libRequests.a
      else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../libRequests/release/Requests.lib
      else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../libRequests/debug/Requests.lib
      else:unix: PRE_TARGETDEPS += $$PWD/../libRequests/libRequests.a
      

      main.cpp

      #include <QApplication>
      
      #include "mainwindow.h"
      #include "Request.h"
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          MainWindow w;
          w.show();
      
          HTTP::Request request;
      
          return a.exec();
      }
      

      I just call HTTP::Request which is in the external library.

      Here are the errors in the compilation:

      /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.10 -Wl,-rpath,@executable_path/Frameworks -Wl,-rpath,/Users/jordanbarbe/Qt/5.10.1/clang_64/lib -o OgameBot.app/Contents/MacOS/OgameBot main.o mainwindow.o moc_mainwindow.o   -F/Users/jordanbarbe/Qt/5.10.1/clang_64/lib -L/Users/jordanbarbe/go-workspace/Project/OgameBot/../libRequests/ -lRequests -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL 
      ld: warning: object file (/Users/jordanbarbe/go-workspace/Project/libRequests/libRequests.a(Request.o)) was built for newer OSX version (10.13) than being linked (10.10)
      ld: warning: object file (/Users/jordanbarbe/go-workspace/Project/libRequests/libRequests.a(Headers.o)) was built for newer OSX version (10.13) than being linked (10.10)
      ld: warning: object file (/Users/jordanbarbe/go-workspace/Project/libRequests/libRequests.a(Response.o)) was built for newer OSX version (10.13) than being linked (10.10)
      Undefined symbols for architecture x86_64:
        "_curl_easy_cleanup", referenced from:
            HTTP::Request::~Request() in libRequests.a(Request.o)
            HTTP::Request::~Request() in libRequests.a(Request.o)
        "_curl_easy_getinfo", referenced from:
            HTTP::Request::perform(HTTP::Response&) in libRequests.a(Request.o)
        "_curl_easy_init", referenced from:
            HTTP::Request::Request() in libRequests.a(Request.o)
            HTTP::Request::Request() in libRequests.a(Request.o)
        "_curl_easy_perform", referenced from:
            HTTP::Request::perform(HTTP::Response&) in libRequests.a(Request.o)
        "_curl_easy_reset", referenced from:
            HTTP::Request::Request() in libRequests.a(Request.o)
            HTTP::Request::curlReset() in libRequests.a(Request.o)
            HTTP::Request::Request() in libRequests.a(Request.o)
            HTTP::Request::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
            HTTP::Request::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, HTTP::Headers const&) in libRequests.a(Request.o)
            HTTP::Request::post(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
            HTTP::Request::post(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, HTTP::Headers const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
            ...
        "_curl_easy_setopt", referenced from:
            HTTP::Request::Request() in libRequests.a(Request.o)
            HTTP::Request::curlReset() in libRequests.a(Request.o)
            HTTP::Request::Request() in libRequests.a(Request.o)
            HTTP::Request::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
            HTTP::Request::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, HTTP::Headers const&) in libRequests.a(Request.o)
            HTTP::Request::post(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
            HTTP::Request::post(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, HTTP::Headers const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Request.o)
            ...
        "_curl_easy_strerror", referenced from:
            HTTP::Request::perform(HTTP::Response&) in libRequests.a(Request.o)
        "_curl_slist_append", referenced from:
            HTTP::Headers::set(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Headers.o)
            HTTP::Headers::set(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libRequests.a(Headers.o)
        "_curl_slist_free_all", referenced from:
            HTTP::Headers::~Headers() in libRequests.a(Headers.o)
            HTTP::Headers::clear() in libRequests.a(Headers.o)
            HTTP::Headers::~Headers() in libRequests.a(Headers.o)
      ld: symbol(s) not found for architecture x86_64
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      make: *** [OgameBot.app/Contents/MacOS/OgameBot] Error 1
      

      here is the library I'm trying to use: lib request

      Thank you for your future answer.

      [Edit ~aha_1980: fixed link]

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @El_Professor said in Cannot compile:

      I'm no Mac user, but these lines looks suspicious to me:

      ld: warning: object file (/Users/jordanbarbe/go-workspace/Project/libRequests/libRequests.a(Request.o)) was built for newer OSX version (10.13) than being linked (10.10)
      ld: warning: object file (/Users/jordanbarbe/go-workspace/Project/libRequests/libRequests.a(Headers.o)) was built for newer OSX version (10.13) than being linked (10.10)
      ld: warning: object file (/Users/jordanbarbe/go-workspace/Project/libRequests/libRequests.a(Response.o)) was built for newer OSX version (10.13) than being linked (10.10)

      ld: symbol(s) not found for architecture x86_64

      Did you get the library pre-compiled? From where? Can you build it yourself?

      Qt has to stay free or it will die.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        El_Professor
        wrote on last edited by
        #3

        Hi, yes I compiled the library well before. I have my request.a file and 3 header files. I added the library via Qt with a right click on the project then "add a new library" .
        So I was looking for the library in my computer in another folder in Qt. I selected external library.

        thanks you

        aha_1980A 1 Reply Last reply
        0
        • E El_Professor

          Hi, yes I compiled the library well before. I have my request.a file and 3 header files. I added the library via Qt with a right click on the project then "add a new library" .
          So I was looking for the library in my computer in another folder in Qt. I selected external library.

          thanks you

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @El_Professor said in Cannot compile:

          Hi, yes I compiled the library well before.

          Hmm, so why does the linker complains:

          ld: warning: object file [..] was built for newer OSX version (10.13) than being linked (10.10)

          Maybe a Mac user can help you more in that regard.

          Qt has to stay free or it will die.

          1 Reply Last reply
          0
          • E Offline
            E Offline
            El_Professor
            wrote on last edited by
            #5

            I don't know exactly. I only cloned the above mentioned repository. and then made a Make in this repository which directly creates a libRequests.a file for me.

            aha_1980A 1 Reply Last reply
            0
            • E El_Professor

              I don't know exactly. I only cloned the above mentioned repository. and then made a Make in this repository which directly creates a libRequests.a file for me.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @El_Professor

              It seems that library handles HTTP requests. Any reason you don't use Qt's QNetworkAccessManager?

              Qt has to stay free or it will die.

              1 Reply Last reply
              1
              • E Offline
                E Offline
                El_Professor
                wrote on last edited by
                #7

                I don't know. I thought we couldn't deal with it?

                thanks you for reply

                aha_1980A 1 Reply Last reply
                0
                • E El_Professor

                  I don't know. I thought we couldn't deal with it?

                  thanks you for reply

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @El_Professor So what do you want to do exactly?

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  1
                  • E Offline
                    E Offline
                    El_Professor
                    wrote on last edited by
                    #9

                    I'm learning. So I try to get a web page for example from a game and then connect to that game via the c++/Qt code.

                    aha_1980A 1 Reply Last reply
                    0
                    • E El_Professor

                      I'm learning. So I try to get a web page for example from a game and then connect to that game via the c++/Qt code.

                      aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @El_Professor so why can't you use QNetworkAccessManager?

                      Qt has to stay free or it will die.

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        El_Professor
                        wrote on last edited by
                        #11

                        In fact a friend explained to me that he was using this library I thought I would take the same one. I forgot Qt can do it. Thank you for your response. I already started my program with this class. And I can do the same thing with librequest for lib.a.
                        sorry for the inconvenience

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved