Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to compile with vbcc the https.c #44

Open
walkero-gr opened this issue Feb 27, 2020 · 8 comments
Open

Trying to compile with vbcc the https.c #44

walkero-gr opened this issue Feb 27, 2020 · 8 comments

Comments

@walkero-gr
Copy link

walkero-gr commented Feb 27, 2020

I am trying to compile with vbcc the example code https.c, but I am getting errors. I am using a cross compiling environment, with AmigaOS 4 SDK and latest AmiSSL 4.4 dev files installed.

I am using the following command to compile it:
vc +aosppc +newlib -I/opt/sdk/ppc-amigaos/Include/include_h -I/opt/sdk/ppc-amigaos/Include/netinclude -I/opt/sdk/ppc-amigaos/newlib/include -I/opt/sdk/AmiSSL/include -lauto https.c -o https -v

I get a few errors and a lot of warnings. I think that I am missing something.

vc frontend for vbcc (c) in 1995-2016 by Volker Barthelmann
vbccppc -quiet "https.c" -o= "/tmp/file3LINRb.asm" -I/opt/sdk/ppc-amigaos/Include/include_h -I/opt/sdk/ppc-amigaos/Include/netinclude -I/opt/sdk/ppc-amigaos/newlib/include -I/opt/sdk/AmiSSL/include -elf -no-regnames -no-multiple-ccs -madd -c99 -use-commons  -O=1 -I$VBCC/targets/ppc-amigaos/include -D__amigaos4__
>	BPTR err = ErrorOutput();
warning 161 in line 48 of "https.c": implicit declaration of function <ErrorOutput>
>	return(err ? err : Output());
warning 161 in line 50 of "https.c": implicit declaration of function <Output>
>						Printf("SSL connection using %s\n", SSL_get_cipher(ssl));
warning 161 in line 119 of "https.c": implicit declaration of function <Printf>
>								FPrintf(GetStdErr(), "Warning: couldn't read subject name in certificat
warning 161 in line 134 of "https.c": implicit declaration of function <FPrintf>
>									FWrite(Output(), buffer, ssl_err, 1);
warning 161 in line 157 of "https.c": implicit declaration of function <FWrite>
>								FFlush(Output());
warning 161 in line 159 of "https.c": implicit declaration of function <FFlush>
>					CloseSocket(sock);
warning 161 in line 181 of "https.c": implicit declaration of function <CloseSocket>
>	if (!(SocketBase = OpenLibrary("bsdsocket.library", 4)))
warning 161 in line 215 of "https.c": implicit declaration of function <OpenLibrary>
>	if (!(SocketBase = OpenLibrary("bsdsocket.library", 4)))
error 39 in line 215 of "https.c": invalid types for assignment
>	else if (!(ISocket = (struct SocketIFace *)GetInterface(SocketBase, "main", 1,
warning 161 in line 218 of "https.c": implicit declaration of function <GetInterface>
>	                                          AMISSLMASTER_MIN_VERSION)))
error 39 in line 222 of "https.c": invalid types for assignment
>	else if (!InitAmiSSLMaster(AMISSL_CURRENT_VERSION, TRUE))
warning 161 in line 230 of "https.c": implicit declaration of function <InitAmiSSLMaster>
>	else if (!(AmiSSLBase = OpenAmiSSL()))
warning 161 in line 232 of "https.c": implicit declaration of function <OpenAmiSSL>
>	else if (!(AmiSSLBase = OpenAmiSSL()))
error 39 in line 232 of "https.c": invalid types for assignment
>	                    TAG_DONE) != 0)
warning 161 in line 242 of "https.c": implicit declaration of function <InitAmiSSL>
>			CleanupAmiSSL(TAG_DONE);
warning 161 in line 265 of "https.c": implicit declaration of function <CleanupAmiSSL>
>			DropInterface((struct Interface *)IAmiSSL);
warning 161 in line 266 of "https.c": implicit declaration of function <DropInterface>
>		CloseAmiSSL();
warning 161 in line 273 of "https.c": implicit declaration of function <CloseAmiSSL>
>	CloseLibrary(AmiSSLMasterBase);
warning 161 in line 282 of "https.c": implicit declaration of function <CloseLibrary>
>	if ((sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0)
warning 161 in line 306 of "https.c": implicit declaration of function <socket>
>			addr.sin_addr.s_addr = inet_addr(proxy);
warning 161 in line 313 of "https.c": implicit declaration of function <inet_addr>
>		if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) >= 0)
warning 161 in line 322 of "https.c": implicit declaration of function <connect>
>				if (send(sock, buffer, strlen(buffer), 0) >= 0)
warning 161 in line 340 of "https.c": implicit declaration of function <send>
>					if ((len = recv(sock, buffer, sizeof(buffer) - 1, 0)) >= 0)
warning 161 in line 347 of "https.c": implicit declaration of function <recv>
3 errors found!
vbccppc -quiet "https.c" -o= "/tmp/file3LINRb.asm" -I/opt/sdk/ppc-amigaos/Include/include_h -I/opt/sdk/ppc-amigaos/Include/netinclude -I/opt/sdk/ppc-amigaos/newlib/include -I/opt/sdk/AmiSSL/include -elf -no-regnames -no-multiple-ccs -madd -c99 -use-commons  -O=1 -I$VBCC/targets/ppc-amigaos/include -D__amigaos4__ failed

