我对C编程非常陌生,并且以前没有使用过Visual Studio或第三方库.我正在尝试使用FMOD做一些简单的事情,需要链接fmodvclib,fmod.h,当然还有fmod.dll.
I am fairly new to C programming and I haven't used Visual Studio or a third party library before. I'm trying to do something simple with FMOD and need to link fmodvclib, fmod.h, and of course fmod.dll.
我已经将fmodex_vc.lib放在了其他依赖项中,并在包含和库目录以及其他包含库中提供了低级库的路径,但是在我构建时,它给出了我的答案:
I've put fmodex_vc.lib in the additional dependencies and the path to the low level libraries in the include and library directories as well as additional include libraries but when I build it gives me:
"cannot open source file "fmod.h" identifier "FSOUND_SAMPLE" is undefined Cannot open include file: 'fmod.h': No such file or directory但更奇怪的是:
cannot open source file "stdio.h"下面是代码:
#include "fmod.h" #include <stdio.h> FSOUND_SAMPLE* handle; int main(void) { int input; FSOUND_Init(44100, 32, 0); handle = FSOUND_Sample_Load(0, "test.ogg", 0, 0, 0); FSOUND_PlaySound(0, handle); while (input != 0) { scanf_s("&d", &input); } FSOUND_Sample_Free(handle); FSOUND_Close(); }任何帮助将不胜感激!
推荐答案要链接到第三方库,通常需要做三件事:
To link against third party libraries you usually have to do 3 things:
1.您必须添加包含目录".
在Project > Properties > C/C++->General > Additional Include Directories
单击编辑",然后输入文件"fmod.h"所在的目录的路径.
Click Edit, and enter the path to the directory where the file "fmod.h" is located.
2.您必须链接到* .lib文件.
在Project > Properties > Linker > General > Additional Library Directories中,单击编辑",然后输入库文件的路径.
In Project > Properties > Linker > General > Additional Library Directories, click Edit and enter the path to your library files.
在Project > Properties > Linker > Input > Additional Dependencies中,单击编辑",添加要链接的库的文件名(在这种情况下,很可能是"fmodvc.lib")
In Project > Properties > Linker > Input > Additional Dependencies, click Edit, add the filename of the library you want to link against (in this case this would be most likely "fmodvc.lib")
3.您必须在项目目录中提供* .dll
您的程序将成功运行,必须在运行时找到*.dll文件.您可以将其放置在PATH变量引用的文件夹中,也可以放置在进程的PWD中.这将在您的*.vcxproj文件旁边.
That your programm will run successfully it has to find the *.dll file at runtime. You can either place it in a folder referenced by the PATH variable, or in the PWD of your process. This would be right beside your *.vcxproj files.
如果您是静态链接,则可以跳过第3步;如果动态地加载dll文件,则可以跳过第2步.
If you are linking statically you can skip step 3, if you are loading the dll file dynamically you can skip step 2.
更多推荐
在Visual Studio中编译和链接第三方库
发布评论