LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
I am developing a Managed class that is a wrapper for other unmanaged classes that uses the old C++ libraries: <math.h>, <stdio.h>,<string.h>, <stdlib.h>.
My little project compiles all right, but I get this LINK error:
Quote:
LNK2020: unresolved token (0A000019) ??_7type_info@@6B@
I did not link this files (<math.h>, <stdio.h>,…). Do I need to do this? If I need, how I can do that?
Thanks in advance.
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
If this appears you do not have RTTI enabled. Please do so in the Compiler Options in your project properties.
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
Thank you very much NoHero.
I did what you said.
I did not say before, I am developing a C++.Net Template. C++ Managed Wraaper to wrapp unmanaged code.
I had lots of LNK2019 errors and then, I ´ve applied some instructions of Microsoft: http://www.support.microsoft.com/?sc...d=2990&sid=149. Now, most of these errors have gone. But I still have link errors. Like that:
Quote:
error LNK2019: unresolved external symbol _strupr and error LNK2019: unresolved external symbol _hypot. error LNK2001: unresolved external symbol _hypot .
Why I get these errors? Why Microsoft C++ .NET 2003 could not link properly the standard libraries <math.h>, <string.h> ???
Thanks a lot.
Eliseu.
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
Then you forgot to link the libraries of the default C library inside your application.
Project Properties -> Linker -> Input -> Additional Libraries -> And add msvcrt.lib for release version and msvcrtd.lib for debug version.
These libraries may also have a version suffix. Like msvcrt80.lib or something like that. I am not quite sure though, better you look them up in your Visual Studion installation directory -> VCX (X is the version number you are using) -> Libs.
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
NoHero, I did what you wrote me. But the linking process stills having the same errors:
Quote:
Basicas.obj : error LNK2019: unresolved external symbol _strupr referenced in function "void __cdecl LatsGMSt2sGMS(char *,int &,int &,int &,double &)" (?LatsGMSt2sGMS@@YAXPADAAH11AAN@Z)
Basicas.obj : error LNK2019: unresolved external symbol _hypot referenced in function "double __cdecl AnguloPP2(double,double,double,double)" (?AnguloPP2@@YANNNNN@Z)
Tmgeod.obj : error LNK2001: unresolved external symbol _hypot
I did not find other versions for msvcrtd.lib in VC7\lib. Just this.
Interesting that I am using others funcions from <math.h>, <string.h>, <stdio.h> and <stdlib.h> and is ok on the linking. Do you have any idea about why some funcionts are linked and others not?
Thanks for your help.
1 Attachment(s)
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
Firstly, which version of DevStudio are you using ? There are two now : 2003 and 2005, although it shouldn't really be a problem unless you're using the Beta for 2005. Even then this shouldn't happen, but this is to just narrow things down.
Anyway, I'm including a VC++.NET (DevStudio 2003) project which does just what you're having problems with. It's a console application, created from the wizards.
And the code is in the source folder in solution explorer, CodeGuruTemp1.cpp.
I hope it helps.
Darwen.
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
All these functions above are within the Microsoft C Runtime, but not ANSI standard. Here is another resource on this C Runtime. Also be sure your source files using these functions are compiled as unmanaged.
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
Thanks Guys.
I really apreciate your help. I am not on the office now. I will come back on MOnday and I will test your sugestion. Yes NOHero, I was looking this table of LIBs today but I did not have time to test them yet.
By the way, I am using Visual Studio 2003.
I wish a fantastic happy new year to U.
Take care.
Re: LINK error: LNK2020 - Use of MSVCP71.DLL
NoHero, on that link there is this option
Quote:
MSVCRT.LIB Multithreaded, dynamic link (import library for MSVCR71.DLL). Be aware that if you use the Standard C++ Library, your program will need MSVCP71.DLL to run. /MD _MT, _DLL
It says:
Quote:
your program will need MSVCP71.DLL to run.
What does it means:
Quote:
Any application built with Visual C++ .NET using the /MD switch will necessarily use msvcr71.dll.
Do I need to do something about MSVCP71.DLL??? Do I need to include this someway? I ´ve tried several options to include this but is not possible. Than I think it is enough to have this file on Visual Studio Libraries...
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
Thanks for your help Darwen. Ive´run your project. It´s worked.
I just do not understand why i needed to change strupr(x) to
_strupr(x), or hypot for _hypot???
Do you have a clue about this?
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
I just read your report and it was reporting errors for _hypot et al. Actually you can remove the underscore from the start and it still works fine.
Darwen.
Re: LINK error: LNK2020 - Should I link the unmanaged libraries <math.h>, <stdio.h> ?
But for my project i get link errors if I do not use _hypot _strupr. Just for these 2. For anothers functions, I do not need to use underscore.
I ´ve put my project. See it in Basicas.cpp and TMGEOD.cpp these 2 functions.
Thank U very much.