-
rand() linker error
I´ve made a new classes library project in c++ .net, in one of the .cpp
I use the rand() function from C, and when I compile, I get the following exception:
error LNK2001: símbolo externo "int __cdecl rand(void)" (?
rand@@$$J0YAHXZ) sin resolver
I include the correct .h and even tried:
extern "C"
{
#include <stdlib.h>
}
but I continue get the same exception...
Thanks ;)
-
try to use <cstdlib> instead. Don't use the enclosing extern "C" block, if it's necessary it should already be in the header itself. Alaos, make sure that your project has the right settings (Console App, unmanaged etc.) and that your files have the right extension, .cpp. Finally, try std::rand() instead of rand().
Danny Kalev
-
I´ve done these changes but I am getting the same exception :confused:
-
check your project settings. make sure default libs are on, etc. It has to be something like that -- rand works in .net, I use it a lot.
If nothing else make a new project and try it using default settings.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks