Amiga.org
Amiga computer related discussion => Amiga/MorphOS/AROS Programmers Forum => Topic started by: Daniele on January 10, 2014, 06:01:18 PM
-
Hello!
I am trying to install VBCC and compile some piece of code, just some examples in C language.
First of all I downloaded the 3.9 NDk from Haage&Partner and saved the NDK_3.9 drawer in my Work: HD partition.
Accordingly with the instructions of the site
http://sun.hasenbraten.de/vbcc/index.php?view=targets
I downloaded the files vbcc_bin_amigaos68k.lha and vbcc_target_m68k-amigaos.lha that are respectively the binary and the target file.
Installed firstly the bin and after the target over my Work: partition I was asked to tell the installer the path of the include files so I selected the drawer Work:NDK_3.9/include/include_h
as suggested here in the thread
http://www.amiga.org/forums/showthread.php?t=34765
Now it happens that if I try to compile a source like for example the 1st example of screen or window of the file http://aminet.net/package/dev/c/ACM
with the command
vc screen.c -o screen
I have a huge list of errors like showed above....
t_3_0.o: In "_main":
Error 21: t_3_0.o (CODE+0x8): Reference to undefined symbol _OpenLibrary.
t_3_0.o: In "l5":
Error 21: t_3_0.o (CODE+0x24): Reference to undefined symbol _OpenScreen.
t_3_0.o: In "l6":
Error 21: t_3_0.o (CODE+0x3a): Reference to undefined symbol _CloseLibrary.
t_3_0.o: In "l7":
Error 21: t_3_0.o (CODE+0x64): Reference to undefined symbol _CloseLibrary.
Error 21: t_3_0.o (CODE+0x4c): Reference to undefined symbol _Delay.
Error 21: t_3_0.o (CODE+0x58): Reference to undefined symbol _CloseScreen.
vlink failed returncode 20
vlink -bamigahunk -x -Bstatic -Cvbcc -nostdlib vlibos3:startup.o "T:t_3_0.o" -s -Rshort -Lvlibos3: -lvc -o screen failed
What do you think I should do to get the compiler doing his job correctly?
Thanks for your advice,
Daniele
-
These are missing in your code:
#include
#include
#include
And if you find these, remove them:
#include
#include
#include
-
Hello Thomas! Thanks for helping me....
Now I have much less errors and the code works!
I only get:
> CloseLibrary( IntuitionBase );
warning 85 in line 69 of "screen.c": assignment of different pointers
> CloseLibrary( IntuitionBase );
warning 85 in line 92 of "screen.c": assignment of different pointers
What else to change to get it work perfectly?
-
Try CloseLibrary((struct Library *)IntuitionBase);
How does the corresponding OpenLibrary look like?
-
How does the corresponding OpenLibrary look like?
mmmm...
I think it would be better to post the source code because I am a very beginner! :)
I am just trying to set up a modern C enviroment to start studying C language and made some exercises.
Thank you very much Thomas I truly appreciate your time and effort!
So the piece of code is...
#include
struct IntuitionBase *IntuitionBase;
struct Screen *my_screen;
struct NewScreen my_new_screen=
{
0,
0,
320,
200,
3,
0,
1,
NULL,
CUSTOMSCREEN,
NULL,
"MY SCREEN",
NULL,
NULL
};
main()
{
IntuitionBase = (struct IntuitionBase *)
OpenLibrary( "intuition.library", 0 );
if( IntuitionBase == NULL )
exit();
my_screen = (struct Screen *) OpenScreen( &my_new_screen );
if(my_screen == NULL)
{
CloseLibrary( IntuitionBase );
exit();
}
Delay( 50 * 30);
CloseScreen( my_screen );
CloseLibrary( IntuitionBase );
}
-
And this is how it should be:
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
struct IntuitionBase *IntuitionBase;
struct Screen *my_screen;
struct NewScreen my_new_screen=
{
0,
0,
320,
200,
3,
0,
1,
NULL,
CUSTOMSCREEN,
NULL,
"MY SCREEN",
NULL,
NULL
};
int main(void)
{
IntuitionBase = (struct IntuitionBase *) OpenLibrary( "intuition.library", 0 );
if( IntuitionBase == NULL )
return (RETURN_FAIL);
my_screen = (struct Screen *) OpenScreen( &my_new_screen );
if(my_screen == NULL)
{
CloseLibrary( (struct Library *) IntuitionBase );
return (RETURN_FAIL);
}
Delay( TICKS_PER_SECOND * 5); /* changed from 30 seconds to 5 seconds because I am impatient */
CloseScreen( my_screen );
CloseLibrary( (struct Library *) IntuitionBase );
return (RETURN_OK);
}
-
Thomas thank you *very* much for your support.
I am now able to compile this sample code and see it working but ... honestly .... what I am really wondering as beginner is if "changes" would always be necessary in the examples I see on the amiga programming books.
Should I always made some fixes in order to get them compiled properly?
Is this depending by the compiler I use or what?
Let me figure out...
-
The C language has evolved a bit since those books were written. Older compilers were less strict. Usually this led to bad code. Nowadays the compiler helps you to find errors easier. Older compilers more supported lazy programmers.
So yes, if an example contains
main()
{
...
}
then it probably contains many mistakes which you have to correct.