-
Hello, I'm trying to build a DLL (on Windows-x64/VS2022) of miniaudio so that I can use in a Unity project, but I'm pretty new to the process. After reading the readme and the docs, I'm not entirely sure on how to do it as I'm getting linker errors in an extern API.
The basic idea is that all I want to do for now is compile a working DLL where I call // in framework.h
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
#include "miniaudio.h"
#ifdef AUDIO_EXPORTS
#define AUDIO_API __declspec(dllexport)
#else
#define AUDIO_API __declspec(dllimport)
#endif
extern "C" {
AUDIO_API void init_engine_on_stack();
}
// in framework.cpp
#include "pch.h"
#include "framework.h"
#include "miniaudio.h"
void init_engine_on_stack() {
ma_result result;
ma_engine engine;
result = ma_engine_init(NULL, &engine);
if (result != MA_SUCCESS) {
return;
}
} I've added a link of the visual studio project I'm working on, but I'm not really sure what I'm missing here. Any tips and advice is appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
That linking error is happening because you haven't included the implementation of miniaudio anywhere. Add #define MINIAUDIO_IMPLEMENTATION
#include "miniaudio.h" Alternatively, consider using the split version if you'd rather use a traditional .c and .h pair: https://github.com/mackron/miniaudio/tree/master/extras/miniaudio_split |
Beta Was this translation helpful? Give feedback.
That linking error is happening because you haven't included the implementation of miniaudio anywhere. Add
#define MINIAUDIO_IMPLEMENTATION
:Alternatively, consider using the split version if you'd rather use a traditional .c and .h pair: https://github.com/mackron/miniaudio/tree/master/extras/miniaudio_split