1
우분투에서 외부 라이브러리를 C++과 수동으로 연결하려고합니다. 이것이 처음 C++ 프로젝트이기 때문에 몇 가지 기본 사항을 놓치고 있습니다. 이 내 코드입니다 (이 확산 연결을 시도) :우분투의 g ++에서 라이브러리를 수동으로 링크하는 방법
#include <iostream>
#include <sp.h>
using namespace std;
int main() {
int status;
status = SP_connect("[email protected]", "test1", 0, 0, 0, 0);
cout << "done\n";
return 0;
}
난 그냥 지금까지 내가 라이브러리를 링크해야 이해
[email protected]:~/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
그것을 실행하려고하면, 나는 시도 (내가 여기 어둠 속에서 촬영 해요) 나는 또한이 시도
[email protected]:~/thesis$ g++ -o example1 test.cpp -llibspread
/usr/bin/ld: cannot find -llibspread
collect2: ld returned 1 exit status
-l와 함께 할 수 있습니다 :
[email protected]:~/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
도움을 주시면 감사하겠습니다.
.so 파일이 표준 위치에 있으면'-lspread'가 올바른 옵션이됩니다. – Mat
-libread의 lib를 건너 뛰고 -lspread를 사용하십시오. – gulyan