-1

I get following error, when i tried to compile my test program

g++     main.cpp   -o main
/tmp/ccICBwKO.o: In function `main':
main.cpp:(.text+0xa): undefined reference to `ssh_new'
main.cpp:(.text+0x2d): undefined reference to `ssh_free'
collect2: error: ld returned 1 exit status
make: *** [main] Error 1

In my make file i have:

all:        main

$main:  main.cpp
        g++ main.cpp -o main -lssh

Thanks for help. (I really hate C/C++...)

Raiper34
  • 537
  • 2
  • 6
  • 20

1 Answers1

3

As you can see from the log, make is not using the rule you have given for $main. I suspect that you want to name it either main or $(main).

$main concatenates the value of variable $m (defaults to nothing as m is not defined) with ain, so that you've created a rule for ain instead of main. make thus rely on its default rules for creating an executable from a .cpp file, which does not include linking with libssh.

Virgile
  • 9,724
  • 18
  • 42
  • 1
    Perfectly right. The makefile can be fixed by removing the leading $ in the Makefile. This is not a libssh-related problem by the way. – Aris Oct 06 '15 at 11:24