g ++找不到已安装的库

时间:2015-10-28 16:35:43

标签: c++ path compilation g++

我正在尝试编译需要所需库libmusicxml的示例文件。

我按照他们的说法(cmake,make,make install)编译了库,并制作并安装了一堆文件:

Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libmusicxml2.so.3.00
-- Installing: /usr/local/lib/libmusicxml2.so
-- Installing: /usr/local/include/libmusicxml/musicxmlfactory.h
-- Installing: /usr/local/include/libmusicxml/sortvisitor.h
-- Installing: /usr/local/include/libmusicxml/xmlreader.h
... etc

现在我想编译他们的一个示例文件,所以我运行g + filename.cpp,它给了我以下错误:

libmusicxml.h: No such file or directory

这是否意味着它没有在/ usr / local中看到库?我可以在某处指定吗?设置路径或什么?

我已确保从here获得最新版本的libmusicxml库并执行相同的操作(cmake后跟make)。

当我去提供示例并尝试制作一个(使用提供的make文件,根据开发人员工作)时,它不想这样做:

dorien@XP:~/bin/libmusicxml-master/samples$ make
gcc -g -O3 -Wall -Wuninitialized -I../src/elements -I../src/interface -I../src/files -I../src/lib -I../src/parser -I../src/visitors -I../src/guido -I../src/operations countnotes.cpp ../libmusicxml2.a -lstdc++ -o countnotes
gcc: error: ../libmusicxml2.a: No such file or directory
Makefile:14: recipe for target 'countnotes' failed

- >我试图找到libmusicxml2.a,但这似乎不存在。

当我运行xml2guido(它似乎在包的根目录中有一个编译版本)时,我得到:

xml2guido: error while loading shared libraries: libmusicxml2.so.3.00: cannot open shared object file: No such file or directory

但是,同一目录中有一个libmusicxml2.so.3.00

也许是因为包没有正确链接?或者关于丢失的.a文件的内容?

我确实认为它构建正确:

 make
[ 73%] Built target musicxml2
[ 75%] Built target RandomMusic
[ 78%] Built target countnotes
[ 80%] Built target partsummary
[ 82%] Built target readunrolled
[ 85%] Built target xml2guido
[ 87%] Built target xml2midi
[ 90%] Built target xmlclone
[ 92%] Built target xmlfactory
[ 95%] Built target xmliter
[ 97%] Built target xmlread
[100%] Built target xmltranspose

dorien@XP:~/bin/libmusicxml-master$ sudo make install
[ 73%] Built target musicxml2
[ 75%] Built target RandomMusic
[ 78%] Built target countnotes
[ 80%] Built target partsummary
[ 82%] Built target readunrolled
[ 85%] Built target xml2guido
[ 87%] Built target xml2midi
[ 90%] Built target xmlclone
[ 92%] Built target xmlfactory
[ 95%] Built target xmliter
[ 97%] Built target xmlread
[100%] Built target xmltranspose
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/local/lib/libmusicxml2.so.3.00
-- Up-to-date: /usr/local/lib/libmusicxml2.so
-- Up-to-date: /usr/local/include/libmusicxml/musicxmlfactory.h
-- Up-to-date: /usr/local/include/libmusicxml/sortvisitor.h
-- Up-to-date: /usr/local/include/libmusicxml/xmlreader.h
-- Up-to-date: /usr/local/include/libmusicxml/xmlfile.h
-- Up-to-date: /usr/local/include/libmusicxml/libmusicxml.h
-- Up-to-date: /usr/local/include/libmusicxml/unrolled_xml_tree_browser.h
-- Up-to-date: /usr/local/include/libmusicxml/xml.h
-- Up-to-date: /usr/local/include/libmusicxml/elements.h
-- Up-to-date: /usr/local/include/libmusicxml/factory.h
-- Up-to-date: /usr/local/include/libmusicxml/types.h
-- Up-to-date: /usr/local/include/libmusicxml/typedefs.h
-- Up-to-date: /usr/local/include/libmusicxml/xml_tree_browser.h
-- Up-to-date: /usr/local/include/libmusicxml/versions.h
-- Up-to-date: /usr/local/include/libmusicxml/exports.h

2 个答案:

答案 0 :(得分:1)

  

这是否意味着它没有在/ usr / local中看到库?

这意味着它找不到标题libmusicxml.h。您没有告诉编译器在/usr/local/include/libmusicxml中查找它。

  

我可以在某处指定吗?设置路径或什么?

请参阅编译器的文档。在gcc中,包含搜索路径的选项为-I

我建议不要从libmusicxml.h搜索标题/usr/local/include/libmusicxml/,而是要libmusicxml/libmusicxml.h并从/usr/local/include搜索。这会更简单,因为默认情况下g ++从/usr/local/include搜索,因此不需要编译器选项。

答案 1 :(得分:0)

在我跑步之前,图书馆(和标题)都没有被识别出来:

export LD_LIBRARY_PATH=/addressto/libmusicxml-master

修复了它。