English Amiga Board


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

 
 
Thread Tools
Old 08 February 2021, 22:28   #1
alancfrancis
Registered User
 
alancfrancis's Avatar
 
Join Date: Jun 2020
Location: Scotland
Posts: 146
Noob Question about Library Formats and VBCC

So I'm playing with libcurl https://aminet.net/package/comm/tcp/curl-7.74.0.lha as a way to make https requests on OS3.x. Theres's a simple https.c example that comes with the lib, which I am trying to build with vbcc.

I have a simple VC command line that specifies the include and lib directories for libz, libcurl and amissl-4.7, along with @phx's PosixLib and the 3.9 NDK. All compiles just fine but when I get to linking I get a message saying libamisslauto.a is
"format not recognised".

Update: removed a bunch of stuff I had written about the Mac "file" utility as it was lying to me. libamisslauto, and libz (which I have definitely built with before) look similar in structure. in a hex editor they both start with "!<arch> __.SYMDEF". libcurl looks different in the hex editor, but its not complaining about that file.

I'm a bit new to all this so I'm not clear what to take from this information. VBCC/VLINK clearly doesnt like libamisslauto.a ... is there a way to find out why ?

Thanks in advance for any help

Alan

Last edited by alancfrancis; 08 February 2021 at 22:45.
alancfrancis is offline  
Old 08 February 2021, 22:36   #2
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,993
You forgot the .lha in your link.

vbcc lib format is different from gcc (which this one is) lib format.

Not sure if they can be converted from one to the other. I think the vbcc libs end with .lib

Last edited by Hedeon; 08 February 2021 at 22:50.
Hedeon is offline  
Old 08 February 2021, 22:44   #3
alancfrancis
Registered User
 
alancfrancis's Avatar
 
Join Date: Jun 2020
Location: Scotland
Posts: 146
@Hedeon thanks. Fixed the link. That sucks... so I'd have to build amissl from source using VBCC to get a lib I can use ?
alancfrancis is offline  
Old 09 February 2021, 13:52   #4
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by Hedeon View Post
vbcc lib format is different from gcc (which this one is) lib format.
There is no "vbcc" or "gcc" lib format. The ar(1) tool is a similar file archiver like tar(1), but is mainly used to archive object files (.a extension). On AmigaOS, hunk-format object files were traditionally just concatenated into a single file with the "join" command and got a .lib extension. But there is also the HUNK_LIB format, introduced by SAS/C, which provides an index for the library, like ar(1).

Dealing with object and library file formats is the job of the linker. vlink, in this case, which supports many different formats. But it wouldn't expect a hunk-format object file in a ".a" linker-lib, for example (although this could be easily added).

It's just that vbcc's m68k-amigaos target uses hunk-format object files, defined in its config files. I made this choice because this is the traditional format of all real Amiga compilers and linkers, which provides best compatibility with other Amiga tools. m68k-ataritos is completely different, of course, and uses .a libraries with VOBJ object files.

Quote:
Not sure if they can be converted from one to the other.
Yes. Theoretically you can do that. Extract the archive
ar xv libxyz.a
and convert all object files from a.out format to hunk-format, for example:
vlink -bamigahunk -r -o hunkobj1.o aoutobj1.o
. Then put the objects into an Amiga linker lib:
join as xyz.lib hunkobj1.o ...


BTW, I got the files from alanfrancis and libamisslauto.a seems corrupt. At least no binutils-ar can list or extract it correctly. libz.a is ok, although a gcc a.out library, but still links with vlink.
phx is offline  
Old 11 February 2021, 22:54   #5
Futaura
Registered User
 
Futaura's Avatar
 
Join Date: Aug 2018
Location: United Kingdom
Posts: 198
Quote:
Originally Posted by alancfrancis View Post
@Hedeon thanks. Fixed the link. That sucks... so I'd have to build amissl from source using VBCC to get a lib I can use ?
Only https://github.com/jens-maus/amissl/..._amissl_main.c would need recompiling, although it will need a few tweaks, which is what libamisslauto consists of. Or you could save yourself hassle and open AmiSSL yourself.
Futaura is offline  
Old 12 February 2021, 18:53   #6
Futaura
Registered User
 
