2 Replies - 586 Views - Last Post: 01 December 2010 - 03:13 PM Rate Topic: -----

#1 lunixer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 120
  • Joined: 29-January 10

Compiler error: /tmp/ccAKV0Q4.o: In function `encryption(std::basic_st

Posted 01 December 2010 - 02:57 PM

Hello. I am getting this compiler error:

/tmp/ccAKV0Q4.o: In function `encryption(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
encryption.cpp:(.text+0xcd6): undefined reference to `getcipher(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int (*) [3])'
collect2: ld returned 1 exit status



When I try to compile this code:

Anybody know why?

#include "encryption.h"
#include<iostream>
using namespace std;

string encryption(string toencrypt)
{
	for(int i=0;i<(Array_size-toencrypt.length()%Array_size);i++)
	{
		toencrypt=toencrypt+" ";
	}
	int cipher[Array_size][Array_size];
	string ciphercode="";
	getcipher(ciphercode, cipher);
	string encrypted=ciphercode;
	while(toencrypt.length()>0)
	{
		string unit_encrypt=toencrypt.substr(0,Array_size);
		toencrypt.erase(0,Array_size);
		int tomultiply[Array_size];
		for(int i=0;i<Array_size;i++)
		{
			tomultiply[i]=int(unit_encrypt.c_str()[0]);
			unit_encrypt.erase(0,1);
		}
		for(int i=0;i<Array_size;i++)
		{
			int resultchar=0;
			for(int j=0;j<Array_size;j++)
			{
				resultchar+=tomultiply[j]*cipher[i][j];	
			}
			encrypted+=char((resultchar%229)-26);
		}
	}
	return encrypted;
}

string decryption(string todecrypt)
{
	int cipher[Array_size][Array_size];
	string ciphercode=todecrypt.substr(0,3);
	todecrypt.erase(0,3);
	decodecipher(ciphercode,cipher);
	string decrypted="";
	while(todecrypt.length()>0)
	{
		string unit_decrypt=todecrypt.substr(0,Array_size);
		todecrypt.erase(0,Array_size);
		int tomultiply[Array_size];
		for(int i=0;i<Array_size;i++)
		{
			tomultiply[i]=int(unit_decrypt.c_str()[0]);
			unit_decrypt.erase(0,1);
		}
		for(int i=0;i<Array_size;i++)
		{
			int resultchar=0;
			for(int j=0;j<Array_size;j++)
			{
				resultchar+=tomultiply[j]*cipher[i][j];	
			}
			decrypted+=char((resultchar%229)-26);
		}
	}
	return decrypted;
}

void getcipher(string& whichcipher, int returncipher[Array_size][Array_size])
{
	int cipher1[Array_size][Array_size]={{57,-5,46},
										 {11,-1, 9},
										 {-1, 0, 1}};
	int cipher2[Array_size][Array_size]={{1, 0, 5},
										 {2, 1, 6},
										 {3, 4, 0}};
	int cipher3[Array_size][Array_size]={{1, 5, 2},
										 {1, 1, 7},
										 {0, -3,4}};
	string ciph1code="EaP";
	string ciph2code="RH!";
	string ciph3code="Tfh";

	if(whichcipher==ciph1code)
	{
		for(int i=0;i<Array_size;i++)
		{
			for(int j=0;j<Array_size;j++)
			{
				returncipher[i][j]=cipher1[i][j];
			}
		}
	}
	else if(whichcipher==ciph2code)
	{
		for(int i=0;i<Array_size;i++)
		{
			for(int j=0;j<Array_size;j++)
			{
				returncipher[i][j]=cipher2[i][j];
			}
		}
	}
	else if(whichcipher==ciph3code)
	{
		for(int i=0;i<Array_size;i++)
		{
			for(int j=0;j<Array_size;j++)
			{
				returncipher[i][j]=cipher3[i][j];
			}
		}
	}
	
}

void decodecipher(string thiscipher, int returncipher[Array_size][Array_size])
{
	int cipher1iv[Array_size][Array_size]={{1, -5, 1},
										   {2,-11,-7},
										   {-1, 5, 2}};
	int cipher2iv[Array_size][Array_size]={{-24,20,-5},
										   {18,-15, 4},
										   {5, -4, 1}};
	int cipher3iv[Array_size][Array_size]={{-25,26,-33},
										   {4, -4, 5},
										   {3, -3, 4}};
	string ciph1code="EaP";
	string ciph2code="RH!";
	string ciph3code="Tfh";
	if(thiscipher==ciph1code)
	{
		for(int i=0;i<Array_size;i++)
		{
			for(int j=0;j<Array_size;j++)
			{
				returncipher[i][j]=cipher1iv[i][j];
			}
		}
	}
	else if(thiscipher==ciph2code)
	{
		for(int i=0;i<Array_size;i++)
		{
			for(int j=0;j<Array_size;j++)
			{
				returncipher[i][j]=cipher2iv[i][j];
			}
		}
	}
	else if(thiscipher==ciph3code)
	{
		for(int i=0;i<Array_size;i++)
		{
			for(int j=0;j<Array_size;j++)
			{
				returncipher[i][j]=cipher3iv[i][j];
			}
		}
	}
	
}



Is This A Good Question/Topic? 0
  • +

Replies To: Compiler error: /tmp/ccAKV0Q4.o: In function `encryption(std::basic_st

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6039
  • View blog
  • Posts: 23,441
  • Joined: 23-August 08

Re: Compiler error: /tmp/ccAKV0Q4.o: In function `encryption(std::basic_st

Posted 01 December 2010 - 03:10 PM

void getcipher(string& whichcipher, int returncipher[Array_size][Array_size])

Is that prototyped in encryption.h?
Was This Post Helpful? 1
  • +
  • -

#3 lunixer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 120
  • Joined: 29-January 10

Re: Compiler error: /tmp/ccAKV0Q4.o: In function `encryption(std::basic_st

Posted 01 December 2010 - 03:13 PM

View PostJackOfAllTrades, on 01 December 2010 - 04:10 PM, said:

void getcipher(string& whichcipher, int returncipher[Array_size][Array_size])

Is that prototyped in encryption.h?


Forgot the &. Thank you!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1