C++ :: In Function Main Undefined Reference Error

Apr 19, 2012

Why I keep getting the error: "In function main: [linker error] undefined reference to readBook(BookData)" ....

main.cpp :

Code:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
#include "BookData.h"
// FUNCTION PROTOTYPES:
void bookInfo(BookData);
void readBook(BookData& book1);

[Code] ....

View 9 Replies


ADVERTISEMENT

C++ :: Undefined Reference To Function Error

Nov 19, 2013

I am currently working on a code, but I keep getting a error as follows:

[Linker error] undefined reference to 'getHoursOfTheWeek(double)'
[Linker error] undefined reference to 'getGrossPay(double)'
[Linker error] undefined reference to 'getStateTax(double)'
[Linker error] undefined reference to 'getFederalTax(double)'
[Linker error] undefined reference to 'getFICA(double)'
[Linker error] undefined reference to 'getWithHoldingAmount(double)'

I have been trying to debug this error for hours and I am completely stumped....

//BEGIN
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
string getUserName();
double getPayRate();

[Code] .....

View 2 Replies View Related

C/C++ :: Getting Undefined Reference Error To A Function

Mar 16, 2015

I'm getting an undefined reference error to a function, and I can't figure out why. I have tried letting code blocks compile the files, I have tried the command line to compile it with the same results.

I looked up the error and found this from [URL]

undefined reference
Example
/tmp/cc2Q0kRa.o: In function `main':
/tmp/cc2Q0kRa.o(.text+0x18): undefined reference to `Print(int)'
collect2: ld returned 1 exit status

Meaning / Your code called the function Print, but the linker could not find the code for it in any .o file

Usual Causes

You forgot to link the .o file that contains the function

You misspelled the name of the function

You spelled the name of the function correctly, but the parameter list is different in someway

which seems to be the error I get. I have double checked all 4 and I see nothing.

The code that specifically gives me the error is:

Item *name = new Item(desc, id, weight, loc);
itemMap.addItem(name);

and the class looks like this:

class Item // Standard Items {
private:
std::string name;
std::string desc;
int id;
int weight;
int loc;

[code].....

I think everything matches up unless I'm just missing it.

Full codes are located here: [URL]

what I'm doing wrong?

View 5 Replies View Related

C++ :: Undefined Reference Error When Accessing Static Variable Inside Member Function

Feb 10, 2013

I am modifying a set of static variables inside of the class's member function. The static variables are private. An example of what I'm doing is as below,

