Avatar of farrellzzs
farrellzzs

asked on 

error LNK2001: unresolved external symbol "void __cdecl test5(int)

hi there,
Im using the "newran c++ liabrary" which can be download online at http://www.robertnz.net/nr02doc.htm. Its ok when i compile it but when i try to build it, i got the follow errors:

--------------------Configuration: tryrand - Win32 Debug--------------------
Linking...
tryrand.obj : error LNK2001: unresolved external symbol "void __cdecl test5(int)" (?test5@@YAXH@Z)
tryrand.obj : error LNK2001: unresolved external symbol "void __cdecl test4(int)" (?test4@@YAXH@Z)
tryrand.obj : error LNK2001: unresolved external symbol "void __cdecl test3(int)" (?test3@@YAXH@Z)
tryrand.obj : error LNK2001: unresolved external symbol "void __cdecl test2(int)" (?test2@@YAXH@Z)
tryrand.obj : error LNK2001: unresolved external symbol "void __cdecl test1(int)" (?test1@@YAXH@Z)
tryrand.obj : error LNK2001: unresolved external symbol "public: static void __cdecl Random::Set(double)" (?Set@Random@@SAXN@Z)
Debug/tryrand.exe : fatal error LNK1120: 6 unresolved externals
Error executing link.exe.

tryrand.exe - 7 error(s), 0 warning(s)


can anyone helps me out there?Im using vc++ and Im still learning this language, so plz make ur comment easy for me  to understand , many thanks.
C++Programming Languages-Other

Avatar of undefined
Last Comment
Infinity08
Avatar of Infinity08
Infinity08
Flag of Belgium image

You need to add the library to the linker options : go to your project settings, then the linker settings, and add the .lib file there.
Avatar of farrellzzs
farrellzzs

ASKER

Thx for reply, the point is I dont know which .lib file need to be added, there is no .lib files included in the documents.
Avatar of Infinity08
Infinity08
Flag of Belgium image

Ah, apparently it's not
Avatar of Infinity08
Infinity08
Flag of Belgium image

Ah, apparently it's not a proper library. This is from their docs :

"You will need to compile newran.cpp, myexcept.cpp and extreal.cpp and link the resulting object files to your programs. Your source files which access newran will need to have newran.h as an include file."

So, do exactly that : include the mentioned.cpp and .h files in your project, and rebuild all.
Avatar of farrellzzs
farrellzzs

ASKER

I did what you said, include all the three .cpps and those .hs in the project, rebuild it, then got the follow errors:

--------------------Configuration: tryrand - Win32 Debug--------------------
Compiling...
tryrand.cpp
h:\newran02\myexcept.cpp(68) : error C2065: 'strlen' : undeclared identifier
h:\newran02\myexcept.cpp(69) : error C2065: 'strcpy' : undeclared identifier
h:\newran02\myexcept.cpp(72) : error C2065: 'strncpy' : undeclared identifier
h:\newran02\newran.cpp(351) : error C2065: 'fabs' : undeclared identifier
h:\newran02\newran.cpp(351) : error C2065: 'exp' : undeclared identifier
h:\newran02\newran.cpp(354) : error C2065: 'sqrt' : undeclared identifier
h:\newran02\newran.cpp(397) : error C2065: 'pow' : undeclared identifier
h:\newran02\newran.cpp(415) : error C2065: 'log' : undeclared identifier
h:\newran02\newran.cpp(420) : error C2065: 'floor' : undeclared identifier
h:\newran02\newran.cpp(607) : error C2065: 'sin' : undeclared identifier
extreal.cpp
myexcept.cpp
newran.cpp
Error executing cl.exe.

tryrand.exe - 10 error(s), 0 warning(s)

thx for ur help so far, but plz help me fix this as well..
Avatar of farrellzzs
farrellzzs

ASKER

wait a sec.....i include math.h and string.h in the project and the above problem is gone, instead,

--------------------Configuration: tryrand - Win32 Debug--------------------
Linking...
extreal.obj : error LNK2005: "public: class ExtReal __thiscall ExtReal::operator+(class ExtReal const &)const " (??HExtReal@@QBE?AV0@ABV0@@Z) already defined in tryrand.obj
extreal.obj : error LNK2005: "public: class ExtReal __thiscall ExtReal::operator-(class ExtReal const &)const " (??GExtReal@@QBE?AV0@ABV0@@Z) already defined in tryrand.obj
extreal.obj : error LNK2005: "public: class ExtReal __thiscall ExtReal::operator*(class ExtReal const &)const " (??DExtReal@@QBE?AV0@ABV0@@Z) already defined in tryrand.obj
extreal.obj : error LNK2005: "public: class ExtReal __thiscall ExtReal::operator-(void)const " (??GExtReal@@QBE?AV0@XZ) already defined in tryrand.obj
extreal.obj : error LNK2005: "class ostream & __cdecl operator<<(class ostream &,class ExtReal const &)" (??6@YAAAVostream@@AAV0@ABVExtReal@@@Z) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: __thiscall Exception::Exception(char const *)" (??0Exception@@QAE@PBD@Z) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: static void __cdecl Exception::AddMessage(char const *)" (?AddMessage@Exception@@SAXPBD@Z) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: static void __cdecl Exception::AddInt(int)" (?AddInt@Exception@@SAXH@Z) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: static void __cdecl Tracer::PrintTrace(void)" (?PrintTrace@Tracer@@SAXXZ) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: static void __cdecl Tracer::AddTrace(void)" (?AddTrace@Tracer@@SAXXZ) already defined in tryrand.obj
myexcept.obj : error LNK2005: "void __cdecl Terminate(void)" (?Terminate@@YAXXZ) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: __thiscall Logic_error::Logic_error(char const *)" (??0Logic_error@@QAE@PBD@Z) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: __thiscall Runtime_error::Runtime_error(char const *)" (??0Runtime_error@@QAE@PBD@Z) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: __thiscall Domain_error::Domain_error(char const *)" (??0Domain_error@@QAE@PBD@Z) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: __thiscall Invalid_argument::Invalid_argument(char const *)" (??0Invalid_argument@@QAE@PBD@Z) already defined in tryrand.obj
myexcept.obj : error LNK2005: "public: __thiscall Length_error::Length_error(char const *)" (??0Length_error@@QAE@PBD@Z) already defined in tryrand.obj

tryrand.exe - 193 error(s), 0 warning(s)

another 193 errors comes out.....
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of farrellzzs
farrellzzs

ASKER

I did what u said and the errors are all gone, except when I excute the program , a window pops up and says "debug error: abnormal program termination".....but anyway, thx for your help infinity08 :)
Avatar of Infinity08
Infinity08
Flag of Belgium image

>> a window pops up and says "debug error: abnormal program termination"

That's an error in the code. Either the library contains a bug, or your code does.
C++
C++

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

58K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo