-3

I'm trying to simulate a C17 logic circuit in C++ using a Library called LibLCS. Click here to see an example of a digital circuit made with this lib. But isnt working. I cant compile the code and I have no idea why.

#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;
}

I got the following compilation error:

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): 

And many more...

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Leonardo Alves
  • 37
  • 1
  • 10
  • Where is it failing? – Jamie Rees May 12 '15 at 13:41
  • I have no idea to be honest. It gives me about a hundred erro lines. [leonardoalves@localhost c17]$ 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[_ZNK3lcs3BusILi1EEcmILi1EEEKNS0_IXplT_Li1EEEERKNS0_IXT_EEE]+0x75): and so on.. – Leonardo Alves May 12 '15 at 13:45
  • @Aracthor you right, it's just a link problem. Solved it. Thank you very much bro. – Leonardo Alves May 12 '15 at 13:50
  • I'll do it, It seen I have to wait a minute to do that, but i'll. Thank you very much. – Leonardo Alves May 12 '15 at 13:55

1 Answers1

1

From your errors trace that you gave us in comments, I may tell you that you forgot to link your program with your lib.

If your lib is called liblcs.so or liblcs.a, so add this flags to your g++ compilation :

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

It should works. Or at least it should solve this problem.

Aracthor
  • 5,757
  • 6
  • 31
  • 59