首页 > 解决方案 > 如何用 C 编译 SoLoud 库的演示示例?

问题描述

我计划在我的 C 项目中使用 SoLoud 库 ( https://sol.gfxile.net/soloud/index.html )。我不明白如何编译包含在

/demos/c_test/ 

使其可执行。
有人可以帮助我了解如何使用 gcc 编译它吗?

标签: clinuxaudiocompilation

解决方案


在 demos/c_test/main.c 中,

我变了:

#include "soloud_c.h"  

#include "../../include/soloud_c.h"

并编译。但是,编译器会输出以下警告:

gcc -ggdb3 -Wall -Wextra -Wconversion -pedantic -std=gnu11 -c "main.c" -o "main.o"  main.c: 

In function ‘generate_sample’:

main.c:72:38: warning: conversion from ‘int’ to ‘float’ may change value [-Wconversion]
   72 |   buf[i] += (((rand() % 1024) - 512) / 512.0f) *
      |                                      ^

main.c:75:36: warning: conversion from ‘int’ to ‘float’ may change value [-Wconversion]
   75 |   float fade = (44100 * 10 - base) / (44100 * 10.0f);
      |                                    ^

main.c: In function ‘main’:

main.c:129:14: warning: unused parameter ‘parc’ [-Wunused-parameter]
  129 | int main(int parc, char ** pars)
      |          ~~~~^~~~

main.c:129:28: warning: unused parameter ‘pars’ [-Wunused-parameter]
  129 | int main(int parc, char ** pars)
      |                    ~~~~~~~~^~~~

Compilation finished successfully.

注意:我没有费心链接可执行文件,但是,我确实注意到了一些感兴趣的项目。

  1. 可用的库是 *.dll 文件,因此需要在 Windows 操作系统下编译/链接。
  2. 在“bin”目录下是库:soloud_x64.dll、soloud_x86.dll 和 SDL2.dll。我不知道您的特定计算机需要包含哪些库

推荐阅读