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.



  • 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.
    First I implemented client code in one computer lets call it computer A and I got LINK2019 error, I ran same code in different computer lets call it computer B and it worked. now i'm running server code in computer B and getting this LINK2019 error again...can anyone suggest anything !!!

    I was reading in QT Forum and I read somewhere that the library files could be corrupted ...how can we know it ?

    and still LINK2019 error is unsolved...need suggestions.


  • Qt Champions 2017

    Hi
    You must show some code.
    Also show the pro file where you link to the LIB/DLL
    and maybe link to the video your are following.
    Would also help with a screen shot of what you have in the lib folder.

    Else its pretty darn impossible to guess at :)



  • thanks mrjj for responding...
    https://www.youtube.com/watch?v=iKtCXUHsV70
    thats the link of the video ...i hope i'm not violating any copyrights.

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


  • Qt Champions 2017

    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 ?



  • 4_1523187552476_pro.jpeg 3_1523187552475_mythreadh.jpeg 2_1523187552475_mythreadcpp.jpeg 1_1523187552475_myserverh.jpeg 0_1523187552474_myserveercpp.jpeg



  • @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 .


  • Moderators

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



  • @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"


  • Lifetime Qt Champion

    Hi,

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



  • @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!!?


  • Lifetime Qt Champion

    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 ?



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


  • Lifetime Qt Champion

    What do you mean by flow ?



  • @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.


  • Lifetime Qt Champion

    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.



  • @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.


  • Lifetime Qt Champion

    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.



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


  • Moderators

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


Log in to reply
 

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