如何在 qt throw pro 文件中链接文件

问题描述 投票:0回答:0

我有对“ffwf_malloc”和其他函数的未定义引用 fftw3 lib

起初我安装了fftw3库到

usr/local/lib
。然后我将 包含在我的项目中。但是我有一个错误:
Can't find <fftw3.h> file
。在 pro 文件中,我添加了 LIBS += -lfftw3。现在我在尝试编译项目之前没有任何错误。

我的主文件是这样的:

#include <QCoreApplication>
#include <bitset>
#include <fftw3.h>
#include "fftlib/fft_internal.h"
#include <stdlib.h>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    cfloat *input = static_cast<cfloat*>(fftwf_malloc(64 * sizeof(cfloat)));
    cfloat *output = static_cast<cfloat*>(fftwf_malloc(64 * sizeof(cfloat)));

    fftwf_plan plan;

    plan = fftwf_plan_dft_1d(64, reinterpret_cast<fftwf_complex *>(input),    reinterpret_cast<fftwf_complex *>(output), FFTW_FORWARD, FFTW_MEASURE);

    srand(0);
    for (unsigned i = 0; i < 64; i++)
    {
        float real = (float)rand() / RAND_MAX - 0.5f;
        float imag = (float)rand() / RAND_MAX - 0.5f;
        input[i] = cfloat_create(real, imag);
    }
    fftwf_execute(plan);


    fftwf_free(input);
    fftwf_free(output);
    fftwf_destroy_plan(plan);
    return a.exec();
}

.pro文件: QT -= 贵

CONFIG += c++17 console
CONFIG -= app_bundle


LIBS += -L usr/local/lib/ -lfftw3

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before     Qt 6.0.0

SOURCES += \
        fftlib/cpu.c \
        fftlib/fft.c \
        fftlib/kernel.c \
        main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

HEADERS += \
    fftlib/fft.h \
    fftlib/fft_internal.h

我试图将路径 usr/local/lib/ 更改为 usr/local/lib/cmake/fftw3。但它仍然不起作用。

c++ qt linker fftw
© www.soinside.com 2019 - 2024. All rights reserved.