utilities.h
-----------
class utilities {
private:
static int num_nodes;

public:
void parse_details(char* );

[Code] ....

I get a compilation error in the function void utilities::parse_details(char* filename)

which says: undefined reference to `utilities::num_nodes'

compiler: g++

View 2 Replies View Related

C++ :: Error - Undefined Reference To PrintSpecChar (int)

Apr 2, 2013

I just purchased a laptop with Windows 8 and installed the portable Dev-C++ because the other one wasnt compatible with Win8.

Now im getting an error when i compile that says:

'undefined reference to 'printSpecChar(int)

when i was using Dev-C++ on Win7, i never had to use #include <stdlib.h> for system ("pause") but now I do.

Is there a setting that I need to change, or am I just missing something.....again?

Code:
#include <stdlib.h>
#include <iostream>
using namespace std;
int getNumber(int, int);
void printSpecChar(int);
void pause (double);
int main() {
int n;

[code]....

View 6 Replies View Related

C++ :: Undefined Reference To A Function

Jan 19, 2013

The error is this:

#include <iostream>
using namespace std;
void add(int s);
void subtract(int d);
void multiply(int p);
void divide(int q);

[Code] .....

View 2 Replies View Related

C++ :: Undefined Reference To A Function?

Nov 23, 2013

I'm making a program that's essentially a Text-Based Fire Emblem game; it runs calculations and rolls dice and has all sorts of Goodies. However, I have hit a block to the tune of

#ifndef ITEM_H
#define ITEM_H
class Item
{

[Code]....

Up Until I called up a Sword object, it worked fine. But when I compiled it, I got an Undefined Reference to Item::Item() error in Line 8 of Weapon.cpp.

View 2 Replies View Related

C++ :: Undefined Reference To (function Name)

Oct 2, 2014

Everything seems to be in order and I know my code still has mistakes. I'm just trying to get it to compile and it won't allow it. I've narrowed it down to when I call the functions in main but beyond that I have no clue.

#include <iostream>
#include <cstring>
using namespace std;
void getSize(int num);
void getSpace(int num, int ptr);
void inputData();
void printData();
void destroy();
const int BIG_NUMBER = 100;

[code]....

View 4 Replies View Related

C++ :: Undefined Reference To Function?

Oct 24, 2013

So I have a really strange problem occurring...

First, here are the files I'm using:

//pa4.cpp wirtten by Syd Frederick
#include<iostream>
#include<string>
#include<fstream>

[Code].....

When compiling I'm getting a strange error that says :

/tmp/ccdt0Bf9.o: In function `main':
pa4.cpp:(.text+0x1c): undefined reference to `synopsis()'
pa4.cpp:(.text+0x1e7): undefined reference to `execute(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: ld returned 1 exit status

View 2 Replies View Related

C++ :: Undefined Reference To Template Function

Oct 21, 2013

I am coding a RTS game but I cant compile my dataLoader function. It gives that errors when want to call it:

//Window size
int width;
int height;
if( !dataLoader<int>( width, "settings/resolution.txt", "width" ) || !dataLoader<int>( height, "settings/resolution.txt", "height" ) )

[Code] ....

View 7 Replies View Related

C++ :: Tile Based RPG - Undefined Reference To Class Function

Mar 13, 2014

I'm making a simple tile-based RPG and I've run into a bit of trouble when I put my code into classes.

Heres my main

#include <iostream>
#include "windows.h"
#include "math.h"
#include "time.h"
#include <string>
#include "Goblin.h"
#include "User.h"
#include "Inventory.h"
#include "Maps.h"
using namespace std;
void treasureGet();

[Code] ....

My other 3 classes have the same structure and the same error for all their functions.

This is the exact Error

undefined reference to `Goblin::goblinBattle()'|
undefined reference to `Goblin::goblinBattle()'|
undefined reference to `Goblin::goblinBattle()'|
undefined reference to `Goblin::goblinBattle()'|
undefined reference to `Inventory::inventoryOpen()'|
undefined reference to `Goblin::Goblin()'|
undefined reference to `User::User()'|
undefined reference to `Inventory::Inventory()'|
undefined reference to `Maps::Maps()'|
||=== Build finished: 9 errors, 29 warnings (0 minutes, 0 seconds) ===|

View 4 Replies View Related

C++ :: Undefined Reference To Push (int)

Apr 20, 2013

The problem with the code is on line 14 and says undefined reference to `push(int)

Code:
#include<iostream>
using namespace std;
void push(int n);
int pop(int &n);
struct elem{
int key;

[Code]...

View 2 Replies View Related

C++ :: Undefined Reference To Memcpy?

Apr 26, 2012

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/libstdc++.so: undefined reference to `memcpy@GLIBC_2.14'

Why is this happening and how do I fix it? I installed g++ with rpms, and all of the dependencies were handled.

glibc-headers-2.5-34
glibc-devel-2.5-34
libstdc++-devel-4.1.2-44
gcc-4.1.2-44
gcc-c++-4.1.2-44

I don't understand how memcpy can't be there, it's been standard for 40 years. And I'm not using memcpy in my code, it's likely coming from one of the STL containers I use.

View 7 Replies View Related

C++ :: Undefined Reference To Default Constructor?

Jul 28, 2013

trying to practice the object-oriented part of it by converting my java programs into c++. I believe I understand the concepts of a header file and declaring the functions in the .cpp files. I keep getting this "Undefined reference to NamedStorm::NamedStorm()" error.

NamedStorm.h
#ifndef NAMEDSTORM_H
#define NAMEDSTORM_H
#include <string>
#include <iostream>
// NEVER use using namespce in header, use std instead.
using std::string;

[code]....

View 7 Replies View Related

C++ :: Undefined Reference To Class Definition

Aug 4, 2013

I have successfully built OGDF under directory undefined reference to /home/vijay13/Downloads/OGDF-snapshot/

I have following code in test.cpp under directory /home/vijay13/Downloads/ :

#include <ogdf/basic/Graph.h>
#include <ogdf/fileformats/GraphIO.h>
#include <ogdf/basic/graph_generators.h>
#include <ogdf/layered/DfsAcyclicSubgraph.h>
using namespace ogdf;

[Code] .....

while compiling as following :

vijay13@ubuntu:~/Downloads$ g++ -o test test.cpp -I /home/vijay13/Downloads/OGDF-snapshot/include/

I am getting following error:

vijay13@ubuntu:~/Downloads$ g++ -o test test.cpp -I /home/vijay13/Downloads/OGDF-snapshot/include/
/tmp/ccPE8nCu.o: In function `main':
test.cpp:(.text+0x26): undefined reference to `ogdf::Graph::Graph()' ...................... so on

View 2 Replies View Related

C/C++ :: Undefined Reference On Declaration Part

Jan 29, 2015

I can't run my program. I have undefined reference on the declaration part , where is the error here :

#include <iostream>
using namespace std;
#define T_TABLEAU 5 //change la taille tableau ici
void TableauEntre(int* tab,int n);
void QuickSort(int* tab,int IndexPrem,int IndexFin);
int Partition(int* tab,int pivot,int IndexPrem,int IndexFin);

[Code] ....

View 11 Replies View Related

C++ :: Inherited Class Constructor - Undefined Reference

Jun 18, 2013

I have three classes 1 base and two inherited.. problem is when I try to initialize the it says undefined reference to vtable constructor.

Code:
#ifndef QUOTE_H_INCLUDED
#define QUOTE_H_INCLUDED
#include <string>
using namespace std;

[Code] ....

View 2 Replies View Related

C :: Undefined Reference To Set Console Cursor Position

Apr 8, 2013

Every time I compile this in codeblocks one error comes out. It said that "undefined reference to 'SetConsoleCursorPosition'".

Code:
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<windows.h>

[Code] .....

View 2 Replies View Related

C++ :: Undefined Reference With Mingw (template Usage)

Apr 10, 2014

I am wondering why ToStr throws me this error. I am using mingw64 and codeblocks.

Code:

E:JackyDocumentsCode Blocks ProjectsPerfectSimXmain.cpp|35|undefined reference to `std::string ToStr<int>(int const&)'|

Code:
for (int i = 0; i < NO_CAMS; i++) {
std::string filename("E:/Jacky/Documents/Code Blocks Projects/PerfectSimX/Data/Cam");
std::string restFileName(".cam");
filename += ToStr(i);

[Code] ....

View 4 Replies View Related

C/C++ :: Missing Terminating Character And Int Main Function Error

Oct 6, 2014

I am suppose to make a program that when the user is asked "Enter a Letter for the day:" if the user enters M or m then the screen will output "The day of the week is Monday" and so on until Sunday. I looked over my code and everything looks right but I still get errors saying Missing terminating character " and int function main error.
 
#include <iostream>  
using namespace std;  
int main() {      
    char day;  
    cout << "Enter a letter for a day of the week: ";

[code]....

View 1 Replies View Related

C++ :: Undefined Reference To Header Functions For Hardware Programming

Jul 7, 2014

I am looking to program a digital to analog converter to output voltage on 12 of the available analog channels. I am an novice-intermediate programmer but cannot seem to solve a problem with undefined references.

I downloaded Measurement Computing's "DAQ" and "Instacal" programs to allow for the USB-3105 board to be recognized. Included with instillation is the Universal Library example programs for the USB-3105 DAC.

I am running windows 7 and using Code::Blocks with a GNU GCC compiler to try and run this sample program on the board. The program is also written in C/C++

When I load the VOut01.C file from the examples it reads:

/*VOut01.C****************************************************************

File: VOut01.C

Library Call Demonstrated: cbVOut()

Purpose: Writes to a D/A Output Channel.

Demonstration: Sends a digital output to D/A 0 until a key is pressed.

Other Library Calls: cbErrHandling()
cbFromEngUnits()

Special Requirements: Board 0 must have a D/A output port.

/* Include files */
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "..cbw.h"

[Code] ....

Afterwards all three functions are declared as:

int EXTCCONV cbDeclareRevision(float *RevNum);
int EXTCCONV cbErrHandling (int ErrReporting, int ErrHandling);
int EXTCCONV cbVOut (int BoardNum, int Chan, int Gain, float DataValue, int Options);

The program Instacal in combination with the header file is supposed to recognize the "BoardNum" and allows for the "int Chan", "int Gain", "float DataValue", and all other subsequent dependent variables to exist.

However, I am still retaining these undefined reference errors even when I used Instacal to define the variables of the board (BoardNum, int Chan, ...ect) and added the full location of the header file.

My questions are:

-Why is this section of the header file dimmed after the endif statements?
-Is this reference problem a problem with the header files directory?
-Do the declarations of the function in the header file prevent them from being access due to their names and or symbolism?
-Why are the reference errors @4, @8, or @20, and what does this mean?

View 1 Replies View Related

C++ :: Error Returning By Reference From Function

May 14, 2012

struct emp {
char name[20];
int age;
float sal;
}e1 = {"hello", 24, 2345.67}, e2 = {"hi", 34, 45678.89};

[Code] ....

Query: I am unable to get emp &fun() and fun() = e2...

View 3 Replies View Related

C/C++ :: Display Contents Of Binary Tree In Per-level Format - Undefined Reference

Oct 5, 2014

I am coding in C++ an implementation of BTree Insertion. I want to display the contents of the Tree in a per-level format. After writing functions and trying to run. I get the error Undefined reference.

// C++ program for B-Tree insertion
#include<iostream>
using namespace std;

// A BTree node
class BTreeNode{
int *keys; // An array of keys
int order; // Minimum degree (defines the range for number of keys)
BTreeNode **child; // An array of child pointers
int size; // Current number of keys

[Code] .....

View 6 Replies View Related

C++ :: Error - Reference To Non Static Function Must Be Called?

Feb 27, 2013

So on lines 36 - 39 (The commented out functions) is where I'm sure is causing this error because once I don't comment them out pretty much everywhere Flink or Rlink is used or defined I get this error.

#ifndef nodes_Nodes_h
#define nodes_Nodes_h
#include <cstdlib>

[Code]....

View 4 Replies View Related

C++ :: Main Difference Between Pointer And Reference And How To Use Pointers

Mar 9, 2013

i'm still unclear between the difference between using pointer and a reference

I understood the concept of pointers in c in the class i took last year

and that was to change the actual value stored in the memory address Code:

void change_a(int a*){
a=6;
}
int main(){
int a=5;
change_a(&a);
}

but in c++ I've been using references in all my assignments because I don't know how to correctly use pointers in c++ I may have missed a class but I'm on spring break and would like to clear things up

so in c++

in my assignments I would call it like this Code:

void change_a(int &a){
a=6;
}
int main(){
int a=5;
change_a(a);
}

so does this change the value in the address or does it make another copy of a in my c++ code and stores 6 in that copy

View 2 Replies View Related

C++ :: Error - Identifier Result Is Undefined

Mar 6, 2013

I have some code does not compile. I think it's missing an included library, but not sure.

In the int main() block of code, the following three items give errors:

1. Mtrx (the one following "new") - Error: expected a type specifier
2. result - Error: expected a ";"
3. &result - identifier "result" is undefined

Below is the code with the head to show you what has been included:

HTML Code:
#include <iostream>
#include <iomanip>
using namespace std;
#include <limits.h>
// create the structure of the matrix
struct Mtrx {
int numRows;
int numCols;
float array[101][101];

[code]....

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved