我已经在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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句