NO

Author Topic: Unresolved symbol error for code in background thread.  (Read 3377 times)

rp108

  • Guest
Unresolved symbol error for code in background thread.
« on: September 27, 2015, 06:20:49 PM »
First .....

I wrote a Dialog Based Win32 application to download a web page from a site.

I wrote all of the sockets code directly in main.c

I include:  <winsock.h>

That program works well.

Next...

I wrote a simple function that loops and counts up with an internal while() at once/sec and updates a dialog edit box.
I ran that function as a background thread and that program runs fine, counting up, updating the edit dialog once per sec.

Finally ....

I took the working sockets code and put it into the function that runs in the background and I get POLINK Unresolved  External error for all of the sockets calls.

My function is declared as:
void  __cdecl th02(void* pParam)

I start the background thread with:
int n = 123;
beginthread(&th02, 0, &n);

The error messages are:
POLINK: error: Unresolved external symbol '_WSAStartup@8'.
POLINK: error: Unresolved external symbol '_gethostbyname@4'.
POLINK: error: Unresolved external symbol '_socket@12'.
POLINK: error: Unresolved external symbol '_inet_ntoa@4'.
POLINK: error: Unresolved external symbol '_inet_addr@4'.
POLINK: error: Unresolved external symbol '_htons@4'.
POLINK: error: Unresolved external symbol '_connect@12'.
POLINK: error: Unresolved external symbol '_send@16'.
POLINK: error: Unresolved external symbol '_recv@16'.
POLINK: error: Unresolved external symbol '_closesocket@4'.
POLINK: error: Unresolved external symbol '_WSACleanup@0'.
POLINK: fatal error: 11 unresolved external(s).


Any help in understanding my error here is much appreciated.

Thanks,
Rob




Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Unresolved symbol error for code in background thread.
« Reply #1 on: September 28, 2015, 02:48:12 AM »
Pretty much impossible to give you a definitive answer without actually seeing the whole source code.

Linker errors are usually the result of including calls to functions/variables that are not in either the immediate source file of the main() procedure or are in external files that are not properly compiled and "included" (in the linker path) so that they can be found by the linker...

Post the ZIP'ed up project and someone will be more likely be able to tell you where you went wrong...

Ralf

rp108

  • Guest
Re: Unresolved symbol error for code in background thread.
« Reply #2 on: September 28, 2015, 04:47:31 PM »
Thanks Ralf,

I will start working on Zipping up a Project.

I appreciate your insights.

Best,
Rob

rp108

  • Guest
Re: Unresolved symbol error for code in background thread.
« Reply #3 on: September 28, 2015, 04:57:00 PM »
Ralf,

Thanks again.
You got me thinking and I found my error,

I forgot to include in the source code:
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "wsock32.lib")

It links fine now.

I appreciate your insights and your willingness to help.

All the best,
Rob

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Unresolved symbol error for code in background thread.
« Reply #4 on: September 29, 2015, 02:51:46 AM »
Ralf,

Thanks again.
You got me thinking and I found my error,
Yeah, that happens a lot this way...  ;)

Btw, to zip up a project, it's just one right-click on the executable in the file list windows on the right hand side of the IDE...  8)

Ralf