Menu

LNK2019 & LNK1120 in Qt ERRORS

Anonymous
2024-02-10
2024-02-12
  • Anonymous

    Anonymous - 2024-02-10

    To whom it may concern,

    I hope you are well.

    I have installed GeographicLib then added the library in the .pro file of the Qt. After that, I included #include <geographiclib geodesic.hpp=""> and added using namespace GeographicLib in my .cpp code and wrote a simple code.
    I have run the code via:</geographiclib>

    windows 10
    Qt 6.5.3
    MSVC2019_64bit

    When I run my code I got the attached errors. I want to kindly ask you to help me.

    Thank you in advance,
    Sincerely yours,
    Zahra

     
  • Charles Karney

    Charles Karney - 2024-02-10

    You don't give enough details to diagnose your problem. But it looks
    like the linker doesn't know the location of the GeographicLib library.
    That would be the place to look.

    Can you link any external library to your application? If not, then
    you need to seek help in a Qt-specific forum.

    I haven't messed with Qt's .pro files for many years. Instead, I build
    Qt projects with CMake. (Qt Creator can handle CMake builds.) In this
    case, you just use find_package(GeographicLib ...) to tell the system
    where to find Geographiclib.

     
    • Anonymous

      Anonymous - 2024-02-10

      Dear Charles,

      Thank you for your reply.

      The following is the .cpp code which I tried to run:

      #include "test.h"
      #include "qdebug.h"
      
      #undef GetObject
      #include <iostream>
      #include <GeographicLib/Geodesic.hpp>
      
      using namespace std;
      using namespace GeographicLib;
      
      //#pragma comment(lib, "GeographicLib-i.lib") // Replace with the actual lib file name
      
      Test::Test(QObject *parent)
          : QObject{parent}
      {
      
          // Create a new Geodesic object
          GeographicLib::Geodesic geod(GeographicLib::Constants::WGS84_a(),
                                       GeographicLib::Constants::WGS84_f());
      
          // Define the start and end points
          double lat1 = 50.0, lon1 = 10.0, lat2 = 50.01, lon2 = 9.990;
      
          // Calculate the total distance between the two points
      //    geod.Inverse(lat1, lon1, lat2, lon2,
      //                 GeographicLib::Geodesic::DISTANCE);
      
          // Interpolate points at intervals of 100 meters
          for (double s = 100; s <= s12; s += 100) {
              double lat, lon;
              geod.Direct(lat1, lon1, 0, s, lat, lon);
              qDebug() << "Point: " << lat << ", " << lon;
          }
      }
      

      and in the .pro file I have put the path of the GeographicLib:

      QT += quick
      
      # You can make your code fail to compile if it uses deprecated APIs.
      # In order to do so, uncomment the following line.
      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
      
      SOURCES += \
              main.cpp \
              test.cpp
      
      RESOURCES += qml.qrc
      
      # Additional import path used to resolve QML modules in Qt Creator's code model
      QML_IMPORT_PATH =
      
      # Additional import path used to resolve QML modules just for Qt Quick Designer
      QML_DESIGNER_IMPORT_PATH =
      
      # Default rules for deployment.
      qnx: target.path = /tmp/$${TARGET}/bin
      else: unix:!android: target.path = /opt/$${TARGET}/bin
      !isEmpty(target.path): INSTALLS += target
      
      
      
      HEADERS += \
          test.h
      
      
      
      win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../lib/ -lGeographicLib-i
      #else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../lib/ -lGeographicLib-id
      else:unix: LIBS += -L$$PWD/../lib/ -lGeographicLib-i
      
      INCLUDEPATH += $$PWD/../include
      DEPENDPATH += $$PWD/../include
      

      As I am using the sample code of the ArcGis which has used qmake so I can not use Qt CMake.

      Yes I can use other library such as pcap in my code.

      Thank you agian for your response,
      Sincerely yours,
      Zahra

       
  • Charles Karney

    Charles Karney - 2024-02-10

    Your .pro seems OK. But then I don't know the intricacies of .pro
    files. How does your application find bin/GeographicLib.dll? Is the
    bin directory in you PATH?

    Your problems are, most likely, nothing to do with GeographicLib but
    instead how you use any external library in your program. In this
    case, you need to seek help in a Qt-specific forum. Since your sample
    code is from ArcGis, maybe you can get help there.

    If you do resolve your problem, please post the solution to this forum
    so others can benefit from your experience.

     
  • Anonymous

    Anonymous - 2024-02-12

    Dear Charles,

    Thank you for your reply.

    I added the .dll files into my Debug folder and the errors were removed.

    Sincerely yours,
    Zahra

     

Anonymous
Anonymous

Add attachments
Cancel