![](/img/trans.png)
[英]Include third-party header and library using makefile and VS Code
[英]Using a third party library (sbpl)
我已經在linux \\ ubuntu上建立並安裝了一個名為sbpl的庫。 安裝后,我有以下文件:
usr/local/include/sbpl
(這里有一堆文件,包括headers.h
文件)
usr/local/lib
有一個libsbpl.so
文件
現在我在編譯一個簡單程序時遇到了一些麻煩:
yus.cpp
#include <iostream>
#include <sbpl/headers.h>
int main()
{
EnvironmentType type;
return 0;
}
使用這些命令進行編譯會出現錯誤:
$ g++ yus.cpp -Iusr/local/include/sbpl gives the following error
"error: 'EnvironmentType' was not declared in this scope"
$ g++ yus.cpp -L.-lsbpl gives the same error as above
如何正確編譯和鏈接庫?
將enum EnvironmentType
的定義從main.cpp移動到headers.h,然后運行g++ yus.cpp -I/usr/local/include -L/usr/local/lib -lsbpl
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.