master-keying / minisat

A minimalistic and high-performance SAT solver
minisat.se
Other
143 stars 16 forks source link

undefined reference with library usage #11

Open shubham19195 opened 4 years ago

shubham19195 commented 4 years ago

I use g++ 9.3.0. Now I just copy your example of library usage and when I do "g++ main.cpp -std=c++11" I get a lot of errors like this: g++ main.cpp -o main -L/build/minisat /usr/bin/ld: /tmp/ccKas2ZI.o: in function main': main.cpp:(.text+0x2e): undefined reference toMinisat::Solver::Solver()' /usr/bin/ld: main.cpp:(.text+0x47): undefined reference to Minisat::Solver::newVar(bool, bool)' /usr/bin/ld: main.cpp:(.text+0x66): undefined reference toMinisat::Solver::newVar(bool, bool)' /usr/bin/ld: main.cpp:(.text+0x85): undefined reference to Minisat::Solver::newVar(bool, bool)' /usr/bin/ld: main.cpp:(.text+0x3c7): undefined reference toMinisat::Solver::~Solver()' /usr/bin/ld: main.cpp:(.text+0x3fc): undefined reference to Minisat::Solver::~Solver()' /usr/bin/ld: /tmp/ccKas2ZI.o: in functionMinisat::Solver::addClause(Minisat::Lit, Minisat::Lit, Minisat::Lit)': main.cpp:(.text._ZN7Minisat6Solver9addClauseENS_3LitES1S1[_ZN7Minisat6Solver9addClauseENS_3LitES1S1]+0x94): undefined reference to Minisat::Solver::addClause_(Minisat::vec<Minisat::Lit>&)' /usr/bin/ld: /tmp/ccKas2ZI.o: in functionMinisat::Solver::solve()': main.cpp:(.text._ZN7Minisat6Solver5solveEv[ZN7Minisat6Solver5solveEv]+0x5b): undefined reference to `Minisat::Solver::solve()' collect2: error: ld returned 1 exit status

I have looked into the issues and I am guessing it because of not linking the library correctly.