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.
-
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 -
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 ?
-
@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"
-
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!!?
-
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 ?
-
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.
-
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.
-
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.