Instead of adding all the .cpp files...
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
Instead of adding all the .cpp files...
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
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
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
and you can do that all in a .h file.. but the .cpp and linking the .o files make things easier to manage.
Code: Select all
Namespace test
{
class Something
{
public:
void hello(float a)
{
// do soemthing with a
}
};
};
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
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
global.cpp
main.cpp
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;
}
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
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.
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.
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
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.
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.
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
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'
[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'
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact: