Instead of adding all the .cpp files...

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.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Instead of adding all the .cpp files...

Post by monkeycracks »

Instead of having to add all the .cpp files to define the voids in my namespaces, is there a better way to do this?

Isn't that what a .a or .lib does? If so, how can I make one?

Hopefully this is the last newbie question for me today =p
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

Is this meant to go into another thread as a follow-up or did you just forget to explain what this is about?
Coolkat88
Posts: 30
Joined: Tue Oct 03, 2006 3:14 pm

Post by Coolkat88 »

i think this is a follow up to another thread... well you make a .lib file.. but you make the .lib by linking together .cpp files.. you will have to do this regardless... you can almost make all your functions in your class inline

Code: Select all

Namespace test
{

   class Something
   {
          public:
               void hello(float a)
                {
                         // do soemthing with a
                 }

     };
};
and you can do that all in a .h file.. but the .cpp and linking the .o files make things easier to manage.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

How do you link them together and actually compile it into a lib?

(I use Dev-Cpp if thats important)
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I want to do something like...

--"Global.h"--

#include "everything"

namespace TestSpace
{
void blah();
void rah();
};

using namespace TestSpace;


but I want it so I don't have to have a .cpp file for the voids, I'd rather link to a .a or .lib that contains them all.
Coolkat88
Posts: 30
Joined: Tue Oct 03, 2006 3:14 pm

Post by Coolkat88 »

you are going to have to do .cpp regardless.. start a new project in Dev-CPP, and for type select static library.. i believe dev-cpp compiles into .lib, but maybe it does .a.. not sure..

you could also start a blank one.. but this will give you a template.. then just add your other .cpp files to your current project with the .h files.. and then link them.. you can also make .dll files for your functions with this..


now if you are just trying to avoid putting basic things in your main executable i think you should just add the .cpp files there.. the IDE alreayd knows to link all the .cpp files in the project together.. so you don't have to worry about anything..




global.h

Code: Select all

#ifndef __GLOBAL_H__
#define __GLOBAL_H__

namespace somename
{
     void function();
     void otherFunction();
};

#endif

global.cpp

Code: Select all

#include "global.h"

namespace somename
{
        void function()
        {
             int a = 1;
        }

        // ...
};

main.cpp

Code: Select all

#include "global.h"

using namespace somename;

int main()
{
    function();
    otherFunction();

    return 0;
}
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

ok, I've made the .a (same as .lib) but I get all kinds of OpenGL linking errors even though I've linked the .a to the opengl libs as well.

BTW this isn't for Irrlicht, but it says I can post general programming questions here.

pS = its the .a that compiles but when I link my project to it and compile it gives the linker errors.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

And no, I want to put numerous .cpp files with lots of different OpenGL functions in them(image loaders, file loaders, etc.) but I can't seem to get around the linking error..


my project int he .a is like this


Test
->RAWLoader.cpp

and then its compiled to a .a

My main project is like this

OpenGLProject
->Global.h (which includes RAWLoader.h)
->Main.cpp (which uses some of the RAWLoader functions.
Coolkat88
Posts: 30
Joined: Tue Oct 03, 2006 3:14 pm

Post by Coolkat88 »

if you added new functions or changed some core features to classes inside by adding the static library make sure you rebuild all of your objects..

also could you post what the linker is telling you?
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

In function `ZN9Rawloader14SetVertexColorEPhii':
[Linker error] undefined reference to `glColor3f@12'
In function `ZN9Rawloader15RenderHeightMapEPh':
[Linker error] undefined reference to `glBegin@4'
[Linker error] undefined reference to `glVertex3i@12'
[Linker error] undefined reference to `glVertex3i@12'
[Linker error] undefined reference to `glVertex3i@12'
[Linker error] undefined reference to `glVertex3i@12'
[Linker error] undefined reference to `glEnd@0'
[Linker error] undefined reference to `glColor4f@16'
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Irrlicht makes a .dll....
Shouldn't I be doing that? and if so what exactly do I do to the .dll project?
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

When I make a .dll it also makes a .a BUT then it doesn't even recognize that the functions are there in my main project.
Coolkat88
Posts: 30
Joined: Tue Oct 03, 2006 3:14 pm

Post by Coolkat88 »

that comes when you compile the .a or when you compile your .exe? i think you need to relink your openGL stuff to your EXE project aswell..
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

OpenGL stuff is linked to the .a and the .exe

When I link the .a to my project it gives those OpenGL linker errors, even though I have both of the projects linked to all the openGL stuff.

If I don't include the .a to my project, no linker errors except the RAW loader ones.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I can send you the project via pm or msn or something if you'd like to take a look at it and you have enough time, its been stressing me out a lot lately.
Post Reply