我已经尝试了一段时间,将portaudio包含到我的c++项目中,但是似乎存在一些问题,因为我的项目不“知道” portaudio命名空间,而是qt自动完成函数名称,就好像它知道它们一样。

源目录:

├── CMakeLists.txt
├── CMakeLists.txt.user
└── src
    ├── CMakeLists.txt
    ├── include
    │   ├── CMakeLists.txt
    │   ├── database
    │   │   ├── CMakeLists.txt
    │   │   ├── database.cpp
    │   │   └── database.h
    │   ├── match
    │   │   ├── CMakeLists.txt
    │   │   ├── match.cpp
    │   │   └── match.h
    │   ├── record
    │   │   ├── CMakeLists.txt
    │   │   ├── record.cpp
    │   │   └── record.h
    │   └── spectogram
    │       ├── CMakeLists.txt
    │       ├── spectogram.cpp
    │       └── spectogram.h
    └── main.cpp

portaudio教程建议在Linux环境中构建portaudio,需要从portaudio源文件中复制当前驻留在audio / portaudio中的文件,这显然足够了。
CMakeLists.txt within record:
MESSAGE( “In reord CMAKELIST” )
MESSAGE(":" <Project_source_dir> )
# Include externalproject {portaudio} if lib/portaudio don't exist.

INCLUDE(ExternalProject)
ExternalProject_Add(project_portaudio
    GIT_REPOSITORY      https://git.assembla.com/portaudio.git
    PREFIX              lib/portaudio
    UPDATE_COMMAND      ""
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure
    BUILD_IN_SOURCE     0
    BUILD_COMMAND       make
    INSTALL_COMMAND     sudo make install
)
ExternalProject_Get_Property(project_portaudio BINARY_DIR)
ExternalProject_Get_Property(project_portaudio SOURCE_DIR)

SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")
SET(portaudio_inc_dir "${SOURCE_DIR}/include")

add_library(record STATIC record.cpp record.h)

add_library(portaudio STATIC IMPORTED)
set_target_properties(portaudio PROPERTIES
    IMPORTED_LOCATION "${portaudio_lib_dir}/libportaudio.a")

set_property(TARGET portaudio APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include)

add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though

find_package(Threads REQUIRED)
find_package(ALSA REQUIRED)

IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
   SET(EXTRA_LIBS rt asound jack)
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")

#
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)
target_link_libraries(record PUBLIC  ${EXTRA_LIBS} Threads::Threads portaudio)
target_compile_features(record PUBLIC cxx_defaulted_functions)
target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})

main.cpp:
#include <iostream>
#include "record.h"

using namespace std;

int main()
{
    record test;
    test.example();

    cout << "Hello World!" << endl;
    return 0;
}

record.cpp:
#include "record.h"

record::record()
{
    std::cout << "Record Created!" << std::endl;
}

void record::example()
{
    std::cout << "In example!" << std::endl;
    std::cout << Pa_GetVersion() << std::endl;
}

记录
#ifndef RECORD_H
#define RECORD_H
#include <iostream>
#include "portaudio.h"

class record
{
public:
    record();
    void example();
};

#endif // RECORD_H

