Newbie Pure C

C and PASCAL (or any other high-level languages) in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

FreekBos
Atarian
Atarian
Posts: 9
Joined: Sat Dec 31, 2016 12:44 pm

Newbie Pure C

Postby FreekBos » Sat Dec 31, 2016 12:52 pm

Hi guys.

I am trying to write my first c application on the Atari 520ST+
I decided to use Pure C and ofter several hours of copying and trying to get the harddisk to function again I am finaly ready to start programming.

When I compile a suuuuper simple c application I keep getting Bus Error - Program Aborted.

My Test.prj file looks like this:

Code: Select all

test.prg
=
test.c


My Test.C file looks like this:

Code: Select all

int main()
{
   return 0;
}


What am I doing wrong? Am I missing some setting in Pure C or something?

User avatar
Arne
Captain Atari
Captain Atari
Posts: 400
Joined: Thu Nov 01, 2007 10:01 am

Re: Newbie Pure C

Postby Arne » Sun Jan 01, 2017 6:02 am

Happened to me after some PureC off-time, too.
You forgot the startup code

Code: Select all

test.prg
=
pcstart.o
test.c

It has to be the first item after the equation sign "="!
Image

FreekBos
Atarian
Atarian
Posts: 9
Joined: Sat Dec 31, 2016 12:44 pm

Re: Newbie Pure C

Postby FreekBos » Sun Jan 01, 2017 2:23 pm

Thanks for the swift reply!
Now I get stuck with the Linker when compiling the code.
It says
C:\Tools\Code\Pure_C\Lib\PCStart:
Undefined symbol: '_fpuinit'
Undefined symbol: 'main'
Undefined symbol: '_freeAll'

Do I have a Linker or Compiler setting wrong?

FreekBos
Atarian
Atarian
Posts: 9
Joined: Sat Dec 31, 2016 12:44 pm

Re: Newbie Pure C

Postby FreekBos » Sun Jan 01, 2017 2:25 pm

And... when I swithc on the Linker option -J (Create new object file)
It tries to run... but it gives me the error 'Load format error'.

User avatar
Arne
Captain Atari
Captain Atari
Posts: 400
Joined: Thu Nov 01, 2007 10:01 am

Re: Newbie Pure C

Postby Arne » Sun Jan 01, 2017 6:08 pm

Is the path to the libs set correctly?
Anyway: you need to add the appropriate libs to the project file, too.
Why don't you check "default.prj"?
Image

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1563
Joined: Sun Jul 31, 2011 1:11 pm

Re: Newbie Pure C

Postby Eero Tamminen » Sun Jan 01, 2017 6:50 pm

FreekBos wrote:And... when I swithc on the Linker option -J (Create new object file)
It tries to run... but it gives me the error 'Load format error'.


You don't need linker option, you need add the standard C-library.

Project file for (Pure-C compatible) AHCC Hello Word looks like this:

Code: Select all

hello.tos
=
ahcstart.o
hello.c
ahccstd.lib


(For PC, the start object and library names are different from AHCC, headers are compatible.)

FreekBos
Atarian
Atarian
Posts: 9
Joined: Sat Dec 31, 2016 12:44 pm

Re: Newbie Pure C

Postby FreekBos » Fri Jan 06, 2017 10:40 am

Thanks Eero, that did the job.
For Pure C I had to change the PRJ file to:

test.tos
=
pcstart.o
test.c
pcstdlib.lib

User avatar
LaceySnr
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 111
Joined: Wed Jun 26, 2013 5:00 am
Contact:

Re: Newbie Pure C

Postby LaceySnr » Fri Jan 06, 2017 10:54 am

Good to see you're up and running! Once you get more comfortable with C you should check out dml's AGT: https://bitbucket.org/d_m_l/agtools

It's a toolkit for building games on the STE :)


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 2 guests