relocation truncated to fit: R_X86_64_PC32 against undefined symbol

Getting a weird error when running this program and I can't seem to figure out what is going on. This is what the error shows:
/cygdrive/c/Users/brrr/OneDrive/Documents/NetBeansProjects/CppApplication_6/main.cpp:76:(.text+0x1df): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `getTotal(int, int)'

I have gotten this a few times today and it is something I have never seen before.

I am pretty new to this and everything that I have found online seems to be a little bit over my head. Any suggestions help!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
#include <algorithm>

using namespace std;

/*
 * 
 */
//Function prototypes:
void displayMenu();
//int addPoints(int, int, int);
int getTotal(int, int);

int main() {
    //games is how many times I want the loop to run

  //  cout << "How many games did the player play?" << endl;
  //  cin >> games;
//    int gamesPlayed[games] = {0};
    char userSelection;
    string playersName = "";
    
    int rebounds = 0;
    int points = 0;
    int assists = 0;

    //Accumulators to calculate average
    int totalRebounds = 0;
    int totalPoints = 0;
    int totalAssists = 0;

    //variables to hold average
    double averageRebounds = 0;
    double averagePoints = 0;
    double averageAssists = 0;

    
    do {
        int games = 0;
        displayMenu();
        cout << endl;
        cout << "Choose an option from the menu: ";
        cin >> userSelection;
        switch (userSelection) {
                case 'a': cout << "Enter Players Name: " << endl;
                cin >> playersName;
                break;
                case 'b':
                
                cout << "Enter games played" << endl;
                cin >> games;
                if (games > 0)
                {
                    for (int sub = 0; sub < games; sub++)
                    {
                        int gp = sub +1;
                        cout << "Please enter the points amount for game " << gp << ": " << endl;
                        cin >> points;
                
                }
                    getTotal(points, totalPoints);
                }
                        
                break;
                case 'c': cout << "The total points through " << games << " games is: " << totalPoints;
                break;
        }
    }
    while (userSelection != 'e');
    cout << "Good Bye";
    

    return 0;
}
//Display Menu function
void displayMenu()
{
    cout << endl;
    cout << "a. Enter player's name: " << endl;
    cout << "b. Enter player's statistics: " << endl;
    cout << "c. Display player's totals: " << endl;
    cout << "d. Display player's averages: " << endl;
    cout << "e. End program" << endl;
    cout << endl;
}
 addTotal (int amount, int total)
{
    total += amount;
    return total;
}
addTotal on function definition doesn't have a return type. You also didn't create the function prototype.
Last edited on
Your function addTotal at the bottom should be called getTotal, and, as @Hengry points out, should be defined with a return type:
int getTotal( int amount, int total )

Given what it does it seems a rather superfluous function.
Topic archived. No new replies allowed.