如何让QtCreator编译多个cpp和头文件?

时间:2010-01-05 21:19:59

标签: c++ qt-creator

我有一个在cpp文件中实现的函数,并在头文件中声明。在主程序cpp文件中,我包含头文件并使用该函数。但是这无法链接(未定义的引用myFunc)。我需要做些什么才能让它发挥作用?

编辑:专业档案:

SOURCES += as241.c \
    main.cpp \
    normalvar.cpp \
    normaldistribution.cpp \
    studenttdistribution.cpp
LIBS += -lgsl \
    -lgslcblas \
    -lm
HEADERS += as241.h \
    var.h \
    distribution.h \
    normalvar.h \
    normaldistribution.h \
    studenttdistribution.h

在main.cpp中我使用as241

中的函数

as241.h:

#ifndef AS241_H
#define AS241_H

double ppnd16(double p);

#endif // AS241_H

as241.cpp:

#include "as241.h"
#include <math.h>

double ppnd16(double p)
{
  //code
}

1 个答案:

答案 0 :(得分:1)

我不能确定没有看到代码,但在你的* .h文件(与* .c文件相匹配的文件)中你应该这样做:

extern c{
// old c code
}