undefined referance

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Shykino
Posts: 7
Joined: Tue Aug 01, 2006 6:29 pm

undefined referance

Post by Shykino »

Ok, I got Irrlicht SVN to compile successfully and got the DLL and stuff working with the examples. Now what I did was add a test.h and test.cpp to the Irrlicht project, with a simple class with a function that does std::cout << "Test";

Now I recompiled Irrlicht, put the test.h in the include directory and created a new project to test out the class. The compiler reconizes the test class fine ,but it says that there is a undefiend referance to test::sayTest() with trying to call the function. Does this mean that the .cpp file isn't being compiled?

test.h

Code: Select all

#include <iostream>

namespace irr
{
    class test
    {
        public:
        void sayTest();
    };

}
test.cpp

Code: Select all

#include "test.h"

namespace irr
{
    void test::sayTest()
    {
        std::cout << "Testing";
    }
}
The program is just HelloWorld example with my class thing...

Code: Select all

    test myclass;
    myclass.sayTest();
Error would be nice
Linking executable "..\..\bin\win32-gcc\01.HelloWorld.exe"...
.objs/main.o:main.cpp:(.text+0x33e): undefined reference to `irr::test::sayTest()'
collect2: ld returned 1 exit status
make.exe: *** [../../bin/win32-gcc/01.HelloWorld.exe] Error 1
Process terminated with status 1 (0 minutes, 1 seconds)
0 errors, 0 warnings
stodge
Posts: 216
Joined: Fri Dec 05, 2003 5:57 pm

Post by stodge »

"Does this mean that the .cpp file isn't being compiled? "

Quite possibly. Did you add it to the project (not sure which IDE/compiler) you're using so I can't be more specific.
Shykino
Posts: 7
Joined: Tue Aug 01, 2006 6:29 pm

Post by Shykino »

Yes, I did. I'm quite sure of it. I'm using code::blocks.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

But this line is very suspicious:

Code: Select all

.objs/main.o:main.cpp
Tr to make a new project file with your source.
Shykino
Posts: 7
Joined: Tue Aug 01, 2006 6:29 pm

Post by Shykino »

hybrid wrote:But this line is very suspicious:

Code: Select all

.objs/main.o:main.cpp
Tr to make a new project file with your source.
Make a new project and add my test.cpp and .h or make a new project for using the dll/.a/.lib
Post Reply