英文:
Compiling C++ code using libssh library through vcpkg
问题
I installed libssh through vcpkg on my Windows 8.1 machine.
vcpkg install libssh
Now I am trying to compile my c++ code making use of libssh.
#include <libssh/libssh.h>
#include <stdlib.h>
int main()
{
ssh_session my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
...
ssh_free(my_ssh_session);
}
But I am receiving the following error.
D:\remoteDesktopTimeZone>gcc sample.cpp -o sampl
sample.cpp:1:10: fatal error: libssh/libssh.h: No such file or directory
1 | #include <libssh/libssh.h>
| ^~~~~~~~~~~~~~~~~
compilation terminated.
英文:
I installed libssh through vcpkg on my Windows 8.1 machine.
vcpkg install libssh
Now I am trying to compile my c++ code making use of libssh.
#include <libssh/libssh.h>
#include <stdlib.h>
int main()
{
ssh_session my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
...
ssh_free(my_ssh_session);
}
But I am receiving following error.
D:\remoteDesktopTimeZone>gcc sample.cpp -o sampl
sample.cpp:1:10: fatal error: libssh/libssh.h: No such file or directory
1 | #include <libssh/libssh.h>
| ^~~~~~~~~~~~~~~~~
compilation terminated.
答案1
得分: 1
首先,您应确保使用与您的编译器和架构匹配的正确“三元组”来安装库。
我不知道您的gcc是MingW还是Cygwin。
请参阅此处的说明。
其次,您可以按照此处描述的方法使用CMake,或者手动使用-I
和-L
命令行标志指定编译器在哪里查找库头文件和静态库。
英文:
First, you should ensure that you are installing libraries with correct "triplet" matching your compiler and architecture.
I don't know if your gcc is MingW or Cygwin.
See instructions here.
Second, you should either use CMake as described here, or manually point the compiler where to find the library headers and static libraries using the -I
and -L
command line flags.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论