Page 1 of 1

v15 on macOS - fail to compile

Posted: Thu 27 Jun, 2019 12:59 pm
by startmenu
I tried to compile PCem v15 on macOS 10.14. Though ./configure reported "checking for off64_t x86_64... no", it did generate an Makefile. And I saw these...

Code: Select all

esdi_at.c:110:35: error: unknown type name 'off64_t'; did you mean 'off_t'?
int esdi_get_sector(esdi_t *esdi, off64_t *addr)
                                  ^~~~~~~
                                  off_t
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types/_off_t.h:31:33: note: 
      'off_t' declared here
typedef __darwin_off_t          off_t;
                                ^
esdi_at.c:129:29: error: use of undeclared identifier 'off64_t'
                *addr = ((((off64_t) esdi->cylinder * heads) + esdi->head) *
                            ^
esdi_at.c:137:29: error: use of undeclared identifier 'off64_t'
                *addr = ((((off64_t) esdi->cylinder * heads) + esdi->head) *
                            ^
esdi_at.c:144:29: error: use of undeclared identifier 'off64_t'
                *addr = ((((off64_t) c * drive->hdd_file.hpc) + h) *
                            ^
esdi_at.c:420:9: error: unknown type name 'off64_t'; did you mean 'off_t'?
        off64_t addr;
        ^~~~~~~
        off_t
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types/_off_t.h:31:33: note: 
      'off_t' declared here
typedef __darwin_off_t          off_t;
                                ^
5 errors generated.
make[1]: *** [pcem-esdi_at.o] Error 1
make: *** [all-recursive] Error 1
it seems that Clang doesn't understand off64_t

Re: v15 on macOS - fail to compile

Posted: Fri 09 Aug, 2019 3:19 pm
by TonyM
Did you ever find a solution to this? I'm running into the same issue on OS X 10.12.6

esdi_at.c:110:35: error: unknown type name 'off64_t'; did you mean 'off_t'?
int esdi_get_sector(esdi_t *esdi, off64_t *addr)
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:30:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
esdi_at.c:129:29: error: use of undeclared identifier 'off64_t'
*addr = ((((off64_t) esdi->cylinder * heads) + esdi->head) *
^
esdi_at.c:137:29: error: use of undeclared identifier 'off64_t'
*addr = ((((off64_t) esdi->cylinder * heads) + esdi->head) *
^
esdi_at.c:144:29: error: use of undeclared identifier 'off64_t'
*addr = ((((off64_t) c * drive->hdd_file.hpc) + h) *
^
esdi_at.c:420:9: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t addr;
^~~~~~~
off_t
/usr/include/sys/_types/_off_t.h:30:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
5 errors generated.
make[1]: *** [pcem-esdi_at.o] Error 1
make: *** [all-recursive] Error 1

Re: v15 on macOS - fail to compile

Posted: Mon 12 Aug, 2019 6:15 am
by ruben_balea
In OS X off_t is already 64 bits so edit esdi_at.c and change the code from:

Code: Select all

#include <sys/types.h>

#include "ibm.h"
to:

Code: Select all

#include <sys/types.h>
#define off64_t off_t
#include "ibm.h"
or alternatively to:

Code: Select all

#include <sys/types.h>
typedef off_t off64_t;
#include "ibm.h"
...and try to compile again. I'm not sure which way is more appropriate.

Re: v15 on macOS - fail to compile

Posted: Mon 12 Aug, 2019 2:35 pm
by TonyM
ruben_balea wrote:
Mon 12 Aug, 2019 6:15 am
In OS X off_t is already 64 bits so edit esdi_at.c and change the code from:

Code: Select all

#include <sys/types.h>

#include "ibm.h"
to:

Code: Select all

#include <sys/types.h>
#define off64_t off_t
#include "ibm.h"
or alternatively to:

Code: Select all

#include <sys/types.h>
typedef off_t off64_t;
#include "ibm.h"
...and try to compile again. I'm not sure which way is more appropriate.
Thank you! That worked. I also had to add that line to the following four files:

Code: Select all

hdd_file.c
ide.c
mfm_at.c
mfm_xebec.c
but once I did it compiled fine.

Re: v15 on macOS - fail to compile

Posted: Mon 12 Aug, 2019 4:14 pm
by ruben_balea
I'm glad it helped you!
If that concerns several files it can be easier and faster to edit the Makefile instead, I noted that the provided Makefile.osx64-wx-sdl2 already has the switch -Doff64_t=__off64_t in CFLAGS variable:

Code: Select all

CFLAGS = -D__unix=1 -DPCEM_RENDER_WITH_TIMER -DPCEM_RENDER_TIMER_LOOP -Dfopen64=fopen -Dfseeko64=fseeko -Dftello64=ftello -Doff64_t=off_t -O3 -fomit-frame-pointer -msse2 -m64 $(shell wx-config --cxxflags) $(shell sdl2-config --cflags) -I/usr/local/opt/openal-soft/include -I/usr/local/include
Perhaps your autogenerated /src/Makefile is missing that option for whatever reason, edit /src/Makefile and find the CFLAGS = variable and add the switch -Doff64_t=__off64_t (separate it with a space from anything already present in that line)

Re: v15 on macOS - fail to compile

Posted: Sun 15 Sep, 2019 3:06 pm
by Vashpan
If anyone is having crashes related to setting window title (it can't be done outside of main thread) - then it's enough to just comment out body of

Code: Select all

set_window_title
in

Code: Select all

wx-sdl2.c
Anyway, it would be really nice to have a proper & official macOS version of PCem.

Not much is needed, really:
- make a macOS-style application bundle
- config files, nvram & roms should be stored in "Application Data" preferrably (home folder is also "okay" but this one is better and preferred)
- iron out some minor bugs (like crash on stopping emulation) related to macOS
- ideally: move menu to macOS menu bar (although not necessarily if that would complicate code for other platforms)

I'm strongly thinking about taking care of that job, but I don't know if Sarah would be interested in potentially merging it to mainline one day?