Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


can someone tell me where this comes from?

Posted on 2003-03-30
Medium Priority
Last Modified: 2011-10-03
error LNK2001: unresolved external symbol "int __cdecl Rand(void)" (?Rand@@YAHXZ)
i would like to know the nature of this error and how to go about it. don't have to be specific but what causes this error. i seem to have a few of them. thanks!
Question by:kencj

Expert Comment

ID: 8236616
typically this problem occurs whe you are missing or you aren't linking in the proper libraries (.lib) during your creation of the executable.  In your case, it seems you are failing to link a pretty standard library.

Accepted Solution

Francoz earned 90 total points
ID: 8236638
Probably you might've declared a function prototype but not implemented elsewhere. For example, in the .h file you've one declaration as follows.

int fun(float b);

But this function is not implemented anywhere and so doesnt've a body. But in some other .cpp file you're trying to access this function as


The linker will generate an error at this point because it couldnt find an apporpriate func body.

Check out the below link to get more information, if you've msdn access.


Expert Comment

ID: 8236932
The problem occurs when you are linking with imrpoper lib. Try compiling the same program in a diff m/c. If it gets compiled there , whithout linking errors,then the lib files in your disk might be corrupted. Are you using MSDEV environment for this pgm? If so verify whether you have proper Service Pack installed or not.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 12

Expert Comment

ID: 8237165
My guess is that you have had a mispelling somewhere...

You have declared:

int Rand();

but never linked in any file that defines that function. It is possible you really meant:

int rand();

which is a standard C library function. Note that casing IS significant in C++ and C, so rand() and Rand() are two different names.


Expert Comment

ID: 8237170
It's possible that you've declared a function but delete it and fogot to delete the function prototype in the *.H file just be carefull whar you delete and how becouse it can (Edited by Computer101) up the whole program
greets Captnoord

Author Comment

ID: 8238426
yeap. that was my problem. thanks

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question