473,568 Members | 2,939 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 1560
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
6712
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 which records are extracted and then for each of this record,subsequently, few other transaction tables are queried and finally the record is written...
2
12870
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 2003 1) I am opening a ADO 2.7 recordset with following settings
0
1139
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 applications. the exception we are getting is "function sequence error cli0125E". we are using multithreaded applications which uses pthread library. with...
6
2726
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 .NET. Now I get a lot of compiling error which I don’t understand. Here is an extract from the code: int iOct; CString sASCII;
2
7260
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 switch, we've been getting a function sequence error with this SQLSTATE: State:S1010,Native:0,Origin: Here is a sample query we're running that...
13
2460
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 multiple allocation as follows: 1. I allocated an array of pointer. 2. I Read line by line from a text file. 3. I allocated memory for the read line.
0
1100
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 i Dim j
4
4425
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 Function Sequence Error.SLQSTATE=S1010.
4
10062
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 conditions), DB2 raises SQL0100W warning with SQLSTATE=02000. The same happens when issuing an insert with select clause (insert into .... select from...
10
1503
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 MySQL result resource on line 157" This is the function call on line 123: $data .= makexcldata($str1); Line 157 is the first line of the While...
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6275
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
932
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.