我已经在 linux\ ubuntu 上构建并安装了一个名为sbpl的库。安装后,我有以下文件:
usr/local/include/sbpl
(这里有一堆文件,包括一个headers.h
文件)
usr/local/lib
has alibsbpl.so
file
现在我有一些麻烦编译一个简单的程序:
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
本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处
评论列表(22条)