0
我正在做我的第一個VC++項目,並使用下面的代碼。該項目有以下文件。VC++ 2010項目中的鏈接器錯誤1120。
Project1.cpp
#include "stdafx.h"
#include <iostream>
#include "PopulateDB.h"
using namespace std;
int main (void)
{
PopulateDB x;
x.calcUpload();
return 0;
}
PopulateDB.h
#pragma once
#include "mysql_connection.h"
#include <cppconn/driver.h>
class PopulateDB
{
public:
int calcUpload(void);
PopulateDB(void);
~PopulateDB(void);
private:
int updateMA(sql::Connection &);
};
PopulateDB.cpp
#include "StdAfx.h"
#include "PopulateDB.h"
#include <iostream>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include "Technical.h"
using namespace std;
int updateMA(sql::Connection& con)
{
sql::Statement *stmt;
sql::ResultSet *res;
int i;
stmt = con.createStatement();
res = stmt->executeQuery("SELECT * from PriceAMS");
while(res->next())
{
cout << "Symbol " << i << " = " << res->getBlob("Symbol") << endl;
i++;
}
delete stmt;
}
int calcUpload(void)
{
cout << "Running Connection..." << endl;
try
{
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
/* Create a connection */
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "nishantd", "mySQLDB%passWord2013"); //we can initialize the user/pass in constructor
/* Connect to the MySQL test database */
con->setSchema("testMMDB");
cout << "Looks like it connected..." << endl;
updateMA(*con);
delete con;
}
catch (sql::SQLException &e)
{
cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << ")" << endl;
}
return 0;
}
PopulateDB::PopulateDB(void)
{
}
PopulateDB::~PopulateDB(void)
{
}
Technical.h
#pragma once
#include <vector>
class Technical
{
public:
float StandardMovingAverage(std::vector<float> values);
float StdDev(std::vector<float> values);
float Variance(std::vector<float> values);
int RSI(std::vector<float> values);
Technical(void);
~Technical(void);
};
Technical.cpp
#include "StdAfx.h"
#include "Technical.h"
#include <cmath>
#include <vector>
using namespace std;
float Technical::StandardMovingAverage(vector <float> values)
{
int sum=0;
for(int i=0; i < values.size(); i++)
sum+=values[i];
return sum/values.size();
}
float Technical::StdDev(vector <float> values)
{
float E=0;
float ave = StandardMovingAverage(values); //this function just calculates the mean values
for(int i=0; i < values.size(); i++)
E+=(values[i]- ave)*(values[i]- ave);
return sqrt(1/values.size()*E);
}
float Technical::Variance(vector <float> values)
{
return StdDev(values)*StdDev(values);
}
Technical::Technical(void)
{
}
Technical::~Technical(void)
{
}
我收到以下錯誤在VC++ 2010年有我目前忽略
1>Project1.obj : error LNK2001: unresolved external symbol "public: int __thiscall PopulateDB::calcUpload(void)" ([email protected]@@QAEHXZ)
1>D:\Project\CPP\Project1\Release\Project1.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我試圖解決這一點,讓我的代碼工作的警告。它更令人沮喪,因爲我懷疑我缺少一些非常基本的東西,因爲我是VC++的新手,而代碼無論如何都沒有在當前的形狀中做太多工作。
真的很感謝所有幫助
感謝, 尼克
非常感謝。有效。非常感謝您的幫助。 – user2877289