2010-01-05 61 views
0

我有一个函数在cpp文件中实现并在头文件中声明。在主程序的cpp文件中,我包含头文件并使用该函数。然而,这未能链接(未定义的引用myFunc)。为了让它工作,我需要改变什么?我如何让QtCreator编译多个cpp和头文件?

编辑:亲文件:

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 
} 
+0

什么是你的* .pro文件的内容? – elcuco 2010-01-05 21:21:41

+0

5K代表,你不知道如何提出一个问题 - 有点难过,我会说。 – 2010-01-05 21:22:56

+0

你可以在shell上发布make的输出吗?顺便说一句,恕我直言,这不再是一个stackoverflow问题。如何在http://qtcentre.org重新提问? – elcuco 2010-01-05 21:33:21

回答

1

我无法确定没有看到代码,但在YOUT的* .h文件(该* .c文件相匹配的),你应该做的:

extern c{ 
// old c code 
} 
+0

我提到的所有文件都添加到项目中。 – Grzenio 2010-01-05 21:30:25