链接器命令错误并从错误引用

时间:2017-05-16 17:44:56

标签: c++ xcode audio error-code

尝试运行构建时,我收到两条错误消息

 "SaveFileDelay(double*, int)", referenced from:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

我环顾四周,一直无法找到解决方案;我编译了所有源代码但错误仍然显示。我也清理了它并重新启动了xcode。

#include <string>
#include <iostream>
#include <cmath>
extern "C"
{
#include <sndfile.h>
}
using namespace std;

#include "SaveFile.hpp"
#include "Delay.hpp"
#include "Distortion.hpp"
#include "FadeIn.hpp"
#include "SaveFileDelay.hpp"


int main()
{
    int choice, length;
    int MenuLoop = 1;

    cout << "Please enter file path";
    string strSPath;
    cin >> strSPath;
    const char *SPath = strSPath.c_str();

    SF_INFO FInfo;
    SNDFILE *SFile = sf_open(SPath, SFM_READ, &FInfo);


    if (SFile == NULL)
    {
        cout << "Error loading file, please reload programme. \n";
        return 0;
    }

    length = (int) FInfo.frames;
    double *x = new double[length];
    sf_readf_double(SFile, x, length);


    while (MenuLoop == 1)
    {

        cout << "What would you like to do? \n 1. Amplify \n 2. Fade In \n 3. Distortion \n 4. Delay \n 5. Save File \n 6. Exit \n";
        cin >> choice;


        if (choice == 1)
        {
            int ALStop = 1;

            while (ALStop == 1)
            {
                double Vol;
                int AmpChoice;
                cout << "Please enter amount \n";
                cin >> Vol;

                if (Vol > 1.4)
                {
                    cout << "Amplifying by this amount may cause clipping or distortion. \n";
                    cout << "Are you sure you want to continue? \n";
                    cout << "Enter Number: 1. Yes 2. No \n";
                    cin  >> AmpChoice;

                    if (AmpChoice == 1)
                    {
                        ALStop = 0;
                    }
                    else if (AmpChoice == 2)
                    {
                        ALStop = 1;
                    }
                    else
                    {
                        cout << "Not a valid option \n";
                        ALStop = 1;
                    }

                }
                for (int i=0; i<length; i++)
                {
                    x[i] = x[i]  * Vol;
                }

        }



    }

        else if (choice == 2)
    {
        FadeIn(x, length);
    }

        else if (choice == 3)
        {
            Distortion(x, length);
        }
        else if (choice == 4)
        {
            int DelayChoice;
            int DLoop = 1;

            while (DLoop == 1)
            {
            cout << "Using delay will no allow you to use other effects and the programme will save and close \n";
            cout << "Do you wish to continue? \n 1. Yes 2. No";
            cin >> DelayChoice;

            if (DelayChoice == 1)
            {
                SaveFileDelay(x,length);
                MenuLoop = 0;
                DLoop = 0;
            }

            else if (DelayChoice == 2)
            {
                MenuLoop = 1;
                DLoop = 0;
            }

            else
            {
                cout << "Invalid choice, please choose again.\n";
                MenuLoop = 1;
                DLoop = 1;
            }
            }
        }
        else if (choice == 5)
        {
            int SaveChoice;
            int SaveLoop = 1;

            SaveFile(x,length);

            while (SaveLoop == 1)
            {
            cout << "Do you wish to close the programme or continue? \n 1. Continue 2. Close \n";
            cin >> SaveChoice;

            if (SaveChoice == 1)
            {
                MenuLoop = 1;
                SaveLoop = 0;
            }

            else if (SaveChoice == 2)
            {
                delete []x;
                MenuLoop = 0;
                SaveLoop = 0;
            }

            else
            {
                cout << "Invalid choice, please choose again. \n";
                SaveLoop = 1;
            }
            }
        }

        else if (choice == 6)
        {
            int CloseChoice;
            int CLoop = 1;

            while (CLoop == 1)
            {
                cout << "Warning, this will close the programme without saving.\n";
                cout << "Do you wish to proceed? \n 1. Yes 2. No";
                cin >> CloseChoice;

                if (CloseChoice == 1)
                {
                    MenuLoop = 0;
                    CLoop = 0;
                    delete []x;
                }

                else if (choice == 2)
                {
                    MenuLoop = 1;
                    CLoop = 0;
                }

                else
                {
                    cout << "Invalid choice, please choose again";
                    MenuLoop = 1;
                    CLoop = 1;
                }
            }

        }
        else
        {
            cout << "Invalid choice, please choose again. \n";
            MenuLoop = 1;
        }
}
    return 0;
}

0 个答案:

没有答案