我尝试将portaudio包含到我的记录类中,然后查看它是否了解portaudio函数(例如Pa_getversion ..),但相反,我似乎得到了以下错误消息:
/home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:421: undefined reference to `snd_pcm_hw_params_set_buffer_size_near'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:422: undefined reference to `snd_pcm_hw_params_set_buffer_size_min'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:424: undefined reference to `snd_pcm_hw_params_set_period_size_near'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:425: undefined reference to `snd_pcm_hw_params_set_periods_integer'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:426: undefined reference to `snd_pcm_hw_params_set_periods_min'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:428: undefined reference to `snd_pcm_hw_params_get_buffer_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:433: undefined reference to `snd_pcm_hw_params_get_channels_min'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:434: undefined reference to `snd_pcm_hw_params_get_channels_max'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:436: undefined reference to `snd_pcm_hw_params_test_period_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:437: undefined reference to `snd_pcm_hw_params_test_format'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:438: undefined reference to `snd_pcm_hw_params_test_access'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:439: undefined reference to `snd_pcm_hw_params_dump'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:440: undefined reference to `snd_pcm_hw_params'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:442: undefined reference to `snd_pcm_hw_params_get_periods_min'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:443: undefined reference to `snd_pcm_hw_params_get_periods_max'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:444: undefined reference to `snd_pcm_hw_params_set_period_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:445: undefined reference to `snd_pcm_hw_params_get_period_size_min'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:446: undefined reference to `snd_pcm_hw_params_get_period_size_max'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:447: undefined reference to `snd_pcm_hw_params_get_buffer_size_max'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:448: undefined reference to `snd_pcm_hw_params_get_rate_min'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:449: undefined reference to `snd_pcm_hw_params_get_rate_max'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:450: undefined reference to `snd_pcm_hw_params_get_rate_numden'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:452: undefined reference to `snd_pcm_sw_params_sizeof'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:453: undefined reference to `snd_pcm_sw_params_malloc'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:454: undefined reference to `snd_pcm_sw_params_current'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:455: undefined reference to `snd_pcm_sw_params_set_avail_min'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:456: undefined reference to `snd_pcm_sw_params'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:457: undefined reference to `snd_pcm_sw_params_free'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:458: undefined reference to `snd_pcm_sw_params_set_start_threshold'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:459: undefined reference to `snd_pcm_sw_params_set_stop_threshold'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:460: undefined reference to `snd_pcm_sw_params_get_boundary'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:461: undefined reference to `snd_pcm_sw_params_set_silence_threshold'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:462: undefined reference to `snd_pcm_sw_params_set_silence_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:463: undefined reference to `snd_pcm_sw_params_set_xfer_align'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:464: undefined reference to `snd_pcm_sw_params_set_tstamp_mode'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:466: undefined reference to `snd_pcm_info'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:467: undefined reference to `snd_pcm_info_sizeof'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:468: undefined reference to `snd_pcm_info_malloc'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:469: undefined reference to `snd_pcm_info_free'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:470: undefined reference to `snd_pcm_info_set_device'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:471: undefined reference to `snd_pcm_info_set_subdevice'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:472: undefined reference to `snd_pcm_info_set_stream'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:473: undefined reference to `snd_pcm_info_get_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:474: undefined reference to `snd_pcm_info_get_card'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:476: undefined reference to `snd_ctl_pcm_next_device'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:477: undefined reference to `snd_ctl_pcm_info'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:478: undefined reference to `snd_ctl_open'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:479: undefined reference to `snd_ctl_close'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:480: undefined reference to `snd_ctl_card_info_malloc'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:481: undefined reference to `snd_ctl_card_info_free'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:482: undefined reference to `snd_ctl_card_info'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:483: undefined reference to `snd_ctl_card_info_sizeof'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:484: undefined reference to `snd_ctl_card_info_get_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:486: undefined reference to `snd_config'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:487: undefined reference to `snd_config_update'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:488: undefined reference to `snd_config_search'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:489: undefined reference to `snd_config_iterator_entry'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:490: undefined reference to `snd_config_iterator_first'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:491: undefined reference to `snd_config_iterator_end'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:492: undefined reference to `snd_config_iterator_next'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:493: undefined reference to `snd_config_get_string'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:494: undefined reference to `snd_config_get_id'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:495: undefined reference to `snd_config_update_free_global'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:497: undefined reference to `snd_pcm_status'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:498: undefined reference to `snd_pcm_status_sizeof'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:499: undefined reference to `snd_pcm_status_get_tstamp'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:500: undefined reference to `snd_pcm_status_get_state'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:501: undefined reference to `snd_pcm_status_get_trigger_tstamp'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:502: undefined reference to `snd_pcm_status_get_delay'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:504: undefined reference to `snd_card_next'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:505: undefined reference to `snd_asoundlib_version'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:506: undefined reference to `snd_strerror'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/alsa/pa_linux_alsa.c:507: undefined reference to `snd_output_stdio_attach'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `GetStreamTime':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1738: undefined reference to `jack_frame_time'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1738: undefined reference to `jack_get_sample_rate'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `UpdateQueue':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1427: undefined reference to `jack_get_sample_rate'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `JackCallback':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1562: undefined reference to `jack_port_get_buffer'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `RealProcess':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1349: undefined reference to `jack_get_sample_rate'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1365: undefined reference to `jack_frame_time'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1367: undefined reference to `jack_port_get_latency'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1370: undefined reference to `jack_port_get_latency'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1391: undefined reference to `jack_port_get_buffer'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1402: undefined reference to `jack_port_get_buffer'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `RealStop':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1688: undefined reference to `jack_port_connected'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1690: undefined reference to `jack_port_disconnect'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1696: undefined reference to `jack_port_connected'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1698: undefined reference to `jack_port_disconnect'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `StartStream':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1609: undefined reference to `jack_port_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1609: undefined reference to `jack_port_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1609: undefined reference to `jack_connect'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1619: undefined reference to `jack_port_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1619: undefined reference to `jack_port_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1619: undefined reference to `jack_connect'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `CleanUpStream':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:983: undefined reference to `jack_port_unregister'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:988: undefined reference to `jack_port_unregister'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `OpenStream':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1080: undefined reference to `jack_port_name_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1081: undefined reference to `jack_client_name_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1087: undefined reference to `jack_get_sample_rate'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1181: undefined reference to `jack_get_sample_rate'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1214: undefined reference to `jack_port_name_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1215: undefined reference to `jack_port_register'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1224: undefined reference to `jack_port_name_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1225: undefined reference to `jack_port_register'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1241: undefined reference to `jack_get_ports'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1245: undefined reference to `jack_port_by_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1265: undefined reference to `jack_get_ports'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1269: undefined reference to `jack_port_by_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1301: undefined reference to `jack_port_get_latency'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1302: undefined reference to `jack_get_buffer_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1305: undefined reference to `jack_port_get_latency
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:733: undefined reference to `jack_client_open'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `BuildDeviceList':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:491: undefined reference to `jack_client_name_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:492: undefined reference to `jack_client_name_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:499: undefined reference to `jack_get_ports'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:517: undefined reference to `jack_client_name_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:558: undefined reference to `jack_get_sample_rate'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:589: undefined reference to `jack_get_ports'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:596: undefined reference to `jack_port_by_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:598: undefined reference to `jack_port_get_latency'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:610: undefined reference to `jack_get_ports'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:617: undefined reference to `jack_port_by_name'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:619: undefined reference to `jack_port_get_latency'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `PaJack_Initialize':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:781: undefined reference to `jack_on_shutdown'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:782: undefined reference to `jack_set_error_function'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:783: undefined reference to `jack_get_buffer_size'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:785: undefined reference to `jack_set_sample_rate_callback'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:786: undefined reference to `jack_set_xrun_callback'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:800: undefined reference to `jack_client_close'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:787: undefined reference to `jack_set_process_callback'
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:788: undefined reference to `jack_activate'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `PaJack_SetClientName':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1750: undefined reference to `jack_client_name_size'
    include/record/lib/portaudio/src/project_portaudio-build/lib/.libs/libportaudio.a(pa_jack.o): In function `PaJack_GetClientName':
    /home/lambda/soundcloud/build/src/include/record/lib/portaudio/src/project_portaudio/src/hostapi/jack/pa_jack.c:1765: undefined reference to `jack_get_client_name'
    collect2: error: ld returned 1 exit status
    make[2]: *** [src/cmakeDemo] Error 1
    make[1]: *** [src/CMakeFiles/cmakeDemo.dir/all] Error 2
    make: *** [all] Error 2

最佳答案

QtCreator确实会调查您的文件系统。因此,它将查找不在CMakeLists.txt范围内的文件。据我所知,这也适用于自动补全。

在我们的CMakeLists.txt中,没有一行可将静态库添加到您的项目中。就像是

add_library(libaudio NAME libportaudio.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/portaudio)
...

add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} ${libaudio})

似乎丢失了。

尝试将libportaudio构建为共享库。阅读构建说明或调用portaudio的./configure --help以获取更多详细信息。

关于c++ - PaError不是类或 namespace ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46886033/

10-12 22:40