0

I wanna make c++ app for audio with QT, and I wanna use sox, I import src folder of sox.sourceforg.net project code. and type very simple code

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <src/sox.h>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    sox_format_t* input = sox_open_read("d.wav", NULL, NULL, NULL);
}

MainWindow::~MainWindow()
{
    delete ui;
}

but encounter error for undefined reference to sox_open_read'. since this function with autocomplete show while I programmed.

I have a lot of search in this site and github and find these below links, but did not fix my prb

Recording using sox in c/c++

Android NDK linking problems

How can I send my audio file to stdout with the libsox library?

Reducing a channel from wav file using libsox

How can i determine duration of wav file

S At
  • 422
  • 5
  • 15

1 Answers1

0

I recommend you to add error message. If error is concerning linker (LNK...) than you didn't link sox library into application.

Evgeny
  • 1,072
  • 6
  • 6
  • C:\Users\SATSom\Documents\Qt Project 1\build-resample-Desktop_Qt_5_15_2_MinGW_64_bit-Debug\..\resample\mainwindow.cpp:12: error: undefined reference to `sox_open_read' debug/mainwindow.o: In function `MainWindow::MainWindow(QWidget*)': C:\Users\SATSom\Documents\Qt Project 1\build-resample-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/../resample/mainwindow.cpp:12: undefined reference to `sox_open_read' – S At Apr 09 '21 at 13:15
  • Ok slightly strange. Try to wrap src/sox.h with extern-c: use (separated to lines) ```extern "C" { #include }``` – Evgeny Apr 09 '21 at 13:26
  • thx, but this prb is still with same error ;( – S At Apr 09 '21 at 13:52
  • So do you actually link against the library? Did you add it in your pro-file (when you use qmake)? – chehrlic Apr 09 '21 at 14:21
  • Absolutely these are the first work of any prjs – S At Apr 09 '21 at 22:08