Я новичок в C++, недавно взял класс, чтобы познакомить меня с языком, поэтому я понимаю основы синтаксиса, но не обсуждалось, как использовать внешние библиотеки и подключить их к нашему коду.Ошибка компоновщика при попытке использовать двоичную внешнюю библиотеку
Я пытаюсь использовать библиотеку CLP COIN для решения линейных программ с ... http://www.coin-or.org/Clp/userguide/clpuserguide.html#id4766717
Из того, что я прочитал там, она предложила использовать скомпилированные бинарные библиотеки, а не загрузить исходный код, так как я на платформе Windows 7, поскольку они предполагали, что перекомпиляция в Windows иногда может привести к проблемам.
Я просто пытаюсь получить эквивалент работы Hello World. Вот пример кода, они обеспечивают, чтобы проверить с ...
* Copyright (C) 2004, International Business Machines Corporation
and others. All Rights Reserved.
This sample program is designed to illustrate programming
techniques using CoinLP, has not been thoroughly tested
and comes without any warranty whatsoever.
You may copy, modify and distribute this sample program without
any restrictions whatsoever and without any payment to anyone.
*/
/* This shows how to provide a simple picture of a matrix.
The default matrix will print Hello World
*/
#include "ClpSimplex.hpp"
int main (int argc, const char *argv[])
{
ClpSimplex model;
int status;
// Keep names
if (argc<2) {
status=model.readMps("hello.mps",true);
} else {
status=model.readMps(argv[1],true);
}
if (status)
exit(10);
int numberColumns = model.numberColumns();
int numberRows = model.numberRows();
if (numberColumns>80||numberRows>80) {
printf("model too large\n");
exit(11);
}
printf("This prints x wherever a non-zero elemnt exists in matrix\n\n\n");
char x[81];
int iRow;
// get row copy
CoinPackedMatrix rowCopy = *model.matrix();
rowCopy.reverseOrdering();
const int * column = rowCopy.getIndices();
const int * rowLength = rowCopy.getVectorLengths();
const CoinBigIndex * rowStart = rowCopy.getVectorStarts();
x[numberColumns]='\0';
for (iRow=0;iRow<numberRows;iRow++) {
memset(x,' ',numberColumns);
for (int k=rowStart[iRow];k<rowStart[iRow]+rowLength[iRow];k++) {
int iColumn = column[k];
x[iColumn]='x';
}
printf("%s\n",x);
}
printf("\n\n");
return 0;
}
Я связанный Включать и Lib каталоги с моим проектом в Visual Studio, но когда я пытаюсь построить, получить ряд ошибок компоновщика, таких как :
Simplex(void)" ([email protected]@[email protected]) referenced in function _main
1>hello.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CoinPackedMatrix::~CoinPackedMatrix(void)" ([email protected]@[email protected]) referenced in function _main
1>hello.obj : error LNK2019: unresolved external symbol "public: void __thiscall CoinPackedMatrix::reverseOrdering(void)" ([email protected]@@QAEXXZ) referenced in function _main
1>hello.obj : error LNK2019: unresolved external symbol "public: __thiscall CoinPackedMatrix::CoinPackedMatrix(class CoinPackedMatrix const &)" ([email protected]@[email protected]@@Z) referenced in function _main
1>hello.obj : error LNK2019: unresolved external symbol "public: int __thiscall ClpSimplex::readMps(char const *,bool,bool)" ([email protected]@@[email protected]) referenced in function _main
1>hello.obj : error LNK2019: unresolved external symbol "public: __thiscall ClpSimplex::ClpSimplex(bool)" ([email protected]@[email protected][email protected]) referenced in function _main
как новичок, я невежественный о том, как подходить к решению этой проблемы, так как мой курс охватывает только отладки, связанные с синтаксисом кодом, не компоновщика вопросы.
Любые советы или ссылки на другие темы были бы очень полезными. Я весь день был в Googling, но я в недоумении ...
была аналогичная проблема с C++ кли и внешний крошечного XML Lib, http://stackoverflow.com/questions/7999678/cant-include-tinyxml-in-c -cli-project – Dave