【发布时间】:2015-03-03 17:40:25
【问题描述】:
我在 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
如何正确编译和链接库?
【问题讨论】:
-
试试
g++ yus.cpp -I/usr/local/include -L/usr/local/lib -lsbpl -
仍然给我同样的错误:(
-
是
/usr/local/include/还是usr/local/include?如果是usr/local/include试试g++ yus.cpp -Iusr/local/include -Lusr/local/lib -lsbpl -
标题中是否定义了
EnviromentType?我不太相信这个测试文件中的一次:github.com/sbpl/sbpl/blob/master/src/test/main.cppEnviromentType在主文件中定义
标签: c++ linux shared-libraries