Error LNK2019: Symbol extern undefined. My code (cuda 6.0), why not work?

Hey guys here is my code of an lexical analyzer,
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <regex>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <sstream>
#include <time.h>  
#include <random>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

struct vetorCRelacaoAClasse
{
	string dado;
	string classe;
};

typedef struct vetorCRelacaoAClasse vcrac;

vector<string> lerArquivoEArmazenaVector(FILE *arq);

string stringComDataSet(vector<string> dataVetor);
string lerRelacao(string Linha_lida);
int qntClasses(string Linha_lida);
vector<string> lerClasses(string Linha_lida);
vector<string> lerAtributos(vector<string> Linha_lida);
int qntAtributos(vector<string> Linha_lida);
int indiceDeOcorrenciaDeData(vector<string> Linha_lida);
vector<string> conjuntoDeDados(vector<string> Linha_lida);
int instancias(vector<string> Linha_lida);
vector<string> explode(string Linha,string ER);
vector<vcrac> vectorDataSet(vector<string> conjuntoDeDados, vector<string> Linha_lida);
map<string,vector<vcrac>> finalDataSet(vector<string> vectorDataSet, vector<string> Linha_lida);

vector<string> lerArquivoEArmazenaVector(FILE *arq)
{

	  char Linha[100];
	  char *result;
	  vector<string> dataArff;
	  system("cls");
	  arq = fopen("Data/miniminiiris.arff", "rt");
	  if (arq == NULL)
	  {
		 cout<<"Arquivo nao encontrado"<<endl;
		 system("Pause");
		 exit(0);
	  }
	  else{
		  while (!feof(arq))
		  {
			  result = fgets(Linha, 100, arq);
			  if (result);
			  {
				  dataArff.push_back(result);
			  }
		  }
	  }
	  fclose(arq);
	  return dataArff;
}

string stringComDataSet(vector<string> dataVetor)
{
	const int n = dataVetor.size();
	string data;

	for(int i = 0; i< (int)(dataVetor.size());i++)
	{
		data += dataVetor[i];
	}
	return data;
}
string lerRelacao(string Linha_lida)
{
	regex rx1("^@RELATION.(.+)"); 
	cmatch mr;
	regex_search(Linha_lida.c_str(), mr, rx1);
	string str= mr[1];
	return str;
}
int qntClasses(string Linha_lida)
{
	int qntClasse;
	vector<string> classes;
	regex rx1("^@ATTRIBUTE.class.(.+)$"); 
	cmatch mr2;
	regex_search(Linha_lida.c_str(), mr2, rx1);
	string str2= mr2[1];
	classes = explode(str2,",{} ");
	qntClasse = classes.size();
	return qntClasse;
}
vector<string> lerClasses(string Linha_lida)
{
	vector<string> classes;
	regex rx1("^@ATTRIBUTE.class.(.+)$"); 
	cmatch mr2;
	regex_search(Linha_lida.c_str(), mr2, rx1);
	string str2= mr2[1];
	classes = explode(str2,",{} ");
	return classes;
}
vector<string> lerAtributos(vector<string> Linha_lida)
{	
	vector<string> str;
	for(int i=0; i<(int)(Linha_lida.size());i++)
	{
		regex rx("^@ATTRIBUTE.([a-zA-Z]+)"); 
		cmatch mr;
		if(regex_search(Linha_lida[i].c_str(), mr, rx))
		{
			str.push_back( mr[1]);
		}
	}
	return str;
}
int qntAtributos(vector<string> Linha_lida)
{
	int qntAtributo = 0;
	for(int i=0; i<(int)(Linha_lida.size());i++)
	{
		regex rx("^@ATTRIBUTE.([a-zA-Z]+)"); 
		cmatch mr;
		if(regex_search(Linha_lida[i].c_str(), mr, rx))
		{
			qntAtributo++;
		}
	}
	return qntAtributo;
}
int indiceDeOcorrenciaDeData(vector<string> Linha_lida)
{
  int data;
  for(int i=0;i < (int)(Linha_lida.size());i++)
  { 
	  if (strstr(Linha_lida[i].c_str(),"@DATA"))
	  {
		  data = i;
		  break;
	  }
  }
  return data+1;
}
vector<string> conjuntoDeDados(vector<string> Linha_lida)
{
	vector<string> conjuntoDeDados;
	for(int i = indiceDeOcorrenciaDeData(Linha_lida); i<(int)(Linha_lida.size()); i++)
	{
		conjuntoDeDados.push_back(Linha_lida[i]);
	}
	return conjuntoDeDados;
}
int instancias(vector<string> Linha_lida)
{
	int instancias = 0;
	for(int i = indiceDeOcorrenciaDeData(Linha_lida); i<(int)(Linha_lida.size()); i++)
	{
		instancias++;
	}
	return instancias;
}
vector<string> explode(string Linha,string ER)
{
	vector<string> explode;
	char *cstr= new char [Linha.length()+1];
	strcpy(cstr,Linha.c_str());
	char *p = strtok (cstr,ER.c_str());
	while (p!=0)
	{
		explode.push_back(p);
		p = strtok(NULL,ER.c_str());
	}
	free(cstr);
	return explode;
}
vector<vcrac> vectorDataSet(vector<string> conjuntoDeDados, vector<string> Linha_lida)
{
	vector<string> dados;
	vector<vcrac> vetorConjunto;
	vcrac data;

	for(int i = 0; i < (int)(conjuntoDeDados.size());i++)
	{
		dados = explode(conjuntoDeDados[i],",\n");
		for(int j=0;j<(int)(dados.size());j++)
		{
			data.dado = dados[j];
			data.classe = dados[dados.size() - 1];
			vetorConjunto.push_back(data);
		}
	}
	return vetorConjunto;
}
map<string,vector<vcrac>> finalDataSet(vector<vcrac> vectorDataSet, vector<string> Linha_lida)
{
	vector<string> atributosVetor;
	atributosVetor = lerAtributos(Linha_lida);
	map<string, vector<vcrac>> mapa;
	vector<vcrac> treino;
	vcrac datas;
	int constUniverso = qntAtributos(Linha_lida);
	for(int consts=0;consts<constUniverso - 1;consts++)
	{
		treino.clear();
		for(int i= consts;i<(int)(vectorDataSet.size());i = i + constUniverso)
		{
			datas.dado = vectorDataSet[i].dado;
			datas.classe = vectorDataSet[i].classe;
			treino.push_back(datas);
		}
		mapa[atributosVetor[consts]]=treino;
	}
	return mapa;
}


