"unresolved token" link errors

I

Ian Lazarus

Hello.
How do "unresolved token" link errors occur. How do I fix them?

Linking...
LINK : error LNK2020: unresolved token (0A000015) ??_7type_info@@6B@
LINK : error LNK2020: unresolved token (0A000016) _CxxThrowException
LINK : error LNK2020: unresolved token (0A000018) exception.__ctor
LINK : error LNK2020: unresolved token (0A000019) exception.__ctor
LINK : error LNK2020: unresolved token (0A00001A) exception.__dtor
LINK : error LNK2020: unresolved token (0A00001C) delete
LINK : error LNK2020: unresolved token (0A000022) strlen
LINK : error LNK2020: unresolved token (0A000023) free
LINK : error LNK2020: unresolved token (0A000026) memmove
LINK : error LNK2020: unresolved token (0A00002C) memcpy
LINK : error LNK2020: unresolved token (0A000032) atexit
LINK : error LNK2020: unresolved token (0A00006F) memcmp
LINK : fatal error LNK1120: 12 unresolved externals
 
D

Derrick Coetzee [MSFT]

Ian said:
How do "unresolved token" link errors occur. How do I fix them?

LINK : error LNK2020: unresolved token (0A000015) ??_7type_info@@6B@
LINK : error LNK2020: unresolved token (0A000016) _CxxThrowException
[ . . . ]
LINK : error LNK2020: unresolved token (0A000032) atexit
LINK : error LNK2020: unresolved token (0A00006F) memcmp
LINK : fatal error LNK1120: 12 unresolved externals

Make sure that the option to not link in the standard library is off (it
is by default). Make sure you've included any headers you need, and that
you're compiling and linking C++ files in C++ language mode. If all else
fails, try starting a new project and re-adding all your source files.
If none of this works, please write back and give more information about
your project, the files in it and the language they're in, and the
options you're using. I hope this helps.
 
I

Ian Lazarus

Hello,

Thanks for your help.

The problem goes away if LIBCMTD.lib is explicitly added to the linker as an
added dependency. This is the default library named in the obj files.
However, another problem occurs when this is done, i.e., the linker reports:

LIBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup
C:\project.dll : fatal error LNK1120: 1 unresolved externals

So, after undoing the above fix attempt, and doing all that you suggested,
the problem remains. However, I didn't see any link option referring to not
linking in the standad library. I don't even understand what a "standard"
library is. Maybe you mean the default library. The linker has an "ignore
all default libraries" option, but its default value is "no", which I left
alone.

The C++ compiler options are:

/Od /AI "C:\project directory" /D "WIN32" /D "_DEBUG" /D "_WINDLL" /D
"_MBCS" /FD /EHsc /MTd /GS /Zc:wchar_t /GR /Fo"Debug/" /Fd"Debug/vc70.pdb"
/W3 /nologo /c /Zi /clr /TP /FU
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll" /FU
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" /FU
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"

The linker options are:

/OUT:"C:\project.dll" /INCREMENTAL /NOLOGO /DLL /DEBUG /ASSEMBLYDEBUG
/PDB:"C:\project.pdb" /FIXED:No nochkclr.obj mscoree.lib kernel32.lib
user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "\Program
Files\Microsoft Visual Studio .NET 2003\Sdk\v1.1\Lib\mscoree.lib"

Thanks again
 
D

Derrick Coetzee [MSFT]

"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll" /FU
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" /FU
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"

I did a little additional research on your issue. Based on your .NET
library dependencies, it appears that you are writing a mixed mode
application, including both managed and unmanaged code. Mixed mode
applications are not linked with the C standard library because this is
unsafe due to the DLL Loading Problem. This may result in unresolved
externals much like those you describe. The following article should
explain how to resolve your issue correctly:

http://support.microsoft.com/?id=814472

Create a fresh project and then try out the instructions on this page.
You were on the right track by linking in the C runtime library, but the
remaining steps are far more difficult to guess. I hope this resolves
your issue, but write back if you experience further trouble.
 
I

Ian Lazarus

Thanks very much for you help. I'm still having problems. I performed steps
1 through 4 described in the article you provided, i.e., dealing with
/NOENTRY, msvcrt.lib, nochkclr.obj, and __DllMainCRTStartup@12. The
following link errors now occur.

Linking...
LINK : error LNK2020: unresolved token (0A00002A) std._Lockit.__dtor
LINK : error LNK2020: unresolved token (0A00002B) _DebugHeapTag
LINK : error LNK2020: unresolved token (0A00004D) std.ios_base.__dtor
LINK : error LNK2020: unresolved token (0A000055) std._Mutex.__dtor
LINK : error LNK2020: unresolved token (0A000058)
?_Id_cnt@id@locale@std@@0HA
LINK : error LNK2020: unresolved token (0A00005A) std._Locinfo.__dtor
LINK : error LNK2020: unresolved token (0A00005B)
?id@?$ctype@D@std@@2V0locale@2@A
LINK : error LNK2020: unresolved token (0A00005C)
?id@?$ctype@_W@std@@2V0locale@2@A
LINK : error LNK2020: unresolved token (0A00005D) _BADOFF
LINK : error LNK2020: unresolved token (0A00005E) _Fpz
LINK : fatal error LNK1120: 10 unresolved externals