I tried to use PosixLib as well, but no luck.

Any idea what I am missing there?

@Futaura
Copy link
Collaborator

Futaura commented Feb 27, 2020

Try adding -D__USE_INLINE__ to your vc command line

@walkero-gr
Copy link
Author

walkero-gr commented Feb 28, 2020

Yeah. That did the trick. And I also had to remove the +newlib from my compiling command.

I tried to compile it for 68k as well with the following command:
vc +aos68k -c99 -lamiga -lauto -I/opt/sdk/NDK_3.9/Include/include_h -I/opt/sdk/PosixLib/include -I/opt/sdk/AmiSSL/include -D__USE_INLINE__ https.c -o https

but I am getting a couple of errors

vc frontend for vbcc (c) in 1995-2016 by Volker Barthelmann
vbccm68k -quiet -hunkdebug "https.c" -o= "/tmp/file6BoCQf.asm" -c99 -I/opt/sdk/NDK_3.9/Include/include_h -I/opt/sdk/PosixLib/include -I/opt/sdk/AmiSSL/include -D__USE_INLINE__  -O=1 -I$VBCC/targets/m68k-amigaos/include
>struct timeval {
error 13 in line 30 of "devices/timer.h": redeclaration of struct <timeval>
	included from file "/opt/sdk/NDK_3.9/Include/include_h/dos/dosextens.h":26
	included from file "/opt/sdk/NDK_3.9/Include/include_h/clib/dos_protos.h":21
	included from file "/opt/sdk/NDK_3.9/Include/include_h/pragmas/dos_pragmas.h":30
	included from file "/opt/sdk/NDK_3.9/Include/include_h/proto/dos.h":15
	included from file "https.c":19
>LONG socket(LONG domain, LONG type, LONG protocol);
warning 68 in line 33 of "clib/socket_protos.h": redeclaration of var <__Psocket> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG bind(LONG s, const struct sockaddr *name, LONG namelen);
warning 68 in line 34 of "clib/socket_protos.h": redeclaration of var <__Pbind> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG listen(LONG s, LONG backlog);
warning 68 in line 35 of "clib/socket_protos.h": redeclaration of var <__Plisten> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG accept(LONG s, struct sockaddr *addr, LONG *addrlen);
warning 68 in line 36 of "clib/socket_protos.h": redeclaration of var <__Paccept> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG connect(LONG s, const struct sockaddr *name, LONG namelen);
warning 68 in line 37 of "clib/socket_protos.h": redeclaration of var <__Pconnect> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG send(LONG s, const UBYTE *msg, LONG len, LONG flags);
warning 68 in line 38 of "clib/socket_protos.h": redeclaration of var <__Psend> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>		  const struct sockaddr *to, LONG tolen);
warning 68 in line 40 of "clib/socket_protos.h": redeclaration of var <__Psendto> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG sendmsg(LONG s, struct msghdr * msg, LONG flags);
warning 68 in line 41 of "clib/socket_protos.h": redeclaration of var <__Psendmsg> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG recv(LONG s, UBYTE *buf, LONG len, LONG flags);
warning 68 in line 42 of "clib/socket_protos.h": redeclaration of var <__Precv> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>		    struct sockaddr *from, LONG *fromlen);
warning 68 in line 44 of "clib/socket_protos.h": redeclaration of var <__Precvfrom> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG recvmsg(LONG s, struct msghdr * msg, LONG flags);
warning 68 in line 45 of "clib/socket_protos.h": redeclaration of var <__Precvmsg> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG shutdown(LONG s, LONG how);
warning 68 in line 46 of "clib/socket_protos.h": redeclaration of var <__Pshutdown> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>		     const void *optval, LONG optlen);
warning 68 in line 48 of "clib/socket_protos.h": redeclaration of var <__Psetsockopt> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>		     void *optval, LONG *optlen);
warning 68 in line 50 of "clib/socket_protos.h": redeclaration of var <__Pgetsockopt> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG getsockname(LONG s, struct sockaddr *name, LONG *namelen);
warning 68 in line 51 of "clib/socket_protos.h": redeclaration of var <__Pgetsockname> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>LONG getpeername(LONG s, struct sockaddr *name, LONG *namelen);
warning 68 in line 52 of "clib/socket_protos.h": redeclaration of var <__Pgetpeername> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>ULONG inet_addr(const UBYTE *);
warning 68 in line 79 of "clib/socket_protos.h": redeclaration of var <__Pinet_addr> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>ULONG inet_network(const UBYTE *);
warning 68 in line 80 of "clib/socket_protos.h": redeclaration of var <__Pinet_network> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>struct hostent  *gethostbyname(const UBYTE *name);
warning 68 in line 87 of "clib/socket_protos.h": redeclaration of var <__Pgethostbyname> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>struct hostent  *gethostbyaddr(const UBYTE *addr, LONG len, LONG type);
warning 68 in line 88 of "clib/socket_protos.h": redeclaration of var <__Pgethostbyaddr> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>struct netent   *getnetbyname(const UBYTE *name);
warning 68 in line 89 of "clib/socket_protos.h": redeclaration of var <__Pgetnetbyname> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>struct netent   *getnetbyaddr(LONG net, LONG type);
warning 68 in line 90 of "clib/socket_protos.h": redeclaration of var <__Pgetnetbyaddr> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>struct servent  *getservbyname(const UBYTE *name, const UBYTE *proto);
warning 68 in line 91 of "clib/socket_protos.h": redeclaration of var <__Pgetservbyname> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>struct servent  *getservbyport(LONG port, const UBYTE *proto);
warning 68 in line 92 of "clib/socket_protos.h": redeclaration of var <__Pgetservbyport> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>struct protoent *getprotobyname(const UBYTE *name);
warning 68 in line 93 of "clib/socket_protos.h": redeclaration of var <__Pgetprotobyname> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>struct protoent *getprotobynumber(LONG proto);
warning 68 in line 94 of "clib/socket_protos.h": redeclaration of var <__Pgetprotobynumber> with new type
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":8
	included from file "https.c":22
