-3

我正在尝试使用名为LibLCS的库在 C++ 中模拟 C17 逻辑电路。单击此处查看使用此库制作的数字电路示例。但不工作。我无法编译代码,也不知道为什么。

#include <lcs/lcs.h>
#include <lcs/nand.h>
#include <lcs/simul.h>
#include <lcs/tester.h>
#include <lcs/changeMonitor.h>

// All libLCS constructs are defined under
// the namespace lcs.

using namespace lcs;


int main()
{
  Bus<1> a, b, c, d, e, ga, gb, gc, gd, ge, gf;

  Nand<2> nandGate1(ga, (a,b)), nandGate2(gb, (b,d));
  Nand<2> nandGate3(gc, (c,gb)), nandGate4(gd, (gb,e));
  Nand<2> nandGate5(ge, (ga,gc)), nandGate6(gf, (gc,gd));


  ChangeMonitor<5> inputMonitor((a,b,c,d,e), "Input", DUMP_ON);
  ChangeMonitor<2> outputMonitor((ge,gf), "Output", DUMP_ON);

  Tester<5> tester((a,b,c,d,e));

  Simulation::setStopTime(4000); // Set the stop time.
  Simulation::start(); // Start the simulation.

  return 0;
}

我收到以下编译错误:

g++ -o c17 c17.cpp /tmp/cc5TeFfF.o: In function main':
c17.cpp:(.text+0x50a): undefined reference to lcs::Simulation::setStopTime(unsigned int)'
c17.cpp:(.text+0x50f): undefined reference to lcs::Simulation::start()' /tmp/cc5TeFfF.o: In function lcs::Bus<(1)+(1)> const lcs::Bus<1>::operator,<1>(lcs::Bus<1> const&) const':
c17.cpp(.text._ZNK3lcs3BusILi1EEcmILi1EEEKNS0_IXplT_Li1EEEERKNS0_IXT_EEE[_ZNK3l‌​cs3BusILi1EEcmILi1EEEKNS0_IXplT_Li1EEEERKNS0_IXT_EEE]+0x75): 

还有很多...

4

1 回答 1

1

从您在评论中给我们的错误跟踪中,我可能会告诉您,您忘记将程序与您的库链接。

如果您的 lib 被调用liblcs.soor liblcs.a,则将此标志添加到您的 g++ 编译中:

g++ -o c17 c17.cpp -llcs -L"path to the lib folder"

它应该有效。或者至少它应该解决这个问题。

于 2015-05-12T13:49:52.053 回答