我正在尝试使用 RtAudio 生成流式音频。但是,当我尝试包含“RtAudio.h”文件时,程序总是抱怨一些奇怪的东西。我的项目结构如下:
- 项目
- 音频
- CMakeList1
- RtAudio.h
- 演示
- 主文件
- CMakeList2
- 制作清单
- 音频
基本上,文件夹 rtaudio 是我从这里安装的存储库,CMakeList1 也是从那里安装的。
主文件夹下的 CMakeList:
cmake_minimum_required(VERSION 2.8)
# Add -Wall and -Wextra. Also,
# treat C/C++ warnings as errors if -DADM_FATAL_WARNINGS=ON.
include (cmake/FatalWarnings.cmake)
ADM_EXTRA_WARNINGS()
add_subdirectory(demos)
CMakeList2:
project(malos_service C CXX)
cmake_minimum_required(VERSION 2.8)
add_definitions(-std=c++11)
FIND_LIBRARY(WIRINGPI_LIB NAMES wiringPi)
....
set(AUDIO_LIBRARY_FOUND OFF)
find_path(RTAUDIO_HEADER_PATH "RtAudio.h" HINTS ../rtaudio)
if(RTAUDIO_HEADER_PATH)
message(STATUS "Compiling provided rtaudio-library!")
add_subdirectory(../rtaudio rtaudio)
add_definitions(-DRTAUDIO_HEADER="../rtaudio/RtAudio.h")
set(AUDIO_LIBRARY_FOUND ON)
endif()
if (NOT AUDIO_LIBRARY_FOUND)
message(SEND_ERROR "no supported library")
endif()
# Check if any audio-library was added
if(NOT AUDIO_LIBRARY_FOUND)
message(SEND_ERROR "No supported audio-library found!")
endif()
....
add_executable(...)
要编译这些,在 Project 文件夹下,
mkdir build
cd build
cmake ..
make
主要是,我只是添加:
#include "../rtaudio/RtAudio.h"
在我编译make之后,我会得到很多错误:
In file included from ~/Project/demos/main.cpp:7:0:
/home/pi/Downloads/Project/demos/../rtaudio/RtAudio.h:729:5: error: expected identifier before numeric constant
OUTPUT,
^
/home/pi/Downloads/Project/demos/../rtaudio/RtAudio.h:729:5: error: expected ‘}’ before numeric constant
/home/pi/Downloads/Project/demos/../rtaudio/RtAudio.h:729:5: error: expected unqualified-id before numeric constant
In file included from /home/pi/Downloads/Project/demos/main.cpp:25:0:
/home/pi/Downloads/Project/demos/../rtaudio/RtAudio.h: In member function ‘bool RtApi::isStreamOpen() const’:
/home/pi/Downloads/Project/demos/../rtaudio/RtAudio.h:709:44: error: ‘stream_’ was not declared in this scope
bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; }
...
*PS:如果我直接cmake rtaudio,rtaudio下的程序都可以运行,这意味着错误不应该来自rtaudio *(希望)
我cmake的方式有问题吗?有人知道如何解决这个问题吗?