ubuntuで外部ライブラリをc ++に手動でリンクしようとしています。これは私の最初の C++ プロジェクトであるため、いくつかの基本事項が欠けています。これは私のコードです(これはスプレッドに接続しようとします):
#include <iostream>
#include <sp.h>
using namespace std;
int main() {
int status;
status = SP_connect("4803@localhost", "test1", 0, 0, 0, 0);
cout << "done\n";
return 0;
}
で実行しようとすると
user@computer:~/thesis$ g++ -o example1 test.cpp
/tmp/cczPLZQ0.o: In function `main':
test.cpp:(.text+0x39): undefined reference to `SP_connect'
collect2: ld returned 1 exit status
ライブラリをリンクする必要があることを理解している限り、-l を使用して実行しようとしました
kristjan@kupo:~/thesis$ g++ -o example1 test.cpp -llibspread
/usr/bin/ld: cannot find -llibspread
collect2: ld returned 1 exit status
私もこれを試しました(ここでは暗闇で撮影しています):
user@computer:~/thesis$ g++ -o example1 test.cpp $(pkg-config -cflags /usr/local/lib/libspread) $(pkg-config --libs /usr/local/lib/libspread)
-cflags: unknown option
Package /usr/local/lib/libspread was not found in the pkg-config search path.
Perhaps you should add the directory containing `/usr/local/lib/libspread.pc'
to the PKG_CONFIG_PATH environment variable
No package '/usr/local/lib/libspread' found
/tmp/ccU8GTC2.o: In function `main':
test.cpp:(.text+0x39): undefined reference to `SP_connect'
collect2: ld returned 1 exit status
どんな助けでも大歓迎です。