使用第三方库(sbpl)

时间:2015-03-03 17:40:26

标签: c++ linux shared-libraries

我在linux \ ubuntu上构建并安装了一个名为sbpl的库。安装后我有以下文件:

usr/local/include/sbpl(这里有一堆文件,包括headers.h文件)

usr/local/liblibsbpl.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

如何正确编译和链接库?

1 个答案:

答案 0 :(得分:0)

enum EnvironmentType的定义从main.cpp移至headers.h,然后运行g++ yus.cpp -I/usr/local/include -L/usr/local/lib -lsbpl