473,503 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Free function compiling error

1 New Member
Error:

Expand|Select|Wrap|Line Numbers
  1. Undefined                       first referenced
  2.  symbol                             in file
  3. die()                               /var/tmp//cckddR2X.o
  4. ld: fatal: symbol referencing errors. No output written to a.out
  5. collect2: ld returned 1 exit status
  6.  
This is my die.cpp:

Expand|Select|Wrap|Line Numbers
  1. #include <math.h>
  2. #include <string>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <time.h>
  8. #include "die.h"
  9.  
  10.  
  11.  
  12. int die(){
  13.  
  14.         srand (time(NULL));
  15.         int number = rand() % 6 + 1;
  16.  
  17.         return number;
  18.  
  19. }
  20.  
This is my die.h:

Expand|Select|Wrap|Line Numbers
  1. #ifndef __DIE_H
  2. #define __DIE_H
  3.  
  4.  
  5. int die();
  6.  
  7.  
  8. #endif
  9.  
I'm not sure what I'm doing wrong. Did I leave something out of my .h file? Any feedback is appreciated.
Sep 30 '11 #1
2 1559
johny10151981
1,059 Top Contributor
your code is fine. what is your compilation command???

i mean
Expand|Select|Wrap|Line Numbers
  1. #g++ -c die.cpp -o die
  2.  
if it is not then, you are getting error because you dont have define main function
Oct 1 '11 #2
donbock
2,426 Recognized Expert Top Contributor
I don't know that this has anything to do with your link error, but I believe you should be including <cmath> instead of <math.h>, <cstdio> instead of <stdio.h>, <cstdlib> instead of <stdlib.h>, and <ctime> instead of <time.h>.

This doesn't have anything to do with your link error, but I believe you should say "int die(void)" instead of "int die()" in die.h and die.cpp.

I doubt this has anything to do with your error, but you should not get in the habit of using names with leading underscores (__DIE_H). The C Standard (and perhaps the C++ Standard) reserves all such names for use by behind-the-scenes compiler internals. Change this name to something like DIE__H.

You might verify that "die" isn't a reserved word or name by changing all instances of "die" in die.h and die.cpp to something else, perhaps "xxdie" and confirm that the error still occurs. No need to change the file names.
Oct 1 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
6707
by: Shilpa | last post by:
We are using Java Stored Procs to pull data from application DB2 tables and the final output is written to a file. Stored Procs are structured as mentioned below: There is a driver table from...
2
12867
by: PA | last post by:
Hi All, Thanks for your attention..I appreciate that. -----Problem description -----------Start---------------------- Database : DB2 UDB 8.2 on Windows 2003 Client: VB6/ADO 2.7 on Windows...
0
1138
by: nagaraj_hayyal | last post by:
hi all, i am a c++ developer facing a problem with DB2-CLI on AIX5.2. we are using db2 v8 fixpak 10, gcc 3.3.2, on aix5.2 with extensive use of STL vectors. we are using ODBC 3.0 for our...
6
2717
by: bmwrob | last post by:
I’m very new in C++ programming and am trying to make a decoder tool just for the purpose of learning. I started my project in VC++ 6.0, but after a change of PC, I continued my programming in VS...
2
7250
by: tommydkat | last post by:
Hi! I'm updating a Windows application that we develop that uses a DB2 database. We switched from using Microsoft Developer Studio 6 to Visual Studio .Net 2003 to build our app and since that...
13
2453
by: a.zeevi | last post by:
free() multiple allocation error in C ==================================== Hi! I have written a program in C on PC with Windows 2000 in a Visual C environment. I have an error in freeing...
0
1099
by: mjm | last post by:
Hi, My script errors when compiling with: SCRIPT: Compiling Error => Line 59 : Expected statement (-2146827264) 'Variables available on this screen can be declared and initialized here. Dim...
4
4420
by: Racerx | last post by:
Hi All: I use db2 v8.1 AIX 5.2 Today we recieved an error at the use machine (db2 client) while loggin into one of the applications. The details of the error message are: CLI0125E...
4
10054
by: Szymon Dembek | last post by:
Hi Recently I did some DB2 and ODBC coding in Visual FoxPro. I bumped on a problem I cannot resolve. When I issue a delete statement that deletes no rows (no rows qualify for the WHERE...
10
1486
by: JRough | last post by:
I have a function definition error: Warning: Missing argument 2 for makexcldata(), called on line 123 and defined in on line 149 "Warning: mysql_fetch_row(): supplied argument is not a valid...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.