這是我第一次在C. im的項目中工作,只是想創建一個SSH客戶端。libssh2 C編譯
我的代碼libssh2網站
http://www.libssh2.org/examples/ssh2.html
複製但是當我運行此我得到下面的錯誤?
main.o: In function `main':
main.c:(.text+0xbe): undefined reference to `libssh2_init'
main.c:(.text+0x1a7): undefined reference to `libssh2_session_init_ex'
main.c:(.text+0x1bf): undefined reference to `libssh2_session_startup'
main.c:(.text+0x209): undefined reference to `libssh2_hostkey_hash'
main.c:(.text+0x282): undefined reference to `libssh2_userauth_list'
main.c:(.text+0x3e3): undefined reference to `libssh2_userauth_password_ex'
main.c:(.text+0x443): undefined reference to `libssh2_userauth_keyboard_interactive_ex'
main.c:(.text+0x4b9): undefined reference to `libssh2_userauth_publickey_fromfile_ex'
main.c:(.text+0x529): undefined reference to `libssh2_channel_open_ex'
main.c:(.text+0x58d): undefined reference to `libssh2_channel_setenv_ex'
main.c:(.text+0x5d9): undefined reference to `libssh2_channel_request_pty_ex'
main.c:(.text+0x633): undefined reference to `libssh2_channel_process_startup'
main.c:(.text+0x674): undefined reference to `libssh2_channel_free'
main.c:(.text+0x6a0): undefined reference to `libssh2_session_disconnect_ex'
main.c:(.text+0x6ac): undefined reference to `libssh2_session_free'
main.c:(.text+0x6c9): undefined reference to `libssh2_exit'
collect2: ld returned 1 exit status
我知道有一些庫連接問題。我使用Netbeans作爲我的IDE,並且相對比較新。任何人都可以請指導我。我在互聯網上搜索了很多,但大多數回覆與使用gcc在命令中編譯的代碼有關。如果有人可以幫助Netbeans。
libssh2已安裝。你的方法在命令行上工作。仍然無法弄清netbeans –
我也想知道-lssh2的邏輯是什麼?我的意思是你怎麼知道這個關鍵字。 –
因爲它是libssh2。編譯器標誌是-l後面跟着沒有'lib'的lib名稱。例如,如果你想包含數學庫(libm),你可以添加標誌-lm – nmat