How can I make QtCreator compile multiple cpp and header files?
I have a function implemented in a cpp file and declared in header file. In the main program cpp file I include the header file and use the function. However this fails to lin开发者_高级运维k (undefined reference to myFunc). What do I have to change to get it working?
EDIT: pro file:
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
In main.cpp I use a function from 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
}
I can't be sure without seeing the code, but in yout *.h file (the one that matches the *.c file) you should do:
extern c{
// old c code
}
精彩评论