Undefined reference to function - portaudio
An issue I am having with this cmake list, is that I am getting error message error: undefined reference to
Pa_GetVersion'`
for this piece of code:
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();
}
record.h
#ifndef RECORD_H
#define RECORD_H
#include <iostream>
#include "lportaudio.h"
class record
{
public:
record();
void example();
};
#endif // RECORD_H
main.cpp:
#include <iostream>
#include "record.h"
using namespace std;
int main()
{
record test;
test.example();
cout << "Hello World!" << endl;
return 0;
}
Cmakelist:
project(audio)
cmake_minimum_required(VERSION 3.2.2)
#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 1
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")
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
SET(EXTRA_LIBS rt m asound pthread)
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
#Add the files in the source list
aux_source_directory(. SRC_LIST)
#Add portaudio library
ADD_LIBRARY(portaudio STATIC IMPORTED)
SET_PROPERTY(TARGET portaudio PROPERTY IMPORTED_LOCATION "${portaudio_lib_dir}/libportaudio.a")
add_executable(${PROJECT_NAME} ${SRC_LIST} ${portaudio_inc_dir})
#What to compile before target!
add_dependencies(${PROJECT_NAME} project_portaudio)
#What libraries to link to the target!
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${EXTRA_LIBS} portaudio)
Error: https://pastebin.com/q0a7rKUP
I am not sure i understand the error messages, and why I am gettting these..