Futaura's Avatar
 
Join Date: Aug 2018
Location: United Kingdom
Posts: 198
Quote:
Originally Posted by phx View Post
BTW, I got the files from alanfrancis and libamisslauto.a seems corrupt. At least no binutils-ar can list or extract it correctly. libz.a is ok, although a gcc a.out library, but still links with vlink.
Thanks for this. It seems the binutils-ar we are using (GNU ar 2.14 20030612 (adtools build 20080628)) is limited to name lengths of 15 in some way. It either creates corrupt archives if any names are longer than that or isn't able to handle reading back long names! So, autoinit_amissl_main.o clearly is too long. All the OpenSSL object files are not longer than 15 characters, otherwise this would have gotten noticed much sooner.

Have now tried using "ar rf" to truncate the name and it seems to work now - see attached fixed libamisslauto.a for 68k in case it is of any help.
Attached Files
File Type: lha libamisslauto.lha (986 Bytes, 72 views)
Futaura is offline  
Old 13 February 2021, 19:39   #7
Futaura
Registered User
 
Futaura's Avatar
 
Join Date: Aug 2018
Location: United Kingdom
Posts: 198
FYI, I've tweaked the AmiSSL includes a little to be more compatible with VBCC - it was mainly the missing ssize_t type that was causing problem. I've also added native VBCC support into autoinit_amissl_main.c so that it can be easily recompiled with VBCC (and SAS/C support added back too) into a native link library.

I can now compile the example https.c (I've updated this too) with VBCC with a vanilla install, plus the Roadshow netincludes, for both OS3 and OS4.

See https://github.com/jens-maus/amissl/...e481e9071fdd80 for details - these changes will all be included in the next AmiSSL release.
Futaura is offline  
Old 14 February 2021, 14:32   #8
alancfrancis
Registered User
 
alancfrancis's Avatar
 
Join Date: Jun 2020
Location: Scotland
Posts: 146
@futaura @phx Thanks so much for all your help and time. As I said to Frank I've been programming for 30+ years and am betraying an embarrassing lack of knowledge in how the basic tools work. I blame TurboC, BorlandC++, VisualC++, Java, Ruby and Xcode for shielding me from the ins and outs of all this :-). But I'm glad to be getting my hands more dirty now, at least in my hobby project.
alancfrancis is offline  
Old 14 February 2021, 15:15   #9
alancfrancis
Registered User
 
alancfrancis's Avatar
 
Join Date: Jun 2020
Location: Scotland
Posts: 146
Quote:
Originally Posted by Futaura View Post
Only https://github.com/jens-maus/amissl/..._amissl_main.c would need recompiling, although it will need a few tweaks, which is what libamisslauto consists of. Or you could save yourself hassle and open AmiSSL yourself.
Just to clarify here (cause I'm aware "that sucks" could sound like I was blaming AmiSSL rather than the universe) I was trying to basically cargo cult the libcurl https example, just to understand if it did what I needed. So I hadn't even begun to look at changing any code. I was just trying to build it by following the instructions (which specifically included libamisslauto).

When I couldn't do that, I went down a garden path of trying to understand why the library wasn't working and ended up installing Bebbos GCC toolchain and the whole thing worked out of the box. (yay!)

As an over thinker, and someone who's aware you probably get a lot of people complaining about work you do for free, I just wanted to be super clear that I'm in no way bitching about VBCC or AmiSSL, just frustrated when following instructions doesn't work and *I* don't understand enough to guess why.

Glad to see that maybe I helped find a bug somewhere by asking idiot questions :-)

Alan
alancfrancis 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
noob question Pixelfill Coders. Asm / Hardware 7 07 February 2020 15:04
Noob Question 1: Amiga formats Peilton New to Emulation or Amiga scene 21 16 January 2010 22:36
Noob question, sorry. fitzsteve project.WHDLoad 3 23 August 2009 16:56
Noob Question but anyway. trackah123 Coders. General 17 30 October 2008 14:39
yet another noob question AliasXZ New to Emulation or Amiga scene 11 23 January 2008 23:28

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 14:10.

Top

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