The link options are now:

/OUT:"C:\project.dll" /INCREMENTAL /NOLOGO /DLL /NODEFAULTLIB
/INCLUDE:"__DllMainCRTStartup@12" /DEBUG /ASSEMBLYDEBUG
/PDB:"C:\project.pdb" /NOENTRY /FIXED:No mscoree.lib msvcrt.lib.
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
"\Program Files\Microsoft Visual Studio .NET 2003\Sdk\v1.1\Lib\mscoree.lib"

I should have provided an overall description of the project. Here it is. I
have a native DLL class library written in C++ that I wish to make available
to .NET users. I'm trying to write a version of the DLL just for those
users. Following the documentation's suggestion, I wrote a "Managed
Extensions wrapper class". Data marshalling is being done manually.

Thanks again.
 
I

Ian Lazarus

I forgot to mention that another change I made was to set the /NODEFAULTLIB
linker option. After removing this option it now compiles successfully.
Thanks a million!
 
D

Derrick Coetzee [MSFT]

Ian said:
I forgot to mention that another change I made was to set the /NODEFAULTLIB
linker option. After removing this option it now compiles successfully.
Thanks a million!

Oops, missed this mail. I'm glad your program is now compiling! Be
careful, though, to make sure you're addressing the Mixed DLL Loading
Problem by either not using static or global data or by ensuring that
it's initialized correctly, as the remainder of the previously linked
article describes. I hope you encounter no more problems; please write
back if you do. Good luck!
 
D

Derrick Coetzee [MSFT]

Ian Lazarus said:
I should have provided an overall description of the project. Here it is. I
have a native DLL class library written in C++ that I wish to make available
to .NET users. I'm trying to write a version of the DLL just for those
users. Following the documentation's suggestion, I wrote a "Managed
Extensions wrapper class". Data marshalling is being done manually.


I will investigate your new problems more thoroughly later, but first let me
say that mixed-mode DLLs such as the one you're writing are notoriously
problematic, due mainly to the Mixed DLL Loading Problem, which you can
learn about here:

http://msdn.microsoft.com/library/d...stechart/html/vcconMixedDLLLoadingProblem.asp

You may be able to save a great deal of trouble by using some other
technique for communicating with your unmanaged code, such as writing a
wrapper in a purely-managed DLL and using PInvoke from it to invoke your
unmanaged DLL's functionality. You can also use IPC or even just have your
clients use PInvoke on your unmanaged DLL.

If you must use mixed-mode, try and arrange that your unmanaged program
doesn't use any global or static data of any kind; if they do this will put
the burden of manual initialization on each of your clients when loading
your DLL.
 
V

vindeep

Ciao Ian Lazarus :) and Friends

Well It's Pradeep, I am also getting the same sequence of errors when I
am building my project ...

It is by the way compiling without any problem.

After following some of the suggestions that I could perform .. Now I
am getting
following :

------ Build started: Project: example, Configuration: Debug Win32
------

Linking...
LINK : error LNK2020: unresolved token (0A000013) std._Lockit.__dtor
LINK : error LNK2020: unresolved token (0A000014) _DebugHeapTag
LINK : error LNK2020: unresolved token (0A000031) legorobot.__dtor
LINK : error LNK2020: unresolved token (0A000054)
?_Id_cnt@id@locale@std@@0HA
LINK : error LNK2020: unresolved token (0A000056) std._Locinfo.__dtor
LINK : error LNK2020: unresolved token (0A000057)
?id@?$ctype@D@std@@2V0locale@2@A
LINK : error LNK2020: unresolved token (0A000058) cin
LINK : error LNK2020: unresolved token (0A000059) cout
LINK : fatal error LNK1120: 8 unresolved externals

Waiting for Someones encouraging response.

-best regards
VinDeep
 
V

vindeep

Ciao Ian :)

At present my Linker -> Command Line Option looks like this

/OUT:"E:\btp_project\example\Debug\example.exe" /INCREMENTAL /NOLOGO
/NODEFAULTLIB /DEBUG /ASSEMBLYDEBUG
/PDB:"E:\btp_project\example\Debug/example.pdb" /FIXED:No LIBCMTD.lib
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib


And I have selected

Ignore All Default Libraries as (Yes/NODEFAULTLIB)

And in Linker Input I have written Additional Dependencies ->
LIBCMTD.lib

Waiting ..for someones response

-best regards
VinDeep
 
V

vindeep

Hi,
I have developed a project in VC++ in which I am accessing a VB DLL.
I have created that dll through following command.

wsdl http://10.2.1.44/WebService1/Service1.asmx /l:vb
/out:service1.vb

vbc /t:library /r:System.dll,System.web.services.dll,System.xml.dll
Service1.vb

Now I am calling a method called HelloWorld from my main module in VC++
as follows ::


int _tmain()
{
Service1 *ob = new Service1();
System::Console::WriteLine("LastName:",ob->HelloWorld());
return 0;
}

Well I am able to build the project without any problem ... but the
String that is supposed to be returned ... nothing appears in console.

What to do now .. Since till now I was getting some errors but now its
a normal execution so .. no idea which side I am doing wrong ....

best regards
VinDeep
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top