查询:将libsndfile与Visual Studio 2010 C ++集成。错误:找不到libsndfile.dll [英] Inquiry: Integrating libsndfile with Visual Studio 2010 C++. Error: libsndfile.dll not found

查看:197
本文介绍了查询:将libsndfile与Visual Studio 2010 C ++集成。错误:找不到libsndfile.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为我学习C ++的一部分,我正在教自己如何将wav文件读入C ++。我在网上找到了很多推荐以下库的资源: libsnfile库
所以我按照下面的一些教程测试了库的基本功能,但是我无法使该库与Visual Studio 2010一起编译。



我在网上搜索了以下内容错误,但没有发现对我的特定错误有用的任何信息。我在此处下载了libsndfile C ++ Windows安装程序。我使用的是32位版本,因为我使用的是win32 C ++控制台版本。但是,我的Visual Studio是64位。下载安装程序后,我做了以下工作:



我进入了Visual Studio。在我的项目下,我执行了以下操作:



在项目属性中:
1. VC ++



包括>>添加... \libsnfile\包括
库>>添加... \libsnfile\lib
2。 C\C ++
添加了以下目录作为其他依赖项

... \libsnfile\lib\libsndfile-1.lib



我这样做是为了将第三方库添加到我的项目中。此后,要测试,我运行了以下代码:

  #include stdafx.h 
#include< ; stdio.h>
#include< stdlib.h>
#include< sndfile.h>

int _tmain(int argc,_TCHAR * argv [])
{
printf( This is a test\n);

getchar();
返回0;
}

我对此进行了编码,以确保可以访问sndfile.h程序和一切编译。当我尝试实现以下代码时发生了问题:

  #include stdafx.h 
#include< ; stdio.h>
#include< stdlib.h>
#include< sndfile.h>

int _tmain(int argc,_TCHAR * argv [])
{
printf( This is a test\n);


//这是程序处理样本时用于保存样本的缓冲区的长度。


// SNDFILE类似于标准C库中的FILE。因此,当sf_open_read和sf_open_write函数成功打开指定文件时,它们将返回
// SNDFILE *指针。
SNDFILE * sf = NULL;

/ * SF_INFO将获取我们希望加载到程序中的文件的信息。 * /
SF_INFO信息;


/ *这是程序将打开WAV文件的位置* /
info.format = 0;
sf = sf_open( C:\Users\GeekyOmega\Desktop\gameon.wav,SFM_READ,& info);
if(sf == NULL)
{
printf(无法打开文件。\n);
出口(-1);
}

getchar();
返回0;
}

当我尝试在Visual Studio中单击运行时,出现系统错误运行我的程序。它说,

 该程序无法启动,因为您的计算机缺少libsnfile-1.dll。 
尝试重新安装程序以解决此问题。`

我尝试了64位Windows安装程序并尝试了一下,但没有成功。有人知道我在做什么吗?我正在Windows 7上运行Visual Studio 2010,作为我的开发环境。正如我在上面所述,我尝试了一些hacky修复,但是没有任何效果。



编辑:我也知道此线程此处,但这对我当前的问题没有任何意义,因为我没有做他们正在谈论的任何有关这种途径的事情。



温暖的问候,
GeekyOmega

解决方案

我已修复问题。我认为对于未来的读者来说,这是一个非常普遍的问题。我将.dll放置在Visual Studio项目的debug文件夹中。否则,Visual Studio将看不到.dll文件。此后,程序按预期启动并运行。如果这不能为您解决问题,那么我建议可能会发生其他事情。


I am teaching myself how to read in wav files into C++ as a part of me learning C++. I have found many resources online that recommended the following library: libsnfile library So I followed some tutorials below in testing the basic functionality of the library, but I can't get the library to compile with Visual Studio 2010.

I have searched online for the following error, but did not find anything useful for my particular error. I downloaded the libsndfile C++ windows installer found here. I used the 32bit version since I am using the win32 C++ console version. However, my Visual Studio is 64 bit. I did the following after I downloaded the installer:

I went into Visual Studio. Under my project, I did the following:

In project properties: 1. VC++

Include >> added ...\libsnfile\include Library >> added ...\libsnfile\lib 2. C\C++ Added the following directory as additional dependencies
...\libsnfile\lib\libsndfile-1.lib

I did this to add this third party library to my project. After this, to test, I ran the following code:

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <sndfile.h>

int _tmain(int argc, _TCHAR* argv[])
{
    printf("This is a test\n");

   getchar();
   return 0; 
}

I coded that to make sure that I could access the sndfile.h in my program and everything compiled. The problem occured when I tried to implement the following code:

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <sndfile.h>

int _tmain(int argc, _TCHAR* argv[])
{
    printf("This is a test\n");


    //This will be the length of the buffer used to hold samples while the program processes them. 


    //A SNDFILE is like FILE in a standard C library. Consequently, the sf_open_read and sf_open_write functions will return an 
    //SNDFILE* pointer when they successfully open the specified file. 
    SNDFILE* sf = NULL; 

    /*SF_INFO will obtain information of the file we wish to load into our program. */
    SF_INFO info; 


    /*This is where the program will open the WAV file */
    info.format = 0; 
    sf = sf_open("C:\Users\GeekyOmega\Desktop\gameon.wav", SFM_READ, &info);
    if(sf == NULL)
    {
        printf("Failed to open the file.\n");
        exit(-1);
    }

    getchar();
    return 0;
}

I then get a system error when I click run inside visual studio when I try to run my program. It says,

The program can't start because libsnfile-1.dll is missing from your computer. 
Try reinstalling the program to fix this problem.` 

I tried the 64 bit windows installer and tried that, but it didn't work. Anyone understand what I am doing run? I am running Visual Studio's 2010 on Windows 7 as my dev environment.

I apologize if I am making a silly mistake, but I would deeply appreciate if anyone could help me. I tried a few hacky fixes, as I talked about above, but nothing has worked.

EDIT: I am also aware of this thread here, but this doesn't make any sense to my current issue as I am not doing any of this path stuff that they are talking about.

Warm Regards, GeekyOmega

解决方案

I fixed the issue. For future readers, this is a very common problem, I think. I placed the .dll in the debug folder of my Visual Studio project. Visual Studio couldn't see the .dll file otherwise. After this, the program fired up as expected and ran. If this does not fix the issue for you, then I suggest something else could be going on.

这篇关于查询:将libsndfile与Visual Studio 2010 C ++集成。错误:找不到libsndfile.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