我正在埃斯兰环境中使用libsndfile运行一些代码。
#include <iostream>
#include <sndfile.h>
int main()
{
SF_INFO info;
const char * path = "~/data/somefile.wav";
SNDFILE* sf = sf_open(path,SFM_READ, &info);
if(sf == NULL)
{
std::cout<< sf_strerror(sf) << std::endl;
return 1;
}
std::cout<<info.samplerate<<std::endl;
std::cout<<"Hello world" << std::endl;
}因此,理想情况下,如果我使用普通的cmake (Apple编译器)运行,所有操作都正常,那么samplerate和hello world就会被打印出来,但是当我用emcmake cmake (em++编译器)运行它并运行编译后的node main.js文件时,它说是System error: no such file or directory。谁能帮我这个忙?谁经历过这样的事情?
发布于 2021-12-16 12:43:25
所以我想明白了。
问题是埃斯兰有它的虚拟文件环境。因此,如果希望上传该文件,并在编译后的.js文件中看到该文件,则需要添加编译标志--preload-file <FILE_PATH>,之后,带有给定路径的文件将被emscripten环境识别。
https://stackoverflow.com/questions/70378742
复制相似问题