6

I am attempting to compile John Burger's StdTel for Windows 98. I am using Pelles C, because it has Windows 98 support, but it appears that I don't have the necessary libraries. This is the compiler's output:

Building StdTel.obj.
C:\StdTel\StdTel.c(76): warning #2145: Assignment of 'char * *' to 'const char * const *'.
Building StdTel.exe.
POLINK: error: Unresolved external symbol '__imp__WSAGetLastError@0'.
POLINK: error: Unresolved external symbol '__imp__htons@4'.
POLINK: error: Unresolved external symbol '__imp__connect@12'.
POLINK: error: Unresolved external symbol '__imp__send@16'.
POLINK: error: Unresolved external symbol '__imp__shutdown@8'.
POLINK: error: Unresolved external symbol '__imp__WSAStartup@8'.
POLINK: error: Unresolved external symbol '__imp__gethostbyname@4'.
POLINK: error: Unresolved external symbol '__imp__getservbyname@8'.
POLINK: error: Unresolved external symbol '__imp__ntohs@4'.
POLINK: error: Unresolved external symbol '__imp__socket@12'.
POLINK: error: Unresolved external symbol '__imp__setsockopt@20'.
POLINK: error: Unresolved external symbol '__imp__closesocket@4'.
POLINK: error: Unresolved external symbol '__imp__recv@16'.
POLINK: fatal error: 13 unresolved external(s).
*** Error code: 1 ***
Done.

So that you don't have to open up the program source, here's the relevant section:

#define STRICT
#define WIN32_LEAN_AND_MEAN
#define WINVER              _WIN32_WINNT_NT4 // Earliest available option to Windows 98
#define _WIN32_WINNT        _WIN32_WINNT_NT4
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include <Windows.h>
#include <WinSock2.h>

#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

I also tried specifying Windows version 2.10 (guestimated from this code snippet), but it didn't appear to have any effect.

7

You are probably not linking to the winsock library.

Depending on the winsock version you are targetting, you should use either

ws2_32.lib for Winsock 2 (which you seem to be using), or

wsock32.lib for Winsock 1.1

  • Would linking to the Windows 10 versions of libraries like user32.lib create references that Windows 98 would understand (i.e. are these libraries backwards-compatible)? – wizzwizz4 Feb 9 '17 at 15:50
  • 1
    @wizzwizz4 Very probably not - I would assume that newer libraries will also refer to newer kernel functions. But I've never actually tried – tofro Feb 9 '17 at 21:11
  • I suppose I'll have to (install and) boot up my Windows 98 VM then. – wizzwizz4 Feb 9 '17 at 21:13
  • 1
    @wizzwizz4, I haven't tried it, but using the Win10 libraries should work: DLL import "libraries" are essentially just lists of symbols to keep the linker happy. – Mark Feb 9 '17 at 21:38
  • 1
    Yes, any version of the import library will work. The problem will come when you try and import functions that didn't exist back on Windows 98. Your program won't start up. So don't do that. :-) If you are going to boot up a Windows 98 VM, you will need an old version of the Windows SDK. I'm assuming you have a copy, @wizz? Or an MSDN subscription? And your guesstimate was wrong. Windows 98 is version 4.10, it's just not Windows NT. I don't know where you were trying to "specify" that, though. – Cody Gray Feb 12 '17 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.