我正在使用OpenNN2.0,它编译得很好,无论是64位还是32位。
当我使用32位编译我的应用程序时,一切正常,当我将解决方案设置为64位时,我收到链接器错误。
error LNK2001: unresolved external symbol "public: void __cdecl OpenNN::DataSet::set(unsigned __int64 const &,unsigned __int64 const &,unsigned __int64 const &)" (?set@DataSet@OpenNN@@QEAAXAEB_K00@Z)
导致此错误的代码:
OpenNN::DataSet data_set;
const unsigned __int64 i = 1;
data_set.set( i, i, i);
如果我这样做
data_set.set( );
相反,它编译得很好。我检查了dumpbin /ALL OpenNN2.0.lib
的输出,它包含
54A6D10 ?set@DataSet@OpenNN@@QEAAXAEBVXMLDocument@tinyxml2@@@Z
54A6D10 ?set@DataSet@OpenNN@@QEAAXAEB_K00@Z
54A6D10 ?set@DataSet@OpenNN@@QEAAXAEB_K0@Z
所以我认为它应该有用,但事实并非如此。这里发生了什么,我该如何纠正呢?就好像转换64位整数不起作用或沿着这些行,我无法弄明白。
来自OpenNN标头(data_set.h):
// Set methods
void set(void);
void set(const Matrix<double>&);
void set(const size_t&, const size_t&);
void set(const size_t&, const size_t&, const size_t&);
void set(const DataSet&);
void set(const tinyxml2::XMLDocument&);
void set(const std::string&);
在.cpp中实施:
void DataSet::set(void)
{
data_file_name = "";
data.set();
variables.set();
instances.set();
display = true;
}
// void set(const Matrix<double>&) method
/// Sets all variables from a data matrix.
/// @param new_data Data matrix.
void DataSet::set(const Matrix<double>& new_data)
{
data_file_name = "";
const size_t variables_number = new_data.get_columns_number();
const size_t instances_number = new_data.get_rows_number();
data = new_data;
variables.set(variables_number);
instances.set(instances_number);
display = true;
}
// void set(const size_t&, const size_t&) method
/// Sets new numbers of instances and variables in the inputs targets data set.
/// All the instances are set for training.
/// All the variables are set as inputs.
/// @param new_variables_number Number of variables.
/// @param new_instances_number Number of instances.
void DataSet::set(const size_t& new_variables_number, const size_t& new_instances_number)
{
// Control sentence (if debug)
#ifndef NDEBUG
if(new_variables_number == 0)
{
std::ostringstream buffer;
buffer << "OpenNN Exception: DataSet class.\n"
<< "void set(const size_t&, const size_t&) method.\n"
<< "Number of variables must be greater than zero.\n";
throw std::logic_error(buffer.str());
}
if(new_instances_number == 0)
{
std::ostringstream buffer;
buffer << "OpenNN Exception: DataSet class.\n"
<< "void set(const size_t&, const size_t&) method.\n"
<< "Number of instances must be greater than zero.\n";
throw std::logic_error(buffer.str());
}
#endif
data.set(new_instances_number, new_variables_number);
instances.set(new_instances_number);
variables.set(new_variables_number);
}
// void set(const size_t&, const size_t&, const size_t&) method
/// Sets new numbers of instances and inputs and target variables in the data set.
/// The variables in the data set are the number of inputs plus the number of targets.
///
/// @param new_inputs_number Number of input variables.
/// @param new_targets_number Number of target variables.
/// @param new_instances_number Number of instances.
void DataSet::set(const size_t& new_inputs_number, const size_t& new_targets_number, const size_t& new_instances_number)
{
data_file_name = "";
const size_t new_variables_number = new_inputs_number + new_targets_number;
data.set(new_instances_number, new_variables_number);
// Variables
variables.set(new_inputs_number, new_targets_number);
// Instances
instances.set(new_instances_number);
display = true;
}