Linkage problem..
Olof Bjarnason
objarni at dd.chalmers.se
Thu Mar 25 19:19:03 GMT 2004
Hi there!
I have three files named multifiletest.cpp, test.h and
test.cpp, which I have added to a "C++ / Simple Hello
World program" project in KDevelop 3.0. Bear with me, I am
new to KDevelop but can't find any hints on what I am doing
wrong in the docs nor on the web.
After F8 (build project), which give me a "Success",
I push F7 (build active target) to link my program.
What I think are the essential part of the output message
follow:
c++ -O0 -g3
/home/olof/develop/multifiletest/src/multifiletest.cpp -o
multifiletest
*/home/olof/tmp/ccZDrIEN.o(.text+0x3e): In function `main':
*/home/olof/develop/multifiletest/src/multifiletest.cpp:36:
undefined reference to `MyClass::MyClass[in-charge]()'
*/home/olof/tmp/ccZDrIEN.o(.text+0x4d):/home/olof/develop/multifiletest/src/multifiletest.cpp:38:
undefined reference to `MyClass::~MyClass [in-charge]()'
*collect2: ld returned 1 exit status
That is, the constructor and destructor of MyClass, which
reside in test.cpp (see source later on), is not linked with
the main file multifiletest.cpp (which include main()).
Examinig the first of the above output lines, not surprisingly
the test.cpp file is NOT there, only the multifiletest.cpp.
What am I doing wrong? I am sure the test.cpp and
multifiletest.cpp files both are in my "Active Target"
subtarget in the Automake Manager, but it seems the system
doesn't include the test.cpp file at all. Note, in the Build
Project step both files are included, but from what I can
see not linked into the final 'multifiletest' binary.
Source code:
-- multifiletest.cpp -------------------
#include "test.h"
int main(int argc, char *argv[]) {
MyClass m;
myFunc();
return 0;
}
-- test.h ------------------------------
#ifndef TEST_H
#define TEST_H
void myFunc(void);
class MyClass {
public:
MyClass(void);
~MyClass(void);
};
#endif
-- test.cpp ----------------------------
#include "test.h"
void myFunc(void) {
}
MyClass::MyClass(void) {
}
MyClass::~MyClass(void) {
}
Thanks for any help,
/Olof
-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«
More information about the KDevelop
mailing list