PaError不是类或命名空间

时间:2017-10-23 09:30:56

标签: c++ cmake linker namespaces portaudio

我一直在尝试将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;
}

record.h

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

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

#endif // RECORD_H

我尝试将portaudio包含在我的记录类中,看看它是否理解了诸如Pa_getversion之类的portaudio函数..但是我似乎得到了错误消息:

/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

2 个答案:

答案 0 :(得分:1)

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以获取更多详细信息。

答案 1 :(得分:0)

  

它似乎并不喜欢。 PaError不是类或命名空间?

查看此处记录的代码:

http://portaudio.com/docs/v19-doxydocs/portaudio_8h_source.html

节目:

〜剪断

# serializers.py, vanilla
from django.contrib.auth.models import User, Group
from rest_framework import serializers

class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ('username', 'groups')


# views.py
from django.contrib.auth.models import User
from rest_framework.authentication import BasicAuthentication
from rest_framework import viewsets
from app import serializers

class UserViewSet(viewsets.ModelViewSet):
    serializer_class = serializers.UserSerializer
    queryset = User.objects.all()
    authentication_classes = (BasicAuthentication,)

# serializers.py, with write-choice filter modification
class FilteredRelatedField(serializers.PrimaryKeyRelatedField):
    def get_queryset(self):
        user = self.context['request'].user
        user_groups = user.groups.values_list('id', flat=True)
        queryset = Group.objects.filter(id__in=user_groups)
        return queryset

class UserSerializer(serializers.ModelSerializer):
    groups = FilteredRelatedField(many=True)
    class Meta:
        model = User
        fields = ('username', 'groups')


# serializers.py, with read-only filtering
class UserSerializer(serializers.ModelSerializer):
    groups = serializers.SerializerMethodField()
    class Meta:
        model = User
        fields = ('username', 'groups')
    def get_groups(self, instance):
        instance_user_groups = instance.groups.values_list('id', flat=True)
        current_user_groups = self.context['request'].user.groups.values_list('id', flat=True)
        return [x for x in instance_user_groups if x in current_user_groups]

基于此,它似乎没有使用任何自定义C ++命名空间。

PaError刚定义为int。

所以你的代码:

   #ifdef __cplusplus
   49 extern "C"
   50 {
   51 #endif /* __cplusplus */
   52 
   58 int Pa_GetVersion( void );
   59 
   67 const char* Pa_GetVersionText( void );
   68 
   81 #define paMakeVersionNumber(major, minor, subminor) \
   82     (((major)&0xFF)<<16 | ((minor)&0xFF)<<8 | ((subminor)&0xFF))
   83 
   84 
   90 typedef struct PaVersionInfo {
   91     int versionMajor;
   92     int versionMinor;
   93     int versionSubMinor;
   99     const char *versionControlRevision;
  101     const char *versionText;
  102 } PaVersionInfo;
  103     
  114 const PaVersionInfo* Pa_GetVersionInfo();
  115 
  116 
  121 typedef int PaError;  
  ...

本质上是试图将int视为包含Pa_GetVersion()方法的类类型。这对你得到的错误很有意义。

从头文件中,Pa_GetVersion()似乎是标准的C风格导出函数,如portaudio.h中所列:

std::cout << PaError::Pa_GetVersion() << std::endl;

因此,您应该能够简单地按原样调用该函数。因此,请尝试将代码更改为:

58 int Pa_GetVersion( void );

它看起来应该返回一个int。