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:
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:
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> ???
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:
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?
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.
Last edited by darwen; December 29th, 2005 at 05:48 PM.
www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.
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.
Last edited by Eliseu_CEL; December 29th, 2005 at 09:00 PM.
Reason: mistakes of English
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:
your program will need MSVCP71.DLL to run.
What does it means:
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...
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.