我正在尝试编译和示例文件,该文件需要所需的库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

最佳答案

这是否意味着在/ 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搜索,因此不需要编译器选项。

关于c++ - g++找不到已安装的库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33396602/

10-16 04:57