jdh-8
jdh-8 copied to clipboard
Compiler errors, no executeable on windows
I cloned the repo today and started compiling on windows. i use MSYS2-MinGW64 and followed the instructions in the readme. but i get some syntax errors. The full log
mkdir -p bin
gcc -o emu/libemu.o -c emu/libemu.c -std=c11 -O0 -g -Wall -Wextra -Wpedantic -Wstrict-aliasing -IC:/Users/Robin/AppData/Local/MSYS2/mingw64/include/ -IC:/Users/Robin/AppData/Local/MSYS2/usr/lib/ -v -Wno-pointer-arith -Wno-unused-parameter
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-pc-msys
Configured with: /c/_/S/gcc/src/gcc-10.2.0/configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable-__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)
COLLECT_GCC_OPTIONS='-o' 'emu/libemu.o' '-c' '-std=c11' '-O0' '-g' '-Wall' '-Wextra' '-Wpedantic' '-Wstrict-aliasing' '-I' 'C:/Users/Robin/AppData/Local/MSYS2/mingw64/include/' '-I' 'C:/Users/Robin/AppData/Local/MSYS2/usr/lib/' '-v' '-Wno-pointer-arith' '-Wno-unused-parameter' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/cc1.exe -quiet -v -I C:/Users/Robin/AppData/Local/MSYS2/mingw64/include/ -I C:/Users/Robin/AppData/Local/MSYS2/usr/lib/ -idirafter /usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../lib/../include/w32api -idirafter /usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/lib/../lib/../../include/w32api emu/libemu.c -quiet -dumpbase libemu.c -mtune=generic -march=x86-64 -auxbase-strip emu/libemu.o -g -O0 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wno-pointer-arith -Wno-unused-parameter -std=c11 -version -o /tmp/ccTKThYJ.s
GNU C11 (GCC) version 10.2.0 (x86_64-pc-msys)
compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version 4.1.0, MPC version 1.1.0, isl version isl-0.22.1-GMP
warning: GMP header version 6.2.0 differs from library version 6.2.1.
warning: MPC header version 1.1.0 differs from library version 1.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/include"
ignoring duplicate directory "/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/lib/../lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
C:/Users/Robin/AppData/Local/MSYS2/mingw64/include/
C:/Users/Robin/AppData/Local/MSYS2/usr/lib/
/usr/lib/gcc/x86_64-pc-msys/10.2.0/include
/usr/lib/gcc/x86_64-pc-msys/10.2.0/include-fixed
/usr/include
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../lib/../include/w32api
End of search list.
GNU C11 (GCC) version 10.2.0 (x86_64-pc-msys)
compiled by GNU C version 10.2.0, GMP version 6.2.0, MPFR version 4.1.0, MPC version 1.1.0, isl version isl-0.22.1-GMP
warning: GMP header version 6.2.0 differs from library version 6.2.1.
warning: MPC header version 1.1.0 differs from library version 1.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5dc831ba8ba50cc9f8b7e3207bc4f700
In file included from emu/../common/util.h:6,
from emu/emu.h:4,
from emu/libemu.c:3:
emu/../common/util.h: In function ‘strlstrip’:
emu/../common/util.h:88:20: warning: array subscript has type ‘char’ [-Wchar-subscripts]
88 | while (isspace(*str)) memmove(str, str + 1, --len);
| ^~~~
emu/../common/util.h: In function ‘strrstrip’:
emu/../common/util.h:95:23: warning: array subscript has type ‘char’ [-Wchar-subscripts]
95 | while (isspace(str[len - 1])) str[--len] = '\0';
| ~~~^~~~~~~~~
In file included from emu/emu.h:4,
from emu/libemu.c:3:
emu/../common/util.h: In function ‘strtou32’:
emu/../common/util.h:134:22: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
134 | } else if (r >= (_min) && r <= (_max)) { \
| ^~
emu/../common/util.h:142:1: note: in expansion of macro ‘_DECL_STRTOX’
142 | _DECL_STRTOX(u, u32, u32, 0, UINT_MAX)
| ^~~~~~~~~~~~
emu/../common/util.h: In function ‘strtou16’:
emu/../common/util.h:134:22: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
134 | } else if (r >= (_min) && r <= (_max)) { \
| ^~
emu/../common/util.h:144:1: note: in expansion of macro ‘_DECL_STRTOX’
144 | _DECL_STRTOX(u, u16, u16, 0, USHRT_MAX)
| ^~~~~~~~~~~~
emu/../common/util.h: In function ‘strtou8’:
emu/../common/util.h:134:22: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
134 | } else if (r >= (_min) && r <= (_max)) { \
| ^~
emu/../common/util.h:146:1: note: in expansion of macro ‘_DECL_STRTOX’
146 | _DECL_STRTOX(u, u8, u8, 0, INT_MAX)
| ^~~~~~~~~~~~
emu/libemu.c: In function ‘simulate’:
emu/libemu.c:10:21: error: ‘_CLOCK_MONOTONIC_RAW’ undeclared (first use in this function); did you mean ‘CLOCK_MONOTONIC’?
10 | #define MONO_CLOCK _CLOCK_MONOTONIC_RAW
| ^~~~~~~~~~~~~~~~~~~~
emu/../common/util.h:175:31: note: in definition of macro ‘assert’
175 | #define assert(_e) ( _assert((_e), false, __FILE__, __LINE__))
| ^~
emu/libemu.c:15:31: note: in expansion of macro ‘MONO_CLOCK’
15 | assert(!clock_gettime(MONO_CLOCK, &ts)); \
| ^~~~~~~~~~
emu/libemu.c:45:17: note: in expansion of macro ‘NOW’
45 | u64 start = NOW(),
| ^~~
emu/libemu.c:10:21: note: each undeclared identifier is reported only once for each function it appears in
10 | #define MONO_CLOCK _CLOCK_MONOTONIC_RAW
| ^~~~~~~~~~~~~~~~~~~~
emu/../common/util.h:175:31: note: in definition of macro ‘assert’
175 | #define assert(_e) ( _assert((_e), false, __FILE__, __LINE__))
| ^~
emu/libemu.c:15:31: note: in expansion of macro ‘MONO_CLOCK’
15 | assert(!clock_gettime(MONO_CLOCK, &ts)); \
| ^~~~~~~~~~
emu/libemu.c:45:17: note: in expansion of macro ‘NOW’
45 | u64 start = NOW(),
| ^~~
emu/libemu.c:26:43: warning: statement with no effect [-Wunused-value]
26 | ((rem.tv_sec * NS_PER_SECOND) + rem.tv_nsec); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
emu/libemu.c:86:9: note: in expansion of macro ‘SLEEP’
86 | SLEEP(sleep_time);
| ^~~~~
emu/libemu.c:27:18: warning: statement with no effect [-Wunused-value]
27 | } else { 0; } \
| ^
emu/libemu.c:86:9: note: in expansion of macro ‘SLEEP’
86 | SLEEP(sleep_time);
| ^~~~~
emu/libemu.c: In function ‘pop16’:
emu/libemu.c:203:29: warning: operation on ‘state->special.<U43b0>.pc’ may be undefined [-Wsequence-point]
203 | (((u16) peek(state, ++state->special.pc)) << 0) |
| ^~~~~~~~~~~~~~~~~~~
emu/libemu.c: In function ‘step’:
emu/libemu.c:320:42: warning: operation on ‘state->special.<U43b0>.pc’ may be undefined [-Wsequence-point]
320 | (((u16) peek(state, state->special.pc++)) << 8))\
| ~~~~~~~~~~~~~~~~~^~
emu/libemu.c:329:51: note: in expansion of macro ‘IMM16’
329 | pc0 & 0x8 ? state->registers.hl : IMM16()
| ^~~~~
emu/libemu.c:320:42: warning: operation on ‘state->special.<U43b0>.pc’ may be undefined [-Wsequence-point]
320 | (((u16) peek(state, state->special.pc++)) << 8))\
| ~~~~~~~~~~~~~~~~~^~
emu/libemu.c:335:51: note: in expansion of macro ‘IMM16’
335 | pc0 & 0x8 ? state->registers.hl : IMM16(),
| ^~~~~
emu/libemu.c:319:41: warning: operation on ‘state->special.<U43b0>.pc’ may be undefined [-Wsequence-point]
319 | ((u16) peek(state, state->special.pc++)) | \
| ~~~~~~~~~~~~~~~~~^~
emu/libemu.c:346:18: note: in expansion of macro ‘IMM16’
346 | hl = IMM16();
| ^~~~~
emu/libemu.c:377:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
377 | r += !!(state->registers.f & (1 << F_CARRY));
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
emu/libemu.c:378:17: note: here
378 | case I_ADD:
| ^~~~
make: *** [Makefile:57: emu/libemu.o] Error 1
What should i do?
Remove the first _ in _CLOCK_MONOTONIC_RAW
in Libemu.c, line 10
now i getting this big error: https://pastebin.com/8FrU7HeF
C:/Users/Robin/Programme/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsdl2main
C:/Users/Robin/Programme/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsdl2
You're missing SDL2. I'm not sure how to fix this on Windows, but try checking out the SDL website or building on WSL.
iirc on MSYS2, there's SDL2 packages
i think i fixed it. but now i got a other error:
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: cannot find -lmingw32
ok searching a bit on google helps
but now i got an other error. i tryed a bit with include paths and libpaths but it didn't work.
gcc -o bin/emu -LC:/Users/Robin/AppData/Local/MSYS2/mingw64/lib -lmingw32 -lsdl2main -lsdl2 -lws2_32 emu/emu.o emu/kb.o emu/libemu.o emu/mod.o emu/screen.o
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: emu/emu.o: in function `main':
C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/emu.c:244: multiple definition of `main'; C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:17: first defined here
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Robin/AppData/Local/MSYS2/mingw64/lib/libsdl2main.a(SDL_windows_main.c.obj):SDL_windows_ma:(.text+0x15d): undefined reference to `SDL_main'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: emu/emu.o: in function `stop_simulation':
C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/emu.c:23: undefined reference to `poll'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: emu/emu.o: in function `command':
C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/emu.c:99: undefined reference to `strlcpy'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/emu.c:170: undefined reference to `fmemopen'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: emu/emu.o: in function `main':
C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/emu.c:287: undefined reference to `readline'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/emu.c:295: undefined reference to `add_history'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: emu/screen.o: in function `screen_destroy':
C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:35: undefined reference to `SDL_DestroyTexture'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:36: undefined reference to `SDL_DestroyRenderer'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:37: undefined reference to `SDL_DestroyWindow'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:38: undefined reference to `SDL_Quit'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: emu/screen.o: in function `screen_tick':
C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:55: undefined reference to `SDL_PollEvent'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: emu/screen.o: in function `fchild':
C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:96: undefined reference to `SDL_SetRenderDrawColor'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:97: undefined reference to `SDL_RenderClear'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:98: undefined reference to `SDL_UpdateTexture'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:99: undefined reference to `SDL_RenderCopy'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:104: undefined reference to `SDL_RenderPresent'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:105: undefined reference to `SDL_UpdateWindowSurface'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: emu/screen.o: in function `screen_init':
C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:123: undefined reference to `SDL_Init'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:125: undefined reference to `SDL_CreateWindow'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:132: undefined reference to `SDL_CreateRenderer'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/screen.c:136: undefined reference to `SDL_CreateTexture'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:63: emu] Error 1
Yes, you're missing both SDL (still, not sure why) and some of the POSIX functions (poll, strlcpy, readline). Try building under WSL.
i installed sdl 3 times.i installed it (sdl and sdl2) in msys2 2 times and one time in windows with path.
The problem is why i cant use wsl is, i cant install it because im not the pc admin
Try with the newest commit :-) make sure you make clean
first.
with the newest commit it gives me:
gcc -o bin/emu emu/emu.o emu/kb.o emu/libemu.o emu/mod.o emu/screen.o emu/win/mman.o emu/win/win.o -lsdl2main -lsdl2 -LC:/Users/Robin/AppData/Local/MSYS2/mingw64/lib/ -Lws2_32
emu/win/win.o: In function `poll':
C:\Users\Robin\AppData\Local\cygwin\home\Robin\projects\jdh-8\jdh-8-master/emu/win/win.c:59: undefined reference to `__imp_select'
C:\Users\Robin\AppData\Local\cygwin\home\Robin\projects\jdh-8\jdh-8-master/emu/win/win.c:64: undefined reference to `__WSAFDIsSet'
C:\Users\Robin\AppData\Local\cygwin\home\Robin\projects\jdh-8\jdh-8-master/emu/win/win.c:65: undefined reference to `__WSAFDIsSet'
C:\Users\Robin\AppData\Local\cygwin\home\Robin\projects\jdh-8\jdh-8-master/emu/win/win.c:66: undefined reference to `__WSAFDIsSet'
C:/Users/Robin/Programme/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
make: *** [emu] Fehler 1
when i look on this line i see:
#17 should fix that compilation problem (idk why it says there's conflicts, looks fine to me)
so after some tries i got:
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/win/win.c:37: undefined reference to `__WSAFDIsSet'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/win/win.c:38: undefined reference to `__WSAFDIsSet'
C:/Users/Robin/AppData/Local/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Robin\projects\jdh-8\jdh-8-master/emu/win/win.c:39: undefined reference to `__WSAFDIsSet'
collect2.exe: error: ld returned 1 exit status
The problem is why i cant use wsl is, i cant install it because im not the pc admin
Try using something like azure or google cloud servers.
That sounds good, but i need it for windows, not linux
now after a few tries today i made it complete. i needed just to rename builtin_macros.c in builtin_macros.h, add #pragma once
before code and need to include it in asm.h