>#define socket(domain, type, protocol) __socket(SocketBase, (domain), (type), (
error 272 in line 9 of "inline/socket_protos.h": macro 'socket' redefined unidentically
	included from file "/opt/vbcc/targets/m68k-amigaos/include/proto/socket.h":22
	included from file "https.c":22
2 errors found!
vbccm68k -quiet -hunkdebug "https.c" -o= "/tmp/file6BoCQf.asm" -c99 -I/opt/sdk/NDK_3.9/Include/include_h -I/opt/sdk/PosixLib/include -I/opt/sdk/AmiSSL/include -D__USE_INLINE__  -O=1 -I$VBCC/targets/m68k-amigaos/include failed

Thank you for your valuable help. I just want to know that the development environment I am creating has what is needed to compile programs that need AmiSSL.

@Futaura
Copy link
Collaborator

Futaura commented Feb 28, 2020

No problem - if there is anything I can do to improve to SDK, I'll try to do it.

For the first error, you need to add -D__NEW_TIMEVAL_DEFINITION_USED__ - I'm going to modify https.c so these two definitions are added there too, so it is more obvious than having to decipher our Makefile.

For the socket warnings/errors where is your clib/socket_protos.h coming from? I can't seem to find __Psocket, etc, anywhere in the includes that I have. You appear to have two conflicting headers that are defining a socket() macro, for example. For testing with VBCC, I used some ancient AmiTCP includes (that I'm using with SAS/C!) to compile https.c. I can see that Jens is using the Roadshow includes for building the OS3 AmiSSL though.

@walkero-gr
Copy link
Author

walkero-gr commented Feb 28, 2020

Unfortunately the -D__NEW_TIMEVAL_DEFINITION_USED__ didn't solve anything.

I am using PosixLib. There is the clib/socket_protos.h. I tried using Roadshow as well, without PosixLib, but I get the following error

>#include <sys/types.h>
error 248 in line 6 of "https.c": file 'sys/types.h' not found

Where can I find that Makefile to have a look?

Futaura added a commit that referenced this issue Feb 28, 2020
@Futaura
Copy link
Collaborator

Futaura commented Feb 28, 2020

I was referring to https://github.com/jens-maus/amissl/blob/master/Makefile for AmiSSL, which also builds the https example with GCC for OS3/OS4, so there is not much to learn from that now that I have updated https://github.com/jens-maus/amissl/blob/master/test/https.c - I've removed some unnecessary includes which should help with compiling with VBCC, whilst still compiling ok with GCC.

