2014-03-25 36 views
1

早些时候,我在Ubuntu 13.10上使用cmake成功编译了Stasm。它给了我静态库libstasm.a。 不过,我尝试使用Stasm代码,但每次我试图G ++的时间来建立自己的节目给了我这样的:如何将静态Stasm库链接到我的程序?

[email protected]:~/Desktop$ g++ -Wall -L/home/hanna/Downloads/stasm4.1.0/build -lstasm stasmtest.cpp -o stasmtest 
stasmtest.cpp:7:23: fatal error: stasm_lib.h: No such file or directory 
#include "stasm_lib.h" 
       ^
compilation terminated. 

我试图编译在外部库中的Minimal.cpp例子,因为这是为了显示如何在我自己的程序中使用Stasm,但仍然会出现同样的错误。

有人能告诉我什么命令我应该用来链接Stasm库到我的程序?

在此先感谢!

+0

Fritzone的回答给了我一些进展。我添加了-I和-L标志。然而,然后我得到了'stasm_search_single'和其他库函数的未定义引用。原来,我把错误的顺序放在旗帜上。 对于任何感兴趣的人,我的代码使用这个命令编译: 'g ++ file.cpp -Wall -I/direction/to/includes -L/direction/to/libraries -lstasm -o file'pkg-config --cflags - libs opencv'(包括pkg-config部分,代码格式是关闭的) –

+0

对不起,应该是:'g ++ file.cpp -Wall -I/direction/to/includes -L/direction/to/libraries - lstasm -o file \'pkg-config --cflags --libs opencv \'' –

回答

2

您收到编译错误,而不是链接错误。 g ++找不到“stasm_lib.h”标题。使用-I/path/to/stasm_lib.h作为g ++的参数。