Hello,
The message from the linker is:
Code:
main.obj||error LNK2019: unresolved external symbol "class std::vector<int,class
std::allocator<int> > __cdecl vfnd(class std::vector<int,class std::allocator<int> >,int)"
(?vfnd@@YA?AV?$vector@HV?$allocator@H@std@@@std@@V12@H@Z) referenced in
function _main|
It seems to me it is finding some kind of problem with the types of the parameters when I call function vfnd.cpp (a function to find the positions in a vector of occurrences of a given integer value).
The main function is as follows:
Code:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include "rddt.h"
#include "vfnd.h"
#include "wvct.h"
using namespace std;
int main(){
//----------------------------------------------------------------- Variable declaration
int sid, infv, ndlb, dmn;
string adj = "adj.txt";
string cst = "cst.txt";
vector<vector<int> > adjm;
vector<vector<int> > cstm;
vector<vector<int> >& padj = adjm;
vector<vector<int> >& pcst = cstm;
vector<int> prm, dlb, prd, tmp, rchv, pns, vadj;
//----------------------------------------------------------------- Calling in input variables
rddt(adj, padj); // it modifies adjm
rddt(cst, pcst); // it modifies cstm
cout << "source? ";
cin >> sid;
//----------------------------------------------------------------- Initializations
typedef vector<int>::size_type v_sz;
v_sz n;
n = adjm[0].size(); // order of network
infv = 10000000; // infinity definition
dlb.assign(n, infv); // distance labels initialization
prd.assign(n, infv); // predeccesor list initialization
dlb[sid] = 0; // starting alteration of control vectors
prd[sid] = 0;
//----------------------------------------------------------------- Core process
while (prm.size() != n){
prm.push_back(sid);
tmp[sid] = 0;
vadj = adjm[sid];
rchv = vfnd(vadj, 1); // see vfnd.cpp for details
vector<int>::const_iterator i, j;
for(i = rchv.begin(); i != rchv.end(); i++){ // Update of distance labels
ndlb = dlb[sid] + cstm[sid][*i];
if (dlb[*i] > ndlb){
dlb[*i] = ndlb;
prd[*i] = sid;
}
}
pns = vfnd(tmp, 1); // possible new sources
dmn = infv;
for(j = pns.begin();j != pns.end(); j++){ // selection of new source
if(dlb[*j] < dmn){
sid = *j;
dmn = dlb[*j];
}
}
}
string sdlb = "dlb.txt";
string sprd = "prd.txt";
wvct(sdlb, dlb);
wvct(sprd, prd);
return 0;
}
The headers and definition of the vfnd.cpp function are:
Code:
#ifndef VFND_H_INCLUDED
#define VFND_H_INCLUDED
#include <vector>
using std::vector;
vector<int> vfnd(vector<int>, int);
#endif // VFND_H_INCLUDED
and
Code:
#include <vector>
std::vector<int> vfnd(std::vector<int> vct, int tvl){
int dmvl;
std::vector<int> rchv;
std::vector<int>::const_iterator i, ov;
ov = vct.begin();
for (i = vct.begin(); i != vct.end(); i++){
if (*i == tvl){
dmvl = i - ov;
rchv.push_back(dmvl);
}
}
return rchv;
}
The function is called twice. The first time using a vector extracted from a vector of vectors (adjm). The call always looks for the integer 1:
Code:
vadj = adjm[sid];
rchv = vfnd(vadj, 1);
The second call is made for a pure vector (tmp):
Code:
pns = vfnd(tmp, 1);
If you could help me pointing out what is wrong here, I'd appreciate it.
Thanks.