0

I have cloned libssh library and built it with cmake. Building process was like this :

git clone https://git.libssh.org/projects/libssh.git/
mkdir build in libssh directory.
cd build   
cmake -DUNIT_TESTING=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
after this line i got this error about cmocka:
Could NOT find CMocka (missing: CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR)
then : rm CMakeCache.txt 
cmake ..
make 
sudo make install

Now I want to use this library on qt but I have some issues there.

I got errors like :

error: undefined reference to `ssh_session_is_known_server'

I can't use any of function or structures on this library. My OS is ubuntu 18.04.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
fa7eme
  • 73
  • 10
  • You have to link to the `libssh` library *you* built, in your cmake / make file. Please show your cmake file or the commands you execute to build the project. – Waqar Jul 12 '20 at 07:41
  • @Waqar how should I link libssh library? I will edit to add those commands and results, and why did you down voted my question?! – fa7eme Jul 12 '20 at 07:51
  • 1
    I did not downvote your question. Stackoverflow has more than a million members, anyone with rep > 125 can do it. Though you should provide more information, while being as brief as possible, when asking a question. That means providing the necessary code to reproduce the problem OR giving commands or other things that may be causing the problem. If you don't, you will get downvoted quickly. Read more: [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) – Waqar Jul 12 '20 at 07:54
  • `> I want to use this library on qt ` How are you trying to use it in Qt? Is there a `qmake` (.pro) file? Another `cmake` file that you wrote? – Waqar Jul 12 '20 at 08:14
  • Where do you get the error `error: undefined reference to `ssh_session_is_known_server'`? – Waqar Jul 12 '20 at 08:15
  • I included the library like this: #include . and add this line in .pro file : LIBS += -L$$PWD/LibSSH/lib -lssh @Waqar – fa7eme Jul 12 '20 at 08:16
  • compiled code and that was on compile output. this is a function to recognize if the server is in the known servers or not. @Waqar – fa7eme Jul 12 '20 at 08:19
  • `-L$$PWD/LibSSH/lib` this path is incorrect probably. Verify that there is a `libssh.a` file in that directory. You might need to do `-L$$PWD/LibSSH/build/lib`, because the library was built in `build` directory. Find the place where `*.a` file exists and then give that path. – Waqar Jul 12 '20 at 08:19
  • @Waqar shouldn't I add libssh as external library to project? – fa7eme Jul 12 '20 at 08:25
  • Making it external / internal is your own decision. And since you did `sudo make install`, `-lssh` should work without giving any path. – Waqar Jul 12 '20 at 08:27

0 Answers0