v15 on macOS - fail to compile

Support and general discussion.
Post Reply
startmenu
Posts: 104
Joined: Sat 29 Nov, 2014 7:39 am

v15 on macOS - fail to compile

Post 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
TonyM
Posts: 20
Joined: Fri 15 Jul, 2016 8:11 pm

Re: v15 on macOS - fail to compile

Post 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
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: v15 on macOS - fail to compile

Post 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.
TonyM
Posts: 20
Joined: Fri 15 Jul, 2016 8:11 pm

Re: v15 on macOS - fail to compile

Post 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.
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: v15 on macOS - fail to compile

Post 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)
Vashpan
Posts: 2
Joined: Sun 20 May, 2018 9:26 pm

Re: v15 on macOS - fail to compile

Post 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?
Post Reply