SYMBOL TABLE:
00000000 l df *ABS* 00000000 libAmiDARK.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
000001b8 l F .text 00000014 MyReshapeFunc
00000fe0 l F .text 000006e4 UpdateImage
000016c4 l F .text 00000b08 INTERNAL_Trace3DObject
000021cc l F .text 00000714 MyDisplayFunc
00000000 l d .rodata 00000000 .rodata
00000000 l O .bss 00000200 jmpbuf
00000000 l d .rodata.cst4 00000000 .rodata.cst4
00000000 l d .rodata.cst8 00000000 .rodata.cst8
00000000 l d .rodata.str1.4 00000000 .rodata.str1.4
00000000 l d .sbss 00000000 .sbss
00000000 l d .sdata 00000000 .sdata
00000000 l d .stab 00000000 .stab
00000000 l d .stabstr 00000000 .stabstr
00000000 l d .comment 00000000 .comment
00000000 g F .text 0000001c DEG2RAD
0000001c g F .text 0000001c RAD2DEG
00000038 g F .text 00000010 DEVal
00000048 g F .text 00000054 DESetMaximumTextures
00000004 O *COM* 00000004 MaxTextureAmount
00000000 *UND* 00000000 mini_CurrentContext
00000400 O *COM* 00000004 ImageTexture
0000009c g F .text 00000010 BASIC2D_Constructor
0000000c O *COM* 00000004 Basic2D
000000ac g F .text 00000004 BASIC2D_Destructor
000000b0 g F .text 00000098 DeSetAmbientColor
00000044 O *COM* 00000004 AmbientLight
00000148 g F .text 00000070 DESetDirectionalLight
000001c0 O *COM* 00000004 Lights
00000120 O *COM* 00000004 BasicSetup
000001cc g F .text 00000044 DESyncOn
00000004 O *COM* 00000004 IsSyncOn
00000210 g F .text 00000060 MyMouseFunc
00000020 O *COM* 00000004 DBMouse
00000270 g F .text 00000020 MyKeyboardFunc
00000016 O *COM* 00000002 DBKey
00000290 g F .text 00000008 MySpecialFunc
00000298 g F .text 00000004 MyEntryFunc
0000029c g F .text 000000a4 ConvertRes2String
00000000 *UND* 00000000 sprintf
00000340 g F .text 00000044 DebugMessage
00000008 g O .sbss 00000004 GlobalDEBUG
00000000 *UND* 00000000 printf
00000384 g F .text 00000020 DeleteString
00000000 *UND* 00000000 free
000003a4 g F .text 00000024 CreateString
00000000 *UND* 00000000 malloc
000003c8 g F .text 00000048 CreateDeleteString
00000410 g F .text 00000128 INTERNAL_SetTriangleNormal
00000400 O *COM* 00000004 MemblockSIZE
00000400 O *COM* 00000004 MemblockPTR
00000538 g F .text 00000044 DESyncOff
0000057c g F .text 00000250 UpdateCamera
00000200 O *COM* 00000004 Camera
000007cc g F .text 000002b4 DESaveObject
00000008 O *COM* 00000004 Basic3D
00000004 O *COM* 00000004 ObjectList
00000400 O *COM* 00000004 FileChannel
00000000 *UND* 00000000 IDOS
00000a80 g F .text 00000560 DELoadObject
00000000 *UND* 00000000 IExec
00000004 O *COM* 00000004 ImageCount
00011c00 O *COM* 00000004 ImageData
00000004 O *COM* 00000004 TraceImages
00000024 O *COM* 00000004 BasicFOG
0000000c O *COM* 00000004 Core
00000000 *UND* 00000000 __glut_current_context
00000010 g O .sbss 00000002 jmp_set
00000000 *UND* 00000000 longjmp
000028e0 g F .text 00000c10 main
00000004 O *COM* 00000004 argc
00000004 O *COM* 00000004 argv
00000400 O *COM* 00000004 MeshSIZE
00000400 O *COM* 00000004 MeshPTR
00000004 O *COM* 00000004 CurrentCamera
00000004 O *COM* 00000004 ImageListAmount
00000000 *UND* 00000000 DarkLoop
00000000 g O .sbss 00000002 DBQuit
00000004 g O .sbss 00000004 window
0000000c g O .sbss 00000004 MyDBWindow
00000000 g O .data 00000010 CoreRGBColor
00000000 g O .sdata 00000004 font
0000000c O *COM* 00000004 vec0
0000000c O *COM* 00000004 vec1
0000000c O *COM* 00000004 vec2
0000000c O *COM* 00000004 normal
0000000c O *COM* 00000004 edge1
0000000c O *COM* 00000004 edge2
00000010 O *COM* 00000004 BasicCamera
00000400 O *COM* 00000004 MeshSize
What I can see in that list are some functions and some variables ... not all in both cases ...
EDIT : I've removed the MiniGL sample optimisation and -gstabd option in compilation and now .a file is 1/2 size and when I list it, all functions appeared. But the result remain the same on compilation ... Does someone have a clue ?
Edited by freddix on 2009/10/26 23:48:36
All we have to decide is what to do with the time that is given to us.
Explanation to your first problem: When compiling something into an .o file you need to supply the -c flag to prevent the compiler from trying to make an executable. Without -c it tries to link it into an executable which requires main(). The -c flag stops after compiling and the result is an .o file.
Also, you don't need to declare any function as extern, just a simple prototype is fine, such as: void DarkLoop( void );
With ar I always use rc, that is: ar rc libmyobj.a myobj.o
Don't know what 'cru' does or if that is the cause of your link problems.
Software developer for Amiga OS3 and OS4. Develops for OnyxSoft and the Amiga using E and C and occasionally C++
@Deniil I only followed what was rpoposed to me to compile at a .a file I will make tests following your advice and tell you the result.
EDIT: I've made tests removing cru and adding rc like you said ...
When I create my libAmiDARK.a using your advices, if I compile a code that use my libAmiDARK.a file, I get this :
gcc -mcrt=newlib -Wall -DMINIGL -c -o AmiDE_3D[MultiCamera].o AmiDE_3D[MultiCamera].c
AmiDE_3D[MultiCamera].c: In function 'DarkLoop':
AmiDE_3D[MultiCamera].c:48: warning: implicit declaration of function 'DESetDisplayMode'
AmiDE_3D[MultiCamera].c:50: warning: implicit declaration of function 'DELoadImage'
AmiDE_3D[MultiCamera].c:51: warning: implicit declaration of function 'DEMakeObjectBox'
AmiDE_3D[MultiCamera].c:52: warning: implicit declaration of function 'DELoadObject'
AmiDE_3D[MultiCamera].c:53: warning: implicit declaration of function 'DEPositionObject'
AmiDE_3D[MultiCamera].c:54: warning: implicit declaration of function 'DEColorObjectEx'
AmiDE_3D[MultiCamera].c:55: warning: implicit declaration of function 'DETextureObject'
AmiDE_3D[MultiCamera].c:65: warning: implicit declaration of function 'DELoop'
AmiDE_3D[MultiCamera].c:68: warning: implicit declaration of function 'DESync'
gcc -mcrt=newlib -Wall -DMINIGL -L -lAmiDARK -lGL -lGLUT -lglpng -lpng -lz -o AmiDE_3D_MultiCameras.exe.debug AmiDE_3D[MultiCamera].o
/SDK/newlib/lib/crtbegin.o: In function `_start':
(.text+0x14e): undefined reference to `main'
/SDK/newlib/lib/crtbegin.o: In function `_start':
(.text+0x156): undefined reference to `main'
AmiDE_3D[MultiCamera].o: In function `DarkLoop':
AmiDE_3D[MultiCamera].c:(.text+0x24): undefined reference to `DESetDisplayMode'
AmiDE_3D[MultiCamera].c:(.text+0x38): undefined reference to `DELoadImage'
AmiDE_3D[MultiCamera].c:(.text+0x68): undefined reference to `DEMakeObjectBox'
AmiDE_3D[MultiCamera].c:(.text+0x7c): undefined reference to `DELoadObject'
AmiDE_3D[MultiCamera].c:(.text+0xac): undefined reference to `DEPositionObject'
AmiDE_3D[MultiCamera].c:(.text+0xc4): undefined reference to `DEColorObjectEx'
AmiDE_3D[MultiCamera].c:(.text+0xd4): undefined reference to `DETextureObject'
AmiDE_3D[MultiCamera].c:(.text+0x104): undefined reference to `DEMakeObjectBox'
AmiDE_3D[MultiCamera].c:(.text+0x134): undefined reference to `DEPositionObject'
AmiDE_3D[MultiCamera].c:(.text+0x14c): undefined reference to `DEColorObjectEx'
AmiDE_3D[MultiCamera].c:(.text+0x160): undefined reference to `DELoadImage'
AmiDE_3D[MultiCamera].c:(.text+0x178): undefined reference to `DEMakeObjectBox'
AmiDE_3D[MultiCamera].c:(.text+0x188): undefined reference to `DETextureObject'
AmiDE_3D[MultiCamera].c:(.text+0x1ac): undefined reference to `DESync'
AmiDE_3D[MultiCamera].c:(.text+0x1b0): undefined reference to `DELoop'
make: *** [AmiDE_3D_MultiCameras.exe] Error 1
the makefile is :
# GLUT-fullscreen template
#
# See GLUT-fullscreen.c and GLUT-fullscreen2.c for details
#
# written by Hans de Ruiter
#
# License:
# This is provided as-is and can be used and distributed by anyone
# without restrictions.
Also, you don't need to declare any function as extern, just a simple prototype is fine, such as: void DarkLoop( void );
Err, you should declare function calls in a shared header with extern....
The only time you might not use extern is if you a decalring a prototype in the same file as afunction because you need to call it before it's defined.
'cru' does the same as 'rc' except that the 'u' means only update newer files. I don't think order of options is critical.
@Fredix
Please delete / (or backup by renaming) all objects files and archives ie libAmiDark.a and rebuild from scratch.
You know when a compiler issues a warning that's not just to disturb you : you *should* understand what the warning report to and be sure to understand why you choose not to correct it (which should really be rare : each warning must be corrected).
Here the warnings you got when compiling your AmiDE_3D[MultiCamera].c file tells me that you are calling functions without first defining them. In such a case, the compiler will assume a default prototype signature usually it will assume the function returns an int, as a consequence when linking it will search for a function returning an int if the real function is returning something else it will not find it and tell you it has undefined references.
Now how to correct that : start by writing an header called AmiDARK.h (for example) in this header you should put every function (and variable?) your AmiDARK engine wants to share externaly, one small example
#ifndef AMIDARK_H
#define AMIDARK_H
extern void DESync(void);
extern int DEPositionObject(DEObject * object);
...
#endif /* AMIDARK_H */
This header will be included by the source files of your engine *and* by the user code so this header will be something you'll provide in your SDK (just like proto/exec.h for example) don't put in it something you want to keep internal to your engine, instead write another header file (for example AmiDARKprivate.h where you'll put anything private to your implementation). AFAIK your engine is written in whole in an unique C file so the private header won't be required because internal things will be defined at the start of this file, but when your engine will grow dramatically you might find convenient to split this monster file into smaller files at this point you will have a need for the private header.
About the ar commandline as it was me that gave the advice I apologize I did it from memory in fact the option order matters so I intended 'ruc' instead of 'cru', sorry.
Here the warnings you got when compiling your AmiDE_3D[MultiCamera].c file tells me that you are calling functions without first defining them. In such a case, the compiler will assume a default prototype signature usually it will assume the function returns an int, as a consequence when linking it will search for a function returning an int if the real function is returning something else it will not find it and tell you it has undefined references.
You are ofcourse correct to say he should be defineing his functions in advance, but that won't result in unfound symbols (unless he's compiling with g++)
In fact under C it could be worse, the functions might be miscalled, with wrong types, leading to apprently inexplcable crashes.
You are ofcourse correct to say he should be defineing his functions in advance, but that won't result in unfound symbols (unless he's compiling with g++)
In fact under C it could be worse, the functions might be miscalled, with wrong types, leading to apprently inexplcable crashes.
Are you sure ? I can't test right now but I would have sworn that not defining a function before it's called would lead you to undefined (not found) symbols especially when dealing with functions from a static library and this function does not return an int.
I already do this. Here is the AmiDARK.h file content :
#ifndef _AMIDARK_H_
#define _AMIDARK_H_
extern void DarkENGINE_Start( void );
extern void DarkENGINE_End( void );
extern int DELoop( void );
extern int main( int myargc, char** myargv );
extern void DESetDisplayMode( int Width, int Height, int Depth );
extern void DELoadImage( const char * FileName, int ImageIndex );
extern void DEMakeObjectBox( int ObjectID, int Width, int Height, int Depth );
extern void DELoadObject( char * FileName, int ObjectID );
extern void DEPositionObject( int ObjectID, float XPos, float YPos, float ZPos );
extern void DEColorObjectEx( int ObjectID, int RGBR, int RGBG, int RGBB );
extern void DETextureObject( int ObjectID, int ImageID );
extern void DESync();
When I include this file, only the warning disappear and I always get this :
gcc -mcrt=newlib -Wall -DMINIGL -c -o AmiDE_3D[MultiCamera].o AmiDE_3D[MultiCamera].c
gcc -mcrt=newlib -Wall -DMINIGL -L -lAmiDARK -lGL -lGLUT -lglpng -lpng -lz -o AmiDE_3D_MultiCameras.exe.debug AmiDE_3D[MultiCamera].o
/SDK/newlib/lib/crtbegin.o: In function `_start':
(.text+0x14e): undefined reference to `main'
/SDK/newlib/lib/crtbegin.o: In function `_start':
(.text+0x156): undefined reference to `main'
AmiDE_3D[MultiCamera].o: In function `DarkLoop':
AmiDE_3D[MultiCamera].c:(.text+0x20): undefined reference to `DESetDisplayMode'
AmiDE_3D[MultiCamera].c:(.text+0x30): undefined reference to `DELoadImage'
AmiDE_3D[MultiCamera].c:(.text+0x44): undefined reference to `DEMakeObjectBox'
AmiDE_3D[MultiCamera].c:(.text+0x54): undefined reference to `DELoadObject'
AmiDE_3D[MultiCamera].c:(.text+0x78): undefined reference to `DEPositionObject'
AmiDE_3D[MultiCamera].c:(.text+0x8c): undefined reference to `DEColorObjectEx'
AmiDE_3D[MultiCamera].c:(.text+0x98): undefined reference to `DETextureObject'
AmiDE_3D[MultiCamera].c:(.text+0xac): undefined reference to `DEMakeObjectBox'
AmiDE_3D[MultiCamera].c:(.text+0xd4): undefined reference to `DEPositionObject'
AmiDE_3D[MultiCamera].c:(.text+0xe8): undefined reference to `DEColorObjectEx'
AmiDE_3D[MultiCamera].c:(.text+0xf8): undefined reference to `DELoadImage'
AmiDE_3D[MultiCamera].c:(.text+0x10c): undefined reference to `DEMakeObjectBox'
AmiDE_3D[MultiCamera].c:(.text+0x118): undefined reference to `DETextureObject'
AmiDE_3D[MultiCamera].c:(.text+0x13c): undefined reference to `DESync'
AmiDE_3D[MultiCamera].c:(.text+0x140): undefined reference to `DELoop'
make: *** [AmiDE_3D_MultiCameras.exe] Error 1
EDIT: @Abalaban : My source code is splitted in several source code files :
no The file that is compiled into the .a contain all includes listed below so it's similar to like if it was only 1 file.
Here is the details :
MakeFile :
# GLUT-fullscreen template
#
# See GLUT-fullscreen.c and GLUT-fullscreen2.c for details
#
# written by Hans de Ruiter
#
# License:
# This is provided as-is and can be used and distributed by anyone
# without restrictions.
int main( int myargc, char** myargv ){
argc = myargc;
argv = myargv;
DarkENGINE_Start();
DarkLoop();
DarkENGINE_End();
return EXIT_SUCCESS;
}
BOOL DELoop(){
int done = DBKey.Escape;
return done;
}
Main is defined here because it is used to activate the system and then user need to use DarkLoop function instead of main when developing under AmiDARK Engine. All includes are here so all is included in this project. It similar to like if it was only 1 big file :p
Regards, Fred
All we have to decide is what to do with the time that is given to us.
Okay. I wouldn't recomend extending that approach to far, it's better keep your objects seperate, so that if a program links against your library, it doesn't require all functionailty, then it doesn't draw in all the code. Thus making a smaller more efficient system.
So all I can recomend is you try doing a 'make clean', then 'make all' again.
Post the output here so we can make sure the corect files are being generated.
I've seen your ouput for the testapp, but I'm not sure that I've seen the make output for your library, it's this I want to see, it may not tell anything, but it'll eliminate possibilities.
in fact, all includes that contain "_static.c" contain a static definition of a function That mean that these functions are defined
static ...
in the original files. Is it a problem ?
Quite possibly. If a function is intended to be visable outside the object file it's compiled, let alone aout side your library, then it must not be declared static.
I would have thought that you get a warning when building your library though.
In fact a here quick test gives an error in that case...
ram:test.c:5: error: static declaration of 'foo' follows non-static declaration ram:test.c:1: error: previous declaration of 'foo' was here