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


ADVERTISEMENT

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++ :: 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 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++ :: 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++ :: 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 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++ :: Tile Based Game Display

Apr 10, 2013

I have been writing a fairly simple turn based rpg game in c++ and at the moment it has a 2d integer array for the map, which I can display using periods for the blank areas and letters for the various people in the game, and I am trying to figure out how to upgrade to a tile based display.

View 3 Replies View Related

C++ :: SDL - Tile Based Collision Detection

Oct 14, 2014

I'm still working on my Project and the next Problem has occured: How do I detect collisions on a tilebased map? My tiles are 16x16 and the map is based on the tutorial of [URL] ..... I really like this Approach because I can define for each tile of what type it should be (so a earth tile can be walkable and lead to a secret passage).

The first Number stands for what Kind of tile it should be (e.g. Grass, Earth, Water, Blank,...) and the number after ":" stands for the type of the tile (e.g. solid, walkable, do dmg to the Player,...).

e.g.
0:0 0:0 0:0 0:0 0:0 //No tile and walkable
0:0 0:0 0:0 0:0 0:0
0:0 0:0 0:0 0:0 0:0
1:1 1:1 1:1 1:1 1:1 //Grass tile and solid
2:1 2:1 2:1 2:1 2:1 //Earth tile and solid

It's working just fine with loading the Images, but i've got no clue about the collision. I've already read a lot of stuff on the Internet but I don't get how to Combine it the structure from above. For example lazyfoo describes the collision with one object like one wall. So how can I check the Player Position with each tile?

For now there's no camera, but I plan to implement one later...

I'm trying to make a 2D platformer

View 5 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/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++ :: 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 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++ :: 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/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++ :: Templatizing A Function Based On Class Member?

Mar 26, 2014

Some background: I have a class, A, with members, B and C and D; I also have an array of A objects; I want to be able to have a function which takes said array and performs a certain calculation on either the B, C, or D members of each of the A objects, depending upon certain circumstances; I want to perform the same calculation regardless of which member is to be used in said calculation, such as always assigning the value 3 or multiplying the member's value by a cofactor of some sort.

My question, therefore, is: how I might do this using only one function be it a template or not?

View 1 Replies View Related

C++ :: Display Fraction In Proper From Based On 2 Arguments Passed To Class Member Function

Mar 15, 2015

We're assigned a project working with classes and fractions. My goal is to display a fraction in proper from based on 2 arguments passed to a class member function proper();

My strategy was to utilize the greatest common factor between the 2 arguements, then divide both the numerator and denominator by that number and then it would display.

The program actually runs, but only seems to divide the numerator and not the denominator. This in return makes my other class member functions have incorrect comparisons and sums.

Code:
#include<iostream>
#include<conio.h>
class Fraction {
friend void compare(Fraction a, Fraction b);
friend void sum(Fraction a, Fraction b);

[Code] ....

View 14 Replies View Related

C++ :: Undefined Reference To (method Name) When Accessing Method In Static Library

Jan 17, 2013

I've been trying for more than one month to access a method found in a library called libcocosnas_static.a. I'm using Cocos2d-X version 2.0.4. The library has been used many times by my company to make games using cocos2d-1.0.1-x-0.12.0 without any problem.

This is what I've done:
1- I added the include paths of the library to both eclipse and Android.mk
2- Included the .h file using #include "NASPlatformUtil.h"
3- Added the libcocosnas_static.a file to the proj.androidobjlocalarmeabi folder
4- Added "LOCAL_WHOLE_STATIC_LIBRARIES += cocosnas_static" to the Android.mk file
5- Called the function using: NASPlatformUtil:: openUrl("http://xxx.xxx.com/");

I can right click on the function, click Open Declaration and get it without any problem, but the compiler keeps on giving me that dreaded error...

View 3 Replies View Related







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