There may be complications using PosixLib with AmiSSL. Ultimately, at some point you need to pass the low level socket to AmiSSL, maybe with something like SSL_set_fd( ssl, __init_bsdsocket(s) ) if that function is accessible publicly. Certainly, the https.c example code is written with Amiga native networking in mind. It could be adapted to work with PosixLib by replacing the appropriate bsdsocket.library calls and removing #include <proto/socket.h> (otherwise it clashes with the PosixLib sys/socket.h).

@walkero-gr
Copy link
Author

@Futaura Thank you very much for your help on that.
I checked the changed code under VBCC for AmigaOS4 dev environment I create and it compiles just fine.

Unfortunately, under m68k it still has issues. If I compile it without Posix Lib includes I get the following error

root@3d24d07ba300:/opt/code/m68k# vc +aos68k -c99 -lamiga -lauto -I/opt/sdk/NDK_3.9/Include/include_h -I/opt/sdk/Roadshow-SDK/netinclude -I/opt/sdk/AmiSSL/include https.c -o https -v

vc frontend for vbcc (c) in 1995-2016 by Volker Barthelmann
vbccm68k -quiet -hunkdebug "https.c" -o= "/tmp/filehff6hC.asm" -c99 -I/opt/sdk/NDK_3.9/Include/include_h -I/opt/sdk/Roadshow-SDK/netinclude -I/opt/sdk/AmiSSL/include  -O=1 -I$VBCC/targets/m68k-amigaos/include
># include <sys/types.h>
error 248 in line 28 of "openssl/buffer.h": file 'sys/types.h' not found
	included from file "/opt/sdk/AmiSSL/include/amissl/amissl.h":29
	included from file "/opt/sdk/AmiSSL/include/proto/amissl.h":31
	included from file "https.c":30
1 error found!
vbccm68k -quiet -hunkdebug "https.c" -o= "/tmp/filehff6hC.asm" -c99 -I/opt/sdk/NDK_3.9/Include/include_h -I/opt/sdk/Roadshow-SDK/netinclude -I/opt/sdk/AmiSSL/include  -O=1 -I$VBCC/targets/m68k-amigaos/include failed

with Posix lib includes

root@3d24d07ba300:/opt/code/m68k# vc +aos68k -c99 -lamiga -lauto -I/opt/sdk/NDK_3.9/Include/include_h -I/opt/sdk/Roadshow-SDK/netinclude -I/opt/sdk/PosixLib/include -I/opt/sdk/AmiSSL/include https.c -o https -v

vc frontend for vbcc (c) in 1995-2016 by Volker Barthelmann
vbccm68k -quiet -hunkdebug "https.c" -o= "/tmp/fileHTkKlZ.asm" -c99 -I/opt/sdk/NDK_3.9/Include/include_h -I/opt/sdk/Roadshow-SDK/netinclude -I/opt/sdk/PosixLib/include -I/opt/sdk/AmiSSL/include  -O=1 -I$VBCC/targets/m68k-amigaos/include
>   #include <inline/bsdsocket_protos.h>
error 248 in line 80 of "proto/bsdsocket.h": file 'inline/bsdsocket_protos.h' not found
	included from file "/opt/sdk/Roadshow-SDK/netinclude/proto/socket.h":18
	included from file "https.c":32
1 error found!
vbccm68k -quiet -hunkdebug "https.c" -o= "/tmp/fileHTkKlZ.asm" -c99 -I/opt/sdk/NDK_3.9/Include/include_h -I/opt/sdk/Roadshow-SDK/netinclude -I/opt/sdk/PosixLib/include -I/opt/sdk/AmiSSL/include  -O=1 -I$VBCC/targets/m68k-amigaos/include failed

The dev environment I am building it is based on docker, and can be found at
https://github.com/walkero-gr/docker4AmigaVBCC

@Futaura
Copy link
Collaborator

Futaura commented Mar 25, 2020

Apologies for the delayed reply - things have been going wrong elsewhere, so haven't had time to get back to AmiSSL until now...

As I eluded too, I think making the https.c example compile with PosixLib is out of the question, as that example code is intentionally Amiga-centric. But, in your own code, I think you should be able to use PosixLib without a problem as long as it provides as way to get the real AmigaOS native socket value so that it can be passed to SSL_set_fd() which expects the raw bsdsocket.library socket, not PosixLib's wrapper.

To compile the example on 68k, you will need to install some other sys/types.h file and use that - I've forgotten what I used on my system, as I have various copies of that file lying around.

@stevelord
Copy link

Has anyone else managed to resolve this? I've checked out @walkero-gr's code after seeing his AmiWest tutorial but I'm having the same problems. I apologise if this isn't the right place and I should open up an issue with him, but I wanted to see if any work's been done here or if there's another AmiSSL client example that could compile on m68k?

Futaura added a commit that referenced this issue Feb 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants