I wanted to test out Pocketsphinx in Node.JS. It says I need to install Swig version 3.0.7 or above.
我想在Node.JS中测试Pocketsphinx。它说我需要安装Swig版本3.0.7或以上。
I think I installed all the other dependencies correctly. I can even type Swig commands in the Terminal now, but I keep getting this error whenever I run npm install pocketsphinx
:
我认为我正确地安装了所有其他依赖项。现在我甚至可以在终端中输入Swig命令,但每次运行npm安装pocketsphinx时,我都会出现这个错误:
CMake Error at /usr/local/Cellar/cmake/3.6.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find SWIG (missing: SWIG_DIR) (Required is at least version
"3.0.7")
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.6.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.6.3/share/cmake/Modules/FindSWIG.cmake:75 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:4 (find_package)
I tried brew install swig
. I tried npm install swig
. I tried npm install -g swig
. I tried going to the swig download page and following the installation instructions, but nothing I seem to do stops the error from happening. I'm trying this on a Macbook by the way.
我尝试了brew安装swig。我尝试了npm安装swig。我尝试了npm安装-g swig。我试着去swig下载页面并按照安装说明执行,但是我似乎没有做任何事情可以阻止错误的发生。顺便说一下,我在Macbook上试试这个。
I really have no clue what I'm doing here. I just wanted to test out Pocketsphinx and now I've installed Swig in 4 different places, and CMake can't seem to recognise any of them.
我真的不知道我在这里做什么。我只是想测试Pocketsphinx,现在我在4个不同的地方安装了Swig, CMake似乎无法识别其中的任何一个。
Any help would be wonderful!
任何帮助都太棒了!
2 个解决方案
#1
1
Check the source code for the FindSwig.cmake
.
检查FindSwig.cmake的源代码。
Unfortunately, if a find script does not work as expected and you do not see right away why that is the case, you usually have to dig into its source. In your case, it looks like CMake was able to find and run the SWIG executable, but then failed to obtain the swig directory.
不幸的是,如果find脚本没有按照预期的那样工作,并且您没有立即看到为什么会这样,您通常需要深入挖掘它的源代码。在您的示例中,看起来CMake能够查找并运行SWIG可执行文件,但随后未能获得SWIG目录。
Try manually running swig -swiglib
and check that the printed directory indeed contains a swig.swg
file. Also, be sure that the swig executable found by CMake is actually the correct one (you can verify this by inspecting the value of SWIG_EXECUTABLE
in either the cmake-gui
, the ccmake
curses interface, or in the CMakeCache.txt
file directly).
尝试手动运行swig -swiglib并检查打印的目录是否包含swig。swg文件。另外,请确保CMake找到的swig可执行文件实际上是正确的(您可以在CMake -gui、ccmake curses接口或CMakeCache中检查swig_execution的值来验证这一点。txt文件直接)。
Note that CMake will not update the executable path once it has been found! So if you make changes to your system that influence the executable location, you will have to clear the cache (eg. by deleting the CMakeCache.txt
) and re-run CMake for the changes to take effect.
注意,一旦找到可执行路径,CMake将不会更新它!因此,如果您对影响可执行位置的系统进行了更改,则必须清除缓存(如:通过删除cmakec .txt)并重新运行CMake以使更改生效。
#2
0
I ended up trying to work it out for myself. The problem was when I typed npm install swig
.
我最终还是想自己解决这个问题。问题是当我输入npm安装swig时。
I forgot to set up this version of Swig, and the compiler was using it.
我忘了设置Swig的这个版本,编译器正在使用它。
I typed sudo npm uninstall swig
and it worked perfectly. I feel very stupid.
我输入了sudo npm卸载swig,效果很好。我觉得很愚蠢。
#1
1
Check the source code for the FindSwig.cmake
.
检查FindSwig.cmake的源代码。
Unfortunately, if a find script does not work as expected and you do not see right away why that is the case, you usually have to dig into its source. In your case, it looks like CMake was able to find and run the SWIG executable, but then failed to obtain the swig directory.
不幸的是,如果find脚本没有按照预期的那样工作,并且您没有立即看到为什么会这样,您通常需要深入挖掘它的源代码。在您的示例中,看起来CMake能够查找并运行SWIG可执行文件,但随后未能获得SWIG目录。
Try manually running swig -swiglib
and check that the printed directory indeed contains a swig.swg
file. Also, be sure that the swig executable found by CMake is actually the correct one (you can verify this by inspecting the value of SWIG_EXECUTABLE
in either the cmake-gui
, the ccmake
curses interface, or in the CMakeCache.txt
file directly).
尝试手动运行swig -swiglib并检查打印的目录是否包含swig。swg文件。另外,请确保CMake找到的swig可执行文件实际上是正确的(您可以在CMake -gui、ccmake curses接口或CMakeCache中检查swig_execution的值来验证这一点。txt文件直接)。
Note that CMake will not update the executable path once it has been found! So if you make changes to your system that influence the executable location, you will have to clear the cache (eg. by deleting the CMakeCache.txt
) and re-run CMake for the changes to take effect.
注意,一旦找到可执行路径,CMake将不会更新它!因此,如果您对影响可执行位置的系统进行了更改,则必须清除缓存(如:通过删除cmakec .txt)并重新运行CMake以使更改生效。
#2
0
I ended up trying to work it out for myself. The problem was when I typed npm install swig
.
我最终还是想自己解决这个问题。问题是当我输入npm安装swig时。
I forgot to set up this version of Swig, and the compiler was using it.
我忘了设置Swig的这个版本,编译器正在使用它。
I typed sudo npm uninstall swig
and it worked perfectly. I feel very stupid.
我输入了sudo npm卸载swig,效果很好。我觉得很愚蠢。