主题:调试程序时遇到的连接问题!
我在调试程序的时候遇到的问题,请各位高手帮我看看!! 谢谢,先!
main.obj : error LNK2001: unresolved external symbol "int __cdecl RC(class std::vector<double *,class std::allocator<double *> > *,int,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?RC@@YAHPAV?$ve
ctor@PANV?$allocator@PAN@std@@@std@@HHHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
下面是主程序:
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <string>
#include "CmdLine.h"
using namespace std;
vector<double*>* construct_graph(vector<double*> Ltable, vector<double*> Ctable, vector<double*> grad_img, double WIDTH, double LAMBDA, bool homogeneity, bool use_corners, string datafile, double ALPHA);
int RC(vector<double*> *graph, int ncount, int ecount, int NumIteration, string fname);
int main(int argc, char** argv) {
if (argc < 2) {
cerr << "Usage: RRC foo.pgm [-n #][-l #][-c][-h][-a #]\n\tfoo.pgm - image to be processed.\n\t-n - number of boundaries (default 1).\n\t-l - real value for continuity lambda (default 0.0).\n\t-c - use corner information.\n\t-h - use homogeneity instead of area.\n\t-a - exponent alpha for proximity (default 1.0).\n";
return 1;
}
try {
CmdLine cmd(argc, argv);
CmdArgInt number = cmd.parse('n', "number", 1);
CmdArgDouble lambda = cmd.parse('l', "lambda", 0.0);
CmdArg homogeneity = cmd.parse('h', "homogeneity");
CmdArg use_corners = cmd.parse('c', "corners");
CmdArgDouble alpha = cmd.parse('a', "alpha", 1.0);
string fname = argv[1];
if (fname.substr(fname.length()-4, fname.length()) == ".pgm")
fname = fname.substr(0,fname.length()-4);
cout << "Processing: " << fname << endl;
if (lambda.value() < 0) {
cerr << "Warning: Lambda should be a real positive value.\n Using default value of 0.0.\n";
lambda.setValue(0.0);
}
cout << "Using the following parameters:\nLambda = " << lambda.value() << ", N = " << number.value() << ", corners = ";
if (use_corners.isFound()) cout << "on, homogeneity = ";
else cout << "off, homogeneity = ";
if (homogeneity.isFound()) cout << "on, alpha = ";
else cout << "off, alpha = ";
cout << alpha.value() << ".\n";
int HEIGHT, WIDTH = 0;
ifstream lines_in((fname+".lines").c_str());
if (!lines_in.is_open()) {
cerr << "ERROR: Could not open file " << fname << ".lines (Forgot to preprocess?)" << endl;
return 2;
}
ifstream corners_in, grad_in;
if (use_corners.isFound()) {
corners_in.open((fname+".corners").c_str());
if (!lines_in.is_open()) {
cerr << "ERROR: Could not open file " << fname << ".corners" << endl;
lines_in.close();
return 2;
}
}
if (homogeneity.isFound()) {
grad_in.open((fname+".map").c_str());
if (!lines_in.is_open()) {
cerr << "ERROR: Could not open file " << fname << ".map" << endl;
lines_in.close();
corners_in.close();
return 2;
}
}
vector<double*> lines;
vector<double*> corners;
vector<double*> gradient;
vector<double*> *graph;
double *one_line, MAX_W2, MAX_W1;
double *dataout;
while(!lines_in.eof()) {
//for (int i=0; i<line_count; i++) {
one_line = new double[4];
lines_in >> one_line[0] >> one_line[1] >> one_line[2] >> one_line[3];
lines.push_back(one_line);
}
one_line = lines[lines.size()-1];
lines.pop_back();
if (one_line != NULL) delete[] one_line;
cout << lines.size() << " lines read\n";
lines_in.close();
if (use_corners.isFound()) {
while(!corners_in.eof()) {
//for (int i=0; i<line_count; i++) {
one_line = new double[3];
corners_in >> one_line[0] >> one_line[1] >> one_line[2];
corners.push_back(one_line);
}
one_line = corners[corners.size()-1];
corners.pop_back();
if (one_line != NULL) delete[] one_line;
cout << corners.size() << " corners read\n";
corners_in.close();
}
if (homogeneity.isFound()) {
grad_in >> WIDTH >> HEIGHT;
for (int i=0; i<HEIGHT; i++) {
one_line = new double[WIDTH];
for (int j=0; j<WIDTH; j++)
grad_in >> one_line[j];
gradient.push_back(one_line);
}
cout << WIDTH << "x" << HEIGHT << " gradient read\n";
grad_in.close();
}
graph = construct_graph(lines, corners, gradient, WIDTH, lambda.value(), homogeneity.isFound(), use_corners.isFound(), fname+".data", alpha.value());
dataout = (*graph)[(*graph).size()-1];
MAX_W2 = dataout[0];
MAX_W1 = dataout[1];
(*graph).pop_back();
delete[] dataout;
for (int i = 0; i < (int)(*graph).size(); i++) {
dataout = (*graph)[i];
dataout[2] = dataout[2]*600.0/MAX_W2;
dataout[3] = dataout[3]*600.0/MAX_W1;
}
RC(graph, (4*lines.size()), (*graph).size(), number.value(), fname);
// CLEANUP
for (int ii=0; ii<(int)lines.size(); ii++) {
one_line = lines[ii];
delete[] one_line;
}
lines.clear();
for (int iii=0; iii<(int)corners.size(); iii++) {
one_line = corners[iii];
delete[] one_line;
}
corners.clear();
for (int iiii=0; iiii<(int)gradient.size(); iiii++) {
one_line = gradient[iiii];
delete[] one_line;
}
gradient.clear();
for (int iiiii=0; iiiii<(int)(*graph).size(); iiiii++) {
one_line = (*graph)[iiiii];
delete[] one_line;
}
(*graph).clear();
delete graph;
} catch(string msg) {
cerr << msg << endl;;
return 1;
}
return 0;
}
小弟急等中。。。。。
main.obj : error LNK2001: unresolved external symbol "int __cdecl RC(class std::vector<double *,class std::allocator<double *> > *,int,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?RC@@YAHPAV?$ve
ctor@PANV?$allocator@PAN@std@@@std@@HHHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
下面是主程序:
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <string>
#include "CmdLine.h"
using namespace std;
vector<double*>* construct_graph(vector<double*> Ltable, vector<double*> Ctable, vector<double*> grad_img, double WIDTH, double LAMBDA, bool homogeneity, bool use_corners, string datafile, double ALPHA);
int RC(vector<double*> *graph, int ncount, int ecount, int NumIteration, string fname);
int main(int argc, char** argv) {
if (argc < 2) {
cerr << "Usage: RRC foo.pgm [-n #][-l #][-c][-h][-a #]\n\tfoo.pgm - image to be processed.\n\t-n - number of boundaries (default 1).\n\t-l - real value for continuity lambda (default 0.0).\n\t-c - use corner information.\n\t-h - use homogeneity instead of area.\n\t-a - exponent alpha for proximity (default 1.0).\n";
return 1;
}
try {
CmdLine cmd(argc, argv);
CmdArgInt number = cmd.parse('n', "number", 1);
CmdArgDouble lambda = cmd.parse('l', "lambda", 0.0);
CmdArg homogeneity = cmd.parse('h', "homogeneity");
CmdArg use_corners = cmd.parse('c', "corners");
CmdArgDouble alpha = cmd.parse('a', "alpha", 1.0);
string fname = argv[1];
if (fname.substr(fname.length()-4, fname.length()) == ".pgm")
fname = fname.substr(0,fname.length()-4);
cout << "Processing: " << fname << endl;
if (lambda.value() < 0) {
cerr << "Warning: Lambda should be a real positive value.\n Using default value of 0.0.\n";
lambda.setValue(0.0);
}
cout << "Using the following parameters:\nLambda = " << lambda.value() << ", N = " << number.value() << ", corners = ";
if (use_corners.isFound()) cout << "on, homogeneity = ";
else cout << "off, homogeneity = ";
if (homogeneity.isFound()) cout << "on, alpha = ";
else cout << "off, alpha = ";
cout << alpha.value() << ".\n";
int HEIGHT, WIDTH = 0;
ifstream lines_in((fname+".lines").c_str());
if (!lines_in.is_open()) {
cerr << "ERROR: Could not open file " << fname << ".lines (Forgot to preprocess?)" << endl;
return 2;
}
ifstream corners_in, grad_in;
if (use_corners.isFound()) {
corners_in.open((fname+".corners").c_str());
if (!lines_in.is_open()) {
cerr << "ERROR: Could not open file " << fname << ".corners" << endl;
lines_in.close();
return 2;
}
}
if (homogeneity.isFound()) {
grad_in.open((fname+".map").c_str());
if (!lines_in.is_open()) {
cerr << "ERROR: Could not open file " << fname << ".map" << endl;
lines_in.close();
corners_in.close();
return 2;
}
}
vector<double*> lines;
vector<double*> corners;
vector<double*> gradient;
vector<double*> *graph;
double *one_line, MAX_W2, MAX_W1;
double *dataout;
while(!lines_in.eof()) {
//for (int i=0; i<line_count; i++) {
one_line = new double[4];
lines_in >> one_line[0] >> one_line[1] >> one_line[2] >> one_line[3];
lines.push_back(one_line);
}
one_line = lines[lines.size()-1];
lines.pop_back();
if (one_line != NULL) delete[] one_line;
cout << lines.size() << " lines read\n";
lines_in.close();
if (use_corners.isFound()) {
while(!corners_in.eof()) {
//for (int i=0; i<line_count; i++) {
one_line = new double[3];
corners_in >> one_line[0] >> one_line[1] >> one_line[2];
corners.push_back(one_line);
}
one_line = corners[corners.size()-1];
corners.pop_back();
if (one_line != NULL) delete[] one_line;
cout << corners.size() << " corners read\n";
corners_in.close();
}
if (homogeneity.isFound()) {
grad_in >> WIDTH >> HEIGHT;
for (int i=0; i<HEIGHT; i++) {
one_line = new double[WIDTH];
for (int j=0; j<WIDTH; j++)
grad_in >> one_line[j];
gradient.push_back(one_line);
}
cout << WIDTH << "x" << HEIGHT << " gradient read\n";
grad_in.close();
}
graph = construct_graph(lines, corners, gradient, WIDTH, lambda.value(), homogeneity.isFound(), use_corners.isFound(), fname+".data", alpha.value());
dataout = (*graph)[(*graph).size()-1];
MAX_W2 = dataout[0];
MAX_W1 = dataout[1];
(*graph).pop_back();
delete[] dataout;
for (int i = 0; i < (int)(*graph).size(); i++) {
dataout = (*graph)[i];
dataout[2] = dataout[2]*600.0/MAX_W2;
dataout[3] = dataout[3]*600.0/MAX_W1;
}
RC(graph, (4*lines.size()), (*graph).size(), number.value(), fname);
// CLEANUP
for (int ii=0; ii<(int)lines.size(); ii++) {
one_line = lines[ii];
delete[] one_line;
}
lines.clear();
for (int iii=0; iii<(int)corners.size(); iii++) {
one_line = corners[iii];
delete[] one_line;
}
corners.clear();
for (int iiii=0; iiii<(int)gradient.size(); iiii++) {
one_line = gradient[iiii];
delete[] one_line;
}
gradient.clear();
for (int iiiii=0; iiiii<(int)(*graph).size(); iiiii++) {
one_line = (*graph)[iiiii];
delete[] one_line;
}
(*graph).clear();
delete graph;
} catch(string msg) {
cerr << msg << endl;;
return 1;
}
return 0;
}
小弟急等中。。。。。