|
-
May 20th, 2001, 08:09 PM
#1
Thread Starter
Fanatic Member
What is an unresolved external symbol?
I am trying to compile some code, but I keep getting the errors:
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/cryptography.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
What does this mean, and what is an external symbol?
Alcohol & calculus don't mix.
Never drink & derive.
-
May 20th, 2001, 09:14 PM
#2
Since the linker is complaining, it means it can't find a function or subroutine (an entry point for a JSB instruction) with the name in your code. The name is an external reference, one which has to be linked in, because it lives in an .olb or .dll file for example.
For example, suppose you had a reference to the api LockWindowUpdate which lives in user32.dll. If you spelled it LockWindowsUpdate you would get this error, because the linker couln't find that name in user32.dll Iy you erroneously told the compiler that the function was in kernel32.dll, you'd see the same error.
-
May 20th, 2001, 11:49 PM
#3
Frenzied Member
What Jim says is right, but I bet I know what the problem is. You're using a main() function and no WinMain() function in a project you have started, which you chose to be a Win32 Application. You want a Win32 Console Application project instead. Win32 Applications start their execution at WinMain().
Harry.
"From one thing, know ten thousand things."
-
May 21st, 2001, 10:50 AM
#4
Monday Morning Lunatic
Just as an FYI...
The reason it's asking for _WinMain@16 is to do with name mangling. When you put WinMain into your code, the compiler adds bits to identify the function. For the standard calling convention in a C function (extern "C" WINAPI/CALLBACK/PASCAL/__stdcall), it prepends a "_" (that's how all C function names end up). The @16 is the number of bytes that need to be passed to the function.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 21st, 2001, 11:45 AM
#5
The prepended underscore is industry standard symbology - I've written linkers and compilers. Just don't use C++ much except to twiddle bits. At least not enough to have encountered this problem personally.
Thought he wanted to know what an unresolved external symbol was. I hope I did not imply that he had mistyped something - was not my intention. Compilers check declared symbol references against the local symbol table such that you normally get unresolved errors only when you attempt to use the wrong library for the symbol. Or declare extern, so the compiler check is turned off. Which is a good reason to consider avoiding extern in C.
-
May 21st, 2001, 11:49 AM
#6
Monday Morning Lunatic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|