Reputation: 1020
Assume that we have a class called Katze in a directory called dirOfKatze.
Katze.h
#ifndef KATZE_H
#define KATZE_H
class Katze
{
public:
Katze();
};
#endif // KATZE_H
Katze.cpp
#include "katze.h"
#include <iostream>
Katze::Katze()
{
std::cout<<"MIAU"<<std::endl;
}
Lets assume that I want to add the class to a Qt project. I can do so by specifying
INCLUDEPATH += dirOfKatze
in my .pro file. Now the header file of Katze, or better all header files in the directory dirOfKatze are included. But unfortunately Katze.cpp can still not be found by the linker:
#include "katze.h"
int main()
{
Katze myCat;
return 0;
}
Results in: LNK2019 ...public: __cdecl Katze::Katze(void)"...
Is there any way to tell the linker that it should look for the cpp files in dirOfKatze equivalent to INCLUDEPATH? This relevant for me, because there might be many cpp files and I would like to add them all at once, without adding them one by one by typing SOURCE += .... \
Upvotes: 0
Views: 174
Reputation: 116
You have to add the following lines in your .pro file:
HEADERS += pathTo_Katze.h
SOURCES += pathTo_Katze.cpp
Upvotes: 2