Answer the question
In order to leave comments, you need to log in
How to link dynamic library with cpp code?
I want to use this repo
.
I did everything correctly and got the dynamic library .so
But when I compile g++ a.cpp -llibselenium
from the same directory where .so is
Not compiled with an error:
[email protected]:~# g++ a.cpp -llibselenium
a.cpp: In function ‘int main(int, char**)’:
a.cpp:12:60: error: no matching function for call to ‘Selenium::Selenium(const char [29])’
Selenium* s = new Selenium("http://127.0.0.1:4444/wd/hub");
^
In file included from a.cpp:1:0:
/usr/local/include/selenium/selenium.hpp:12:4: note: candidate: Selenium::Selenium(std::__cxx11::string, bool)
Selenium(std::string,bool);
^~~~~~~~
/usr/local/include/selenium/selenium.hpp:12:4: note: candidate expects 2 arguments, 1 provided
/usr/local/include/selenium/selenium.hpp:8:7: note: candidate: Selenium::Selenium(const Selenium&)
class Selenium {
^~~~~~~~
/usr/local/include/selenium/selenium.hpp:8:7: note: no known conversion for argument 1 from ‘const char [29]’ to
‘const Selenium&’
/usr/local/include/selenium/selenium.hpp:8:7: note: candidate: Selenium::Selenium(Selenium&&)
/usr/local/include/selenium/selenium.hpp:8:7: note: no known conversion for argument 1 from ‘const char [29]’ to
‘Selenium&&’
#include <selenium/selenium.hpp>
#include <iostream>
#include <vector>
using std::string;
using std::cout;
using std::endl;
int main(int argc,char** argv) {
//creates new selenium object with the selenium entry page as argument.
Selenium* s = new Selenium("http://127.0.0.1:4444/wd/hub"); // ошибка тут
//creates new selenium session.
Session* sess = s->createSession(new Capabilities());
//goes to the google home page.
sess->url("http://www.google.com");
//gets all the links on the page
std::vector<Element*> links = sess->elements(new ElementQuery(ElementQuery::STRAT_TAG_NAME,"a"));
//displays the number of links on the google homepage
cout << "# of links:" << links.size() << endl;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question