int main(void)
{
	vector<string> classes;
	vector<string> dataSet;
	vector<string> atributos;
	vector<string> conjuntoDeDado;
	FILE *arq = NULL;
	string data = "";
	string relacao = "";
	map<string,vector<vcrac>> mapa;
	vector<vcrac> vetorDeConjuntoDeDados;
	dataSet = lerArquivoEArmazenaVector(arq);
	data = stringComDataSet(dataSet);
	relacao = lerRelacao(data);
	classes = lerClasses(data);
	atributos = lerAtributos(dataSet);
	conjuntoDeDado = conjuntoDeDados(dataSet);
	vetorDeConjuntoDeDados = vectorDataSet(conjuntoDeDado, dataSet);
	mapa=finalDataSet(conjuntoDeDado,dataSet);
	system("pause");
	return 0;
}

I´m using vs2012 and CUDA 6.0, ever try all procedure cited for the microsoft in your official site:
http://msdn.microsoft.com/query/dev11.query?appId=Dev11IDEF1&l=PT-BR&k=k(LNK2019);k(VS.ErrorList)&rd=true
between other cited in others sites, help-me please i´m desperate.

1> main.cu
1>main.cu.obj : error LNK2019: símbolo externo indefinido "class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::vector<struct vetorCRelacaoAClasse,class std::allocator<struct vetorCRelacaoAClasse> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::vector<struct vetorCRelacaoAClasse,class std::allocator<struct vetorCRelacaoAClasse> > > > > __cdecl finalDataSet(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >)" (?finalDataSet@@YA?AV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$vector@UvetorCRelacaoAClasse@@V?$allocator@UvetorCRelacaoAClasse@@@std@@@2@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$vector@UvetorCRelacaoAClasse@@V?$allocator@UvetorCRelacaoAClasse@@@std@@@2@@std@@@2@@std@@V?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@0@Z) referenciado na função _main


Note: the code is functional in c/c++, but when i´m using cuda 6.0, appears this problem. I´m desperate.
Last edited on
The linker error means that the linker cannot find the implementation for one version of finalDataSet() from any of the object files that it has been given.


This is a stripped down version of your code:
1
2
3
4
5
6
7
8
9
10
map<string,vector<vcrac>> finalDataSet( vector<vcrac>, vector<string> );

int main()
{
  map<string,vector<vcrac>> mapa;
  vector<string> foo;
  vector<string> bar;

  mapa = finalDataSet( bar, foo );
}

The bar has strings, but the finalDataSet expects vcracs. That should fail on plain C++ as well.
Last edited on
Topic archived. No new replies allowed.