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. Unresolved External Symbol....I'm getting this error: LINK2019 Unresolved External Symbol in my exercise code. I actually try to implement it from a youtube video and i'm still getting this error.
Forum Updated to NodeBB v4.3 + New Features

Unresolved External Symbol....I'm getting this error: LINK2019 Unresolved External Symbol in my exercise code. I actually try to implement it from a youtube video and i'm still getting this error.

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 4 Posters 4.3k Views 2 Watching
  • 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.
  • mrjjM mrjj

    Hi
    if linking to other sites breaks copyright, i think whole internet is in troubles ;)

    anyway, since this demo uses network, you must have

    QT += network

    in the .pro file.
    (if you add it, make SURE to run qmake for menu after)

    however, it seems to complain about your own class and not something QTcpServer
    related.

    Would it be possible for your to zip and link your project here ?
    I could have a fst look and see.

    Its most likely something trivial as Lnk do not seem to use external lib or anything else that can give such errors.

    Can you show your code for main.cpp ?

    J Offline
    J Offline
    JadeN001
    wrote on last edited by
    #6

    @mrjj here is what my code looks like or should I say the code that i was trying to learn looks like...I have tried using int and qintptr as well. the error remains same in my computer.
    and yeah Thanks @mrjj .

    jsulmJ 1 Reply Last reply
    0
    • J JadeN001

      @mrjj here is what my code looks like or should I say the code that i was trying to learn looks like...I have tried using int and qintptr as well. the error remains same in my computer.
      and yeah Thanks @mrjj .

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #7

      @JadeN001 Somewhere in your code you're calling StartServer(), but the name of the method is startserver(). Change it. And do a complete rebuild.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      2
      • jsulmJ jsulm

        @JadeN001 Somewhere in your code you're calling StartServer(), but the name of the method is startserver(). Change it. And do a complete rebuild.

        J Offline
        J Offline
        JadeN001
        wrote on last edited by
        #8

        @jsulm thanks
        That caught my eye too so I've cleared it but the first error remains as it was.

        main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl myserver::myserver(class QObject *)" (??0myserver@@QEAA@PEAVQObject@@@Z) referenced in function main

        and

        moc_myserver.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl myserver::addPendingConnection(class QTcpSocket *)" (?addPendingConnection@myserver@@QEAAXPEAVQTcpSocket@@@Z) referenced in function "private: static void __cdecl myserver::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@myserver@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)

        it also shows a message in red which says.. "File not found:moc_myserver.obj"

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #9

          Hi,

          Looks like you did not implement addPendingConnection (at least from the code you posted).

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

            Looks like you did not implement addPendingConnection (at least from the code you posted).

            J Offline
            J Offline
            JadeN001
            wrote on last edited by
            #10

            @SGaist thanks

            so how does that work !! and whats the flow of the whole sending and receiving functions or Signals and slots for client socket !

            should I create ready read, byteswritten and addPendingConnection of my own or should I just call those signals and attach them to the function or slots that I'd create!!?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #11

              When you declare a slot, you have to implement it otherwise you have missing code. moc generates code that will use that slot.

              Did you read the Signals And Slots chapter of Qt's documentation ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              J 1 Reply Last reply
              2
              • SGaistS SGaist

                When you declare a slot, you have to implement it otherwise you have missing code. moc generates code that will use that slot.

                Did you read the Signals And Slots chapter of Qt's documentation ?

                J Offline
                J Offline
                JadeN001
                wrote on last edited by
                #12

                @SGaist yes I have,Thank you. But the flow confuses me here.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #13

                  What do you mean by flow ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  J 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    What do you mean by flow ?

                    J Offline
                    J Offline
                    JadeN001
                    wrote on last edited by
                    #14

                    @SGaist What I mean is, as for readyRead(): This signal is emitted once every time new data is available for reading... So does it mean that once i connect this signal to the slot I created to read or Receive data would get called every time when someone sends data!!?

                    now bytesWritten(qint64 bytes): This signal is emitted every time a payload of data has been written to the device's current write channel....So should I consider that if I connect this signal to the slot which sends data from my side it will get called every time !!?

                    my code puts me in the blocking mode sometimes. and whats the best way to connect signal from one class to the slot of some other class !!

                    thanks in advance @SGaist and anyone who responses back.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #15

                      It will be called every time new data has arrived which might not be exactly when your device sends it (depending on the speed of the channel, system load, application load etc.) Usually you won't see any delay but it's not instantaneous.

                      That's the goal of signals and slots, once connected the slots are getting called each time a signal is fired.

                      What do you mean by "puts me in the blocking mode" ?

                      The best way is to do the connections in the class that manages these two objects.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      J 1 Reply Last reply
                      1
                      • SGaistS SGaist

                        It will be called every time new data has arrived which might not be exactly when your device sends it (depending on the speed of the channel, system load, application load etc.) Usually you won't see any delay but it's not instantaneous.

                        That's the goal of signals and slots, once connected the slots are getting called each time a signal is fired.

                        What do you mean by "puts me in the blocking mode" ?

                        The best way is to do the connections in the class that manages these two objects.

                        J Offline
                        J Offline
                        JadeN001
                        wrote on last edited by
                        #16

                        @SGaist the code I've posted above , I've added a few more slots and functions in it. so when I'm asking a client to enter its ID from server side ...server is supposed to read when there's something to read, instead it reads nothing when client actually sends its ID and then at second attempt server reads it....and now my client is in blocking mode as it can't read or write .
                        now if I remove this asking for ID function "readClientID() " from server side, client and server both works fine .

                        when I debugged the server side, I found that sometimes when client sends its ID, readyRead() signal triggers and it calls the slot which actually receives data instead the function which actually reads ID. I have a signal which is emmited everytime new client comes and that signal is connected to readClientID.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #17

                          From the looks of it, you are expecting to get all of your data at once when readyRead is fired which likely won't happen especially when using TCP. You have to establish a protocol to ensure you got all the data you are expecting or using something like QDataStream transactions.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          J 1 Reply Last reply
                          1
                          • SGaistS SGaist

                            From the looks of it, you are expecting to get all of your data at once when readyRead is fired which likely won't happen especially when using TCP. You have to establish a protocol to ensure you got all the data you are expecting or using something like QDataStream transactions.

                            J Offline
                            J Offline
                            JadeN001
                            wrote on last edited by
                            #18

                            @SGaist thanks
                            I'm getting the same error while using QSemaphore .

                            jsulmJ 1 Reply Last reply
                            0
                            • J JadeN001

                              @SGaist thanks
                              I'm getting the same error while using QSemaphore .

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #19

                              @JadeN001 What same error? Can you post the error?

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0

                              • Login

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