English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 05 August 2020, 23:02   #1
FirstNE
Registered User
 
Join Date: May 2020
Location: Norwich, CT, USA
Posts: 39
Standard C libraries? aka fopen,fread,fwrite

I am using fopen, fread, fwrite in my code which compiles ok using vbcc, but the linker complains I'm missing _open,_read,_write. Anyone know what the missing library is called?\ or where I might find it?
FirstNE is offline  
Old 06 August 2020, 00:35   #2
Docent
Registered User
 
Join Date: Mar 2019
Location: Poland
Posts: 59
It looks like you compile for an embedded system and not AmigaOS.
What is your compilation params provided to vbcc?
Docent is offline  
Old 06 August 2020, 08:00   #3
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,993
Posixlib. See Aminet.
Hedeon is offline  
Old 06 August 2020, 11:26   #4
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
open(), read() and write() are not part of the ISO-C standard, so you cannot expect them to be in a C library, and really portable C code would not use them.

These are Unix system calls and conform to the POSIX standard. Some C libraries emulate them to simplify porting of Unix sources, but vbcc does not. See Hedeon's reply for an alternative.

The intention behind that is to enforce clean ISO-C code as much as possible, so you can be sure that a source which compiles with vbcc should compile with any ISO-C compliant compiler.
phx is offline  
Old 06 August 2020, 11:46   #5
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
OP said he tried using fopen, fread, fwrite. (and got linking errors on _open etc)

I think those are standard lib as of C89.

Docent's approach sounds more logical to me.
alkis is offline  
Old 06 August 2020, 17:40   #6
FirstNE
Registered User
 
Join Date: May 2020
Location: Norwich, CT, USA
Posts: 39
Quote:
Originally Posted by Docent View Post
It looks like you compile for an embedded system and not AmigaOS.
What is your compilation params provided to vbcc?

Here's the makefile:


OBJECTS = morale.o move.o report.o gun_fire.o gun_load.o main.o

game: $(OBJECTS)
vc +aos68k -lvc -O2 -I$(NDK_INC) -o game $(OBJECTS) -lmieee -lauto -lamiga

main.o: main.c common.h /lib/ship.h /lib/country.h /lib/guns.h
morale.o: morale.c common.h /lib/ship.h /lib/guns.h
move.o: move.c common.h /lib/ship.h
report.o: report.c common.h /lib/ship.h
gun_fire.o: gun_fire.c common.h /lib/ship.h /lib/guns.h
gun_load.o: gun_load.c common.h /lib/ship.h /lib/guns.h
FirstNE is offline  
Old 06 August 2020, 17:46   #7
FirstNE
Registered User
 
Join Date: May 2020
Location: Norwich, CT, USA
Posts: 39
Quote:
Originally Posted by Hedeon View Post
Posixlib. See Aminet.

Yes, this looks like what I am looking for. Will test it out in a while...

Edit: yes, this did the trick! Thank you!

Last edited by FirstNE; 06 August 2020 at 19:38.
FirstNE is offline  
Old 06 August 2020, 20:25   #8
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by FirstNE View Post
vc +aos68k -lvc -O2 -I$(NDK_INC) -o game $(OBJECTS) -lmieee -lauto -lamiga
You should better not write -lvc there. There is also no need for it.
  1. As long as you don't give the -nostdlib option the frontend will always link with vc.lib automatically, after all other libraries on the command line.
  2. You may want to, or even need to, replace functions from vc.lib, which only works when the linker sees them in objects/libs which appear earlier. For example the math libraries (like mieee.lib) would replace the printf-like functions in vc.lib, to add floating-point support to them (%f, %g, etc.).
phx is offline  
Old 07 August 2020, 22:05   #9
FirstNE
Registered User
 
Join Date: May 2020
Location: Norwich, CT, USA
Posts: 39
OK, thanks! Back in the day I used SAS/C so it's an adventure in using vbcc.
FirstNE is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with fread while booting game from adf MacSpain Coders. General 5 16 May 2020 11:34
M68K and libraries rcman Coders. Asm / Hardware 3 05 February 2020 21:03
Libraries Syntrax support.Other 6 31 March 2019 15:59
Equivalent libraries from standard c to amiga c _ThEcRoW Coders. General 6 14 December 2005 17:01

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:37.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08042 seconds with 15 queries