Jump to content




Recent Status Updates

  • Photo
      18 Aug
    KodeKool

    When faced with a wall of errors and no hope to fix them, remember the following "Programs always do what you tell them to, and seldom what you want them to, but eventually you'll run out of things that can go wrong and it'll just work. and that's the secret to good programming."

    Show comments (2)
View All Updates

Developed by Kemal Taskin
Photo
- - - - -

Visual C++ 2010 linker error

C++

  • Please log in to reply
4 replies to this topic

#1 Saurian

Saurian

    CC Regular

  • Member
  • PipPipPip
  • 28 posts
  • Location:Bucharest
  • Programming Language:C, C++, PHP

Posted 12 October 2012 - 03:29 AM

I have the following errors and I have no ideas why is that:
1>Debug\eit_calc.obj : warning LNK4042: object specified more than once; extras ignored
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall proprietati::set_values(double,double,double,double,double)" (?set_values@proprietati@@QAEXNNNNN@Z) referenced in function "void __cdecl interpolare(double,double (* const)[6],class proprietati)" (?interpolare@@YAXNQAY05NVproprietati@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: double __thiscall proprietati::get_t(void)" (?get_t@proprietati@@QAENXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: double __thiscall proprietati::get_c(void)" (?get_c@proprietati@@QAENXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: double __thiscall proprietati::get_eta(void)" (?get_eta@proprietati@@QAENXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: double __thiscall proprietati::get_lambda(void)" (?get_lambda@proprietati@@QAENXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall proprietati::proprietati(void)" (??0proprietati@@QAE@XZ) referenced in function _main
1>C:\Users\Saurian\Documents\Visual Studio 2010\Projects\eit\Debug\eit.exe : fatal error LNK1120: 6 unresolved externals


I have in the header folder eit_calc.h and in the source folder files eit_calc.cpp ( where I devine the class declared in eit_calc.h ) and main.cpp ( the main files ). Anything could know what might be the problem? If it is needed I can give you the source code.
  • 0

#2 lintwurm

lintwurm

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 261 posts
  • Programming Language:C, Java, C++, C#, PHP, (Visual) Basic, Python, Visual Basic .NET

Posted 12 October 2012 - 03:59 AM

please post the code...

It could be several reasons why the linking is failing...
  • 0
No harm was done to the world in sending this message, but a few million electrons have been SERIOUSLY inconvenienced...

#3 Saurian

Saurian

    CC Regular

  • Member
  • PipPipPip
  • 28 posts
  • Location:Bucharest
  • Programming Language:C, C++, PHP

Posted 12 October 2012 - 05:10 AM

--------------------------------------------------------------------------------------------------------------------------------------
eit_calc.h
--------------------------------------------------------------------------------------------------------------------------------------

#pragma once

class proprietati
{
	 private:
		 double t, c, lambda, eta, ro;
	 public:
		 proprietati ();
		 proprietati ( double v1, double v2, double v3, double v4, double v5 );
		 void set_values ( double v1, double v2, double v3, double v4, double v5 );
		 double get_t ();
		 double get_c ();
		 double get_lambda ();
		 double get_eta ();
		 double get_ro ();
};

--------------------------------------------------------------------------------------------------------------------------------------
eit_calc.cpp
--------------------------------------------------------------------------------------------------------------------------------------

#include "eit_calc.h"

//constructorii
proprietati::proprietati ()
{
	t = 0;
	c = 0;
	lambda = 0;
	eta = 0;
	ro = 0;
}

proprietati::proprietati ( double v1, double v2, double v3, double v4, double v5 )
{
	t = v1;
	c = v2;
	lambda = v3;
	eta = v4;
	ro = v5;
}

//setare valori
void proprietati::set_values ( double v1, double v2, double v3, double v4, double v5 )
{
	t = v1;
	c = v2;
	lambda = v3;
	eta = v4;
	ro = v5;
}

//afisare valori
double proprietati::get_t ()
{
	return t;
}

double proprietati::get_c ()
{
	return c;
}

double proprietati::get_lambda ()
{
	return lambda;
}

double proprietati::get_eta ()
{
	return eta;
}

double proprietati::get_ro ()
{
	return ro;
}

--------------------------------------------------------------------------------------------------------------------------------------
main.cpp
---------------------------------------------------------------------------------------------------------------------------------------
#include <fstream>
#include <iostream>
#include <windows.h>
#include <iomanip>
#include "eit_calc.h"
#include "functions.cpp"

using namespace std;

void interpolare ( double tf, double data[6][6], proprietati val )
{
	int i = 0;
	double v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0;

	i = 0;
	while ( tf > data[i][0] )
	 {
		 i++;
	 }

	if ( tf == data[i][0] )
	 {
		 v1 = data[i][0];
		 v2 = data[i][1];
		 v3 = data[i][2];
		 v4 = data[i][3];
		 v5 = data[0][0];
	 }
	 else
	 {
		 v1 = tf;
		 v2 = data[i - 1][1] = ((data[i][1] - data[i - 1][1])/(data[i][0] - data[i - 1][0])) * (tf - data[i - 1][0] );
		 v3 = data[i - 1][2] = ((data[i][2] - data[i - 1][2])/(data[i][0] - data[i - 1][0])) * (tf - data[i - 1][0] );
		 v4 = data[i - 1][3] = ((data[i][3] - data[i - 1][3])/(data[i][0] - data[i - 1][0])) * (tf - data[i - 1][0] );
		 v5 = data[0][0];
	 }

	 val.set_values ( v1, v2, v3, v4, v5 );

}

int main (int argc, TCHAR *argv[])
{
	//declaram variabile
	proprietati aer[2], n2[2], o2[2], co[2], co2[2], h2o[2];
	ifstream fin("date.in"), fa("date_aer.in");
	ofstream fout("date.out");
	double data[6][6][6], dan = 0, dgn = 0, tap = 0, tas = 0, etar = 0, wa1n = 0, wa2n = 0, wgn = 0, de = 0, deltap = 0, lambdap = 0, di = 0, delta = 0, rco2 = 0, ro2 = 0, rh2o = 0, rco = 0, rn2 = 0, temp = 0, data_in[3][5][6], t[6][3], calcule[6][10], date_in_a[4][4], calcule_a[9][10], val[10][10], ta[10];
	int i = 0, j = 0, contoare[10];

	//citire date din fisierul de intrare
	for ( i = 0; i < 4; i++ )
		fin >> data[0][i][0] >> data[0][i][1] >> data[0][i][2] >> data[0][i][3] >> data[0][i][4];
	for ( i = 1; i <= 5; i++ )
	 {
		 for ( j = 0; j < 4; j++ )
			 fin >> data[i][j][0] >> data[i][j][1] >> data[i][j][2] >> data[i][j][3] >> data[i][j][4];
	 }
	for ( i = 0; i < 6; i++ )fin >> data[i][0][5];

	fin.close ();


	//citire datele de intrare
	cout << "Dați datele de intrare:" << endl;
	cout << "\tDebitul de aer raportat la starea normala: "; cin >> dan;
	cout << "\tDebitul de gaze raportat la starea normala: "; cin >> dgn;
	cout << "\tDebitul aerului la intrare: "; cin >> tap;
	cout << "\tDebitul aerului la ieșire: "; cin >> tas;
	cout << "\tProcentajul CO2 din gazele de ardere"; cin >> rco2;
	cout << "\tProcentajul O2 din gazele de ardere"; cin >> ro2;
	cout << "\tProcentajul H2O din gazele de ardere"; cin >> rh2o;
	cout << "\tProcentajul CO din gazele de ardere"; cin >> rco;
	cout << "\tProcentajul N2 din gazele de ardere"; cin >> rn2;
	cout << "\tCoeficientul de reținere al căldurii: "; cin >> etar;
	cout << "\tViteza aerului în condiții normale prin țevi: "; cin >> wa1n;
	cout << "\tViteza aerului în condiții normale prin spațiul inelar: "; cin >> wa2n;
	cout << "\tViteza gazului în condiții normale: "; cin >> wgn;
	cout << "\tDiametrul exterior al țevilor interioare: "; cin >> de;
	cout << "\tGrosimea peretelui țevilor interioare: "; cin >> deltap;
	cout << "\tConductivitatea termică a peretelui: "; cin >> lambdap;
	cout << "\tGrosimea virolei interioare/exterioare: "; cin >> delta;

	//interpolari
	interpolare ( tap, data[0], aer[0] );
	interpolare ( tas, data[0], aer[1] );




	 fout << "t, c, lambda si eta pentru aer" << endl;
	
	 fout << aer[0].get_t() << ' ' << aer[0].get_c() << ' ' << aer[0].get_eta() << aer[0].get_lambda() << endl;
	 fout << aer[1].get_t() << ' ' << aer[1].get_c() << ' ' << aer[1].get_eta() << aer[1].get_lambda() << endl;
	
	 fout << endl;



	 fout << endl << "Valori calculate:" << endl;
	 for ( i = 0; i < 9; i++ )
		 fout << setprecision (4) << calcule[0][i] << ' ';


	 // fout.close ();

	 for ( i = 0; i < 4; i++ )
		 for( j = 0; j < 4; j++ )
			 fa >> date_in_a[i][j];

	 fa.close ();

	 cout << "Dati temperatura aerului de intrare:";cin >> ta[0];
	 cout << "Dati temperatura aerului de iesire:";cin >> ta[1];
	 ta[2] = (ta[0] + ta[1])/2;
	 ta[3] = (ta[0] + ta[2])/2;
	 ta[4] = (ta[2] + ta[1])/2;
	 ta[5] = (ta[0] + ta[1])/1.5;
	 ta[6] = (ta[0] + ta[5])/2;
	 ta[7] = (ta[5] + ta[1])/2;

	 for (i = 0; i < 8; i++ )
	 {
			contoare[i] = 0;
			while ( ta[i] > date_in_a[contoare[i]][0] )contoare[i]++;

			if ( ta[i] == date_in_a[contoare[i]][0] )
			 {
				val[i][0] = date_in_a[contoare[i]][1];
				val[i][1] = date_in_a[contoare[i]][2];
				val[i][2] = date_in_a[contoare[i]][3];
			 }
			else
			 {
				 val[i][0] = date_in_a[contoare[i] - 1][1] + ((date_in_a[contoare[i]][1] - date_in_a[contoare[i] - 1][1])/(date_in_a[contoare[i]][0] - date_in_a[contoare[i] - 1][0]))*(ta[i] - date_in_a[contoare[i] - 1][0]);
				 val[i][1] = date_in_a[contoare[i] - 1][2] + ((date_in_a[contoare[i]][2] - date_in_a[contoare[i] - 1][2])/(date_in_a[contoare[i]][0] - date_in_a[contoare[i] - 1][0]))*(ta[i] - date_in_a[contoare[i] - 1][0]);
				 val[i][2] = date_in_a[contoare[i] - 1][3] + ((date_in_a[contoare[i]][3] - date_in_a[contoare[i] - 1][3])/(date_in_a[contoare[i]][0] - date_in_a[contoare[i] - 1][0]))*(ta[i] - date_in_a[contoare[i] - 1][0]);
			 }
	 }


		for (i = 0; i < 8; i++)
		 {
			calcule_a[i][0] = val[i][0]*ta[i];
			calcule_a[i][1] = (1.2928*273.15)/(ta[i]+273.15);
			calcule_a[i][2] = val[i][2]/calcule_a[i][1];
			calcule_a[i][3] = (val[i][1]*1.2928)/(val[i][0]*calcule_a[i][1]);
			calcule_a[i][4] = calcule_a[i][2] / calcule_a[i][3];
		 }

	 fout << endl << "t h ro niu a Pr" << endl;

	 for ( i = 0; i < 8; i++ )
		 fout << setprecision(8) << ta[i] << ' ' << calcule_a[i][0] << ' ' << calcule_a[i][1] << ' ' << calcule_a[i][2] << ' ' << calcule_a[i][3] << ' ' << calcule_a[i][4] << endl;


	 fout.close ();

	return 0;
}

Edited by BenW, 12 October 2012 - 05:22 AM.
Added code tags

  • 0

#4 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3,319 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 12 October 2012 - 05:28 AM

As lintwurm said, there is a number of reasons for those errors, it is good to have the project to check it up, still there is some hints :

. is eit_calc.cpp included in the compilation ? maybe you are including the .h and not the .cpp

. are you passing wrong data types as parameters or a different quantity of them ?
. are the functions even coded ? maybe the .h proto has more methods than the .cpp

those are two very common reasons for that error to pop.
  • 0

#5 Saurian

Saurian

    CC Regular

  • Member
  • PipPipPip
  • 28 posts
  • Location:Bucharest
  • Programming Language:C, C++, PHP

Posted 12 October 2012 - 08:56 AM

Thank you for your help. Reading what you wrote I realised that at first in the header folder I added a .cpp file and after that rename it as a .h file. I thought that this wouldn't matter. But now I see that this was the reason for the linker errors.

I have another question. How can I remove a .cpp file from a project? I removed a .cpp file from a project and when I tried to add another .cpp file with the same name it gave me an error that the file already existed. So I deleted all the file with that name ( .cpp and .obj ) but when I hit the Run button it gives me a linker error saying that my function is already defined ( I define the same function in the old file as in the new file ).
  • 0





Also tagged with one or more of these keywords: C++