Apologies because this is probably a silly question. I have a small application that I have written in Gnu Pascal that works nicely under Fedora Core 7 on an Intel PC using gpc 20020502 (yes I know it is old but there are reasons not connected with this task). I now want to port the application to Apple Macs running OS-X. I have downloaded and installed gpc 20051116 from http://www.microbizz.nl/gpc.html and that appears to be working. My application compiles OK but fails at the linking stage with the message:
/usr/bin/ld: can't locate file for : -lcrt1.o
The only unit my application includes is gpc.pas and the only screen input and output is simple reads and writes. A search doesn't find a crt1.o anywhere on the system. What do I do next?
Martin Liddle wrote:
Apologies because this is probably a silly question. I have a small application that I have written in Gnu Pascal that works nicely under Fedora Core 7 on an Intel PC using gpc 20020502 (yes I know it is old but there are reasons not connected with this task). I now want to port the application to Apple Macs running OS-X. I have downloaded and installed gpc 20051116 from http://www.microbizz.nl/gpc.html and that appears to be working. My application compiles OK but fails at the linking stage with the message:
/usr/bin/ld: can't locate file for : -lcrt1.o
The only unit my application includes is gpc.pas and the only screen input and output is simple reads and writes. A search doesn't find a crt1.o anywhere on the system. What do I do next?
crt1.o is in /usr/lib, or, more general, the result of `gpc -print-file-name=crt1.o`.
[p17-2:~] adriaan% gpc -print-file-name=crt1.o /usr/lib/crt1.o
However, linking-in crt1.o should normally happen automatically. What exactly are you doing to compile and link ? On what version of OS X ? Etcetera.
Regards,
Adriaan van Os
In message 47861FD8.5020200@microbizz.nl, Adriaan van Os gpc@microbizz.nl writes
crt1.o is in /usr/lib, or, more general, the result of `gpc -print-file-name=crt1.o`.
[p17-2:~] adriaan% gpc -print-file-name=crt1.o /usr/lib/crt1.o
However, linking-in crt1.o should normally happen automatically. What exactly are you doing to compile and link ? On what version of OS X ? Etcetera.
Thanks for the help. Let me explain a little more; I am a reasonably experienced Pascal programmer but know nothing of the Apple Mac. I am doing this for free as a small service to the user group for the Humax 9200 PVR. The particular computer in question is my step daughters who knows nothing of software development (but everything about fashion design) hence it may well not have the appropriate components installed. The operating system is 10.3 (if you can tell me how to determine the exact version, I will happily do that) There is no file crt1.o in /usr/lib; what package do I need to install to obtain it? So far the only thing I have installed is gpc from your site. I have been using
gpc --automake flash9200
which under Linux will compile and link. Thanks again for your interest.
Martin Liddle wrote:
The operating system is 10.3 (if you can tell me how to determine the exact version, I will happily do that) There is no file crt1.o in /usr/lib; what package do I need to install to obtain it? So far the only thing I have installed is gpc from your site. I have been using
gpc --automake flash9200
which under Linux will compile and link. Thanks again for your interest.
Ah, but since you do seem to have a linker and assembler installed, I assume you are using those from my website ? Anyway, the solution to your problem I think is to install the "Xcode" packages that came with the OS X 10.3 system software. Note that older versions of Xcode used to be called ProjectBuilder, but I can't remember exactly when the name was changed (it might have been OS X 10.2).
Regards,
Adriaan van Os
On 10 Jan 2008, at 18:07, Adriaan van Os wrote:
Ah, but since you do seem to have a linker and assembler installed, I assume you are using those from my website ? Anyway, the solution to your problem I think is to install the "Xcode" packages that came with the OS X 10.3 system software. Note that older versions of Xcode used to be called ProjectBuilder, but I can't remember exactly when the name was changed (it might have been OS X 10.2).
Xcode 1.5 is the latest version that was released for Mac OS X 10.3.x (may require 10.3.9).
To Martin Liddle: to find the exact version, execute "sw_vers" in a Terminal window. You can update to 10.3.9 via Software Update in the System Preferences should that be necessary.
Jonas
In message F7C32ECD-BFFA-4CD4-ADB5-560BEA97EAED@elis.ugent.be, Jonas Maebe jonas.maebe@elis.ugent.be writes
Xcode 1.5 is the latest version that was released for Mac OS X 10.3.x (may require 10.3.9).
To Martin Liddle: to find the exact version, execute "sw_vers" in a Terminal window. You can update to 10.3.9 via Software Update in the System Preferences should that be necessary.
Thanks; exact version is 10.3.9. I will try and stay with XCode 1.1 for the moment because I will probably need to upgrade to 10.4 to do everything I want but I would like to demonstrate 'proof of concept' before then.
In message 478650D5.2080709@microbizz.nl, Adriaan van Os gpc@microbizz.nl writes
Anyway, the solution to your problem I think is to install the "Xcode" packages that came with the OS X 10.3 system software.
Adriaan
Thank you for your continuing help. OK I have installed XCode 1.1 (it was a whole lot easier once I realised the installation image was on the disk, just not installed). That takes me a step further but then I hit a whole string of messages; the first couple of which are:
/usr/bin/ld: /Developer/Pascal/gpc345u2/lib/gcc/powerpc-apple-darwin7/3.4.5/libgpc.a(e rror.o) r_type field of relocation entry 728 in section (__TEXT,__text) invalid /usr/bin/ld: /Developer/Pascal/gpc345u2/lib/gcc/powerpc-apple-darwin7/3.4.5/libgpc.a(e rror.o) stray relocation PPC_RELOC_PAIR entry (729) in section (__TEXT,__text)
Any more clues about what to do?
On 10 Jan 2008, at 19:33, Martin Liddle wrote:
In message 478650D5.2080709@microbizz.nl, Adriaan van Os gpc@microbizz.nl writes
Anyway, the solution to your problem I think is to install the "Xcode" packages that came with the OS X 10.3 system software.
Adriaan
Thank you for your continuing help. OK I have installed XCode 1.1 (it was a whole lot easier once I realised the installation image was on the disk, just not installed). That takes me a step further but then I hit a whole string of messages; the first couple of which are:
/usr/bin/ld: /Developer/Pascal/gpc345u2/lib/gcc/powerpc-apple- darwin7/3.4.5/libgpc.a(e rror.o) r_type field of relocation entry 728 in section (__TEXT,__text) invalid /usr/bin/ld: /Developer/Pascal/gpc345u2/lib/gcc/powerpc-apple- darwin7/3.4.5/libgpc.a(e rror.o) stray relocation PPC_RELOC_PAIR entry (729) in section (__TEXT,__text)
Any more clues about what to do?
Try reinstalling the cctools that Adriaan posted on his website ( http://www.microbizz.nl/gpc.html ), as the Xcode installer probably overwrote those with older versions.
Jonas
In message 4EBD9482-D73C-414A-9757-5AAFFBE9DF9E@elis.ugent.be, Jonas Maebe jonas.maebe@elis.ugent.be writes
Try reinstalling the cctools that Adriaan posted on his website ( http://www.microbizz.nl/gpc.html ), as the Xcode installer probably overwrote those with older versions.
Thanks. Yes that worked and now I have an executable! Next to find if it works; I may be back.
Just to continue this story, I now have a working executable. However I do still have a problem that I would like to resolve. The software is using a serial port. The serial port is provided by a Dynamode USB to serial adapter (which uses the Prolific chipset). The latest drivers from the Prolific web site are installed. My software works correctly providing that the adapter has just been plugged in. Attempting to use the software a second time fails; it looks to me as though some setting perhaps baud rate isn't correct on subsequent attempts (some times the first byte from the other end is missed or is incorrect). An extract of my code for opening and setting up the serial port is:
type Tterm_arg=packed record c_iflag:integer; c_oflag:integer; c_cflag:word; c_lflag:integer; c_cc :packed array [0..19] of char; c_ispeed:integer; c_ospeed:integer; end; var fildes_block,fildes_out:integer; block_status, write_status:integer; term_arg_block,SaveTermArg:Tterm_arg;
function open(protected Path: Cstring; Oflag: word; Mode: word): integer; External; function tcsetattr(fd:integer;actions:integer;pt:pointer):integer;External; function tcgetattr(fd:integer;pt:pointer):integer;External; procedure cfmakeraw(pt:pointer);External; function cfsetspeed(pt:pointer;speed:integer):integer;External; function cfgetispeed(pt:pointer):integer;External; function cfgetospeed(pt:pointer):integer;External; function sys_write(Fildes: integer; Buf: pointer; NByte: integer): integer; asmname 'write'; function sys_read(Fildes: integer; Buf: pointer; NByte: integer): integer; asmname 'read'; function sys_close(Fildes: integer): integer; asmname 'close';
function OpenCOMPort: boolean; CONST O_RDONLY = 8#0; O_WRONLY = 8#1; O_RDWR = 8#2; O_NONBLOCK= 8#4;
var Result : boolean; Mode:Word; begin Result:=True; SerialDevicename:='usbserial'; block_status:=integer(O_RDWR or O_NONBLOCK); mode:=0; fildes_block:=open(String2Cstring('/dev/tty.'+SerialDeviceName),word(blo ck_status),mode); if fildes_block<=0 then begin Result:=False; end; OpenCOMPort := Result; end;
function SetupCOMPort: boolean; const CS8 =16#0300; CLOCAL =16#8000; CREAD =16#0800; VMIN=16; VTIME=17;
var loop,InputSpeed,OutputSpeed:integer; dummy:word; Result : boolean;
begin (*SetupComPort*) retval:=tcgetattr(fildes_block,Addr(SaveTermArg)); If Retval<0 then Begin Writeln('Error retrieving existing serial port settings.'); Halt; End; Term_arg_block:=SaveTermArg; With term_arg_block Do Begin c_iflag:=0; c_oflag:=0; c_cflag:=(CREAD or CLOCAL or CS8); c_lflag:=0; for loop:=0 to 19 do c_cc[loop]:=chr(0); End; Result := True; cfmakeraw(Addr(term_arg_block)); Retval:=cfsetspeed(Addr(Term_arg_block),115200); If Retval=-1 then Begin Writeln('Error when setting speed.'); Halt; End; retval:=tcsetattr(fildes_block,TCSANOW,Addr(term_arg_block)); if retval=-1 then begin ErrorString:=CStringStrError(ErrorNumber); writeln(' When setting blocking, tcsetattr returned ',retval:1, ' errno ',ErrorNumber:1); writeln(' ',CString2String(ErrorString)); Result:=False; end; SetupCOMPort := Result; end;
Procedure WriteBuffer(Buffer : TBuffer; Size : longint); var Count: LongWord; begin retval:=sys_write(fildes_block,addr(Buffer),Size); if retval<0 then Begin ErrorString:=CStringStrError(ErrorNumber); writeln('Error from sys_write in writebuffer, retval = ', retval:1,' error = ',ErrorNumber); writeln(' ',CString2String(ErrorString)); End; end;
Procedure WriteByte(b : byte); var Count: LongWord; Begin retval:=sys_write(fildes_block,addr(b),1); if retval<0 then Begin ErrorString:=CStringStrError(ErrorNumber); writeln('Error from sys_write in writebyte, retval = ', retval:1,' error = ',ErrorNumber); writeln(' ',CString2String(ErrorString)); Halt; End; End;
Function ReadByte(var b : byte) : boolean; Var LoopCount,Retval:Integer; begin b:=0; LoopCount:=0; Retval:=0; Repeat retval:=sys_read(fildes_block,addr(b),1); If Retval<=0 then Begin Inc(LoopCount); SleepMicroSeconds(50); End; Until (Retval>0) or (Loopcount>20000); ReadByte:=(RetVal>0); End;
Procedure CloseCOMPort; Var Retval:Integer; Begin retval:=tcsetattr(fildes_block,TCSANOW,Addr(SaveTermArg)); Retval:=Sys_close(Fildes_block); End;
Any thoughts about why this only works once? Any other comments or suggestions on the code snippet?