C++:Undefined reference to 'FMOD:: X'

…衆ロ難τιáo~ 提交于 2019-11-28 12:55:34
Mathew Block

When using FMOD with Code::Blocks you need to use the C API, not the C++ API. FMOD is built with Visual Studio, therefore the C++ symbols use the VC mangling scheme. There is a note in the "Getting Started with FMOD for Windows" document that mentions this.

http://en.wikipedia.org/wiki/Name_mangling#How_different_compilers_mangle_the_same_functions

I do not have a Windows box ready to verify this on, but try replacing those backslashes with forward slashes in the include paths, or escape the backslashes.

#include <D:/Games/FMOD Programmers API Win32/api/inc/fmod.hpp>
#include <D:/Games/FMOD Programmers API Win32/api/inc/fmod_errors.h>

or

#include <D:\\Games\\FMOD Programmers API Win32\\api\\inc\\fmod.hpp>
#include <D:\\Games\\FMOD Programmers API Win32\\api\\inc\\fmod_errors.h>

(Or, better, just add D:\Games\FMOD Programmers API Win32\api\inc\ to your list of include paths, and include the files by filename instead of full path; then your code might actually compile somewhere other than your specific computer!)

Those undefined reference errors mean that the compiler, or rather the linker part of the compiler, cannot find the library.

I don't use Code::Blocks so I don't know where the setting is, but you need to tell your project to use the library and where to find it.

Just putting the DLL in the directory is enough for running the program, but for linking it you need a .lib file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!