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

Cannot build on Ubuntu 20 with instructions on repository. #19

Open
TrashRaccoonSnuffy opened this issue Sep 2, 2023 · 8 comments
Open
Assignees
Labels
trying-to-reproduce-the-issue In the process of reproducing the issue

Comments

@TrashRaccoonSnuffy
Copy link
Collaborator

TrashRaccoonSnuffy commented Sep 2, 2023

I am running a 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz (lscpu says it's x86_64), and running make seems to give the following results:
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libz.so when searching for -lz /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libz.a when searching for -lz /usr/bin/ld: cannot find -lz: No such file or directory /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libz.so when searching for -lz /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libX11.so when searching for -lX11 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libX11.a when searching for -lX11 /usr/bin/ld: cannot find -lX11: No such file or directory /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libX11.so when searching for -lX11 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL.so when searching for -lSDL /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL.a when searching for -lSDL /usr/bin/ld: cannot find -lSDL: No such file or directory /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL.so when searching for -lSDL /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpng16.so when searching for -lpng16 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpng16.a when searching for -lpng16 /usr/bin/ld: cannot find -lpng16: No such file or directory /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpng16.so when searching for -lpng16 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libz.so when searching for -lz /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libz.a when searching for -lz /usr/bin/ld: cannot find -lz: No such file or directory /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libz.so when searching for -lz /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libGL.so when searching for -lGL /usr/bin/ld: cannot find -lGL: No such file or directory /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libGL.so when searching for -lGL

I saw issue #15 and I thought it might have been related, are the libraries necessary still i386?

I actually managed to get way further in compilation by removing -m32 from the cflags, the
ifeq ($(wildcard /usr/lib/i386-linux-gnu/.),)
line in the Makefile and changing the flags inside to
CFLAGS += -I/usr/include/x86_64-linux-gnu -I /usr/include/X11 CXXFLAGS += -I/usr/include/x86_64-linux-gnu -I /usr/include/X11 LDFLAGS = -Wl,--as-needed -no-pie -Wl,--gc-sections -lz -lSDL-1.2 -lpng16 -lX11

and now the errors are only
/usr/bin/ld: cannot find -lSDL-1.2: No such file or directory /usr/bin/ld: skipping incompatible /usr/lib32/libm.so when searching for -lm /usr/bin/ld: skipping incompatible /usr/lib32/libm.a when searching for -lm /usr/bin/ld: skipping incompatible /usr/lib32/libm.so when searching for -lm /usr/bin/ld: skipping incompatible /usr/lib32/libm.a when searching for -lm

The libm issue seems pretty easy to fix, but I'm not sure about lsdl2 or if removing -m32 is safe at all.

@xyproto
Copy link
Owner

xyproto commented Sep 2, 2023

Thanks for reporting.

Did you try these instructions?

https://github.com/xyproto/zsnes#debian-and-ubuntu

@xyproto xyproto added the question Further information is requested label Sep 2, 2023
@xyproto xyproto closed this as completed Sep 2, 2023
@TrashRaccoonSnuffy
Copy link
Collaborator Author

TrashRaccoonSnuffy commented Sep 2, 2023

These are the exact instructions I tried. It appears to be the same issue as #15 , where the i386 libraries cannot be found and it's trying to look in x86-64 for them. I could probably try this in a 32-bit machine instead and see how that goes, but I'm experimenting to see if I can get it to compile either way.

Update: libsdl1.2-compat-dev:i386 appears to be the only missing package, and that can't be installed directly via sudo apt install libsdl1.2-compat-dev:i386 - will have to look into that.

@xyproto xyproto reopened this Sep 2, 2023
@TrashRaccoonSnuffy
Copy link
Collaborator Author

TrashRaccoonSnuffy commented Sep 2, 2023

I've found a way to get it to fully compile without errors on my current fork but it requires a pretty hacky method of manually downloading the dependencies and turning off a few things in the makefile. TrashRaccoonSnuffy@774afa2

Running the program leads to this though:
*** buffer overflow detected ***: terminated

So I'm probably missing something else now, or running the incorrect tools.

@xyproto
Copy link
Owner

xyproto commented Sep 2, 2023

Thanks for adding more information!

Some problems may (possibly, maybe) be with SDL1, but be solved by using sdl2-compat.

Also, the early parts of the Makefile seems to require a 64-bit enviroment, while the rest seems to require a 32-bit environment, which is odd and on my TODO list in the back of my head for things I want to fix. This seems to be a Debian/Ubuntu specific issue, though.

I will give it a go on Ubuntu 20 as well.

@xyproto xyproto self-assigned this Sep 2, 2023
@xyproto xyproto added trying-to-reproduce-the-issue In the process of reproducing the issue bug Something isn't working and removed question Further information is requested bug Something isn't working labels Sep 2, 2023
@TrashRaccoonSnuffy
Copy link
Collaborator Author

TrashRaccoonSnuffy commented Sep 8, 2023

This crash occurs in clearvidsound() in initc.c , specifically at

memset(&echoon0, 0, PHdspsave2);

Possibly related to #5

There is a patch here https://github.com/rpmfusion/zsnes/blob/master/zsnes-1.51-FORTIFY_SOURCE.patch that I will try and I will report back if it does anything.

Program received signal SIGABRT, Aborted.
0xf7fc4579 in __kernel_vsyscall ()
(gdb) bt 10
#0  0xf7fc4579 in __kernel_vsyscall ()
#1  0xf7a88a37 in ?? () from /lib/i386-linux-gnu/libc.so.6
#2  0xf7a37685 in raise () from /lib/i386-linux-gnu/libc.so.6
#3  0xf7a203ac in abort () from /lib/i386-linux-gnu/libc.so.6
#4  0xf7a7b3bc in ?? () from /lib/i386-linux-gnu/libc.so.6
#5  0xf7b3397c in __fortify_fail () from /lib/i386-linux-gnu/libc.so.6
#6  0xf7b321af in __chk_fail () from /lib/i386-linux-gnu/libc.so.6
#7  0x082c15d1 in memset (__len=<optimized out>, __ch=0, __dest=<optimized out>) at /usr/include/bits/string_fortified.h:59
#8  clearvidsound () at initc.c:1376
#9  0x082c379a in init65816 () at initc.c:2485
(More stack frames follow...)

@TrashRaccoonSnuffy
Copy link
Collaborator Author

TrashRaccoonSnuffy commented Sep 8, 2023

image
Confirmed working after TrashRaccoonSnuffy@f77ec1a

Games do not boot at all and lead to a buffer overflow error however. More patches will have to be applied to get it fully working. There also needs to be an easier way to set up the packages for i386, since atleast on ubuntu attempting to install libc i386 wants to delete the x86_64 version and that can't be worked with.

Update: Turning off _FORTIY_SOURCE seems to fix the issues, but that probably isn't the safest thing to do.

@xyproto
Copy link
Owner

xyproto commented Sep 8, 2023

Thanks for the additional info and for your contributions.

I'll test and patch this when I can. (It's been a busy week). 🙂

@TrashRaccoonSnuffy
Copy link
Collaborator Author

TrashRaccoonSnuffy commented Sep 8, 2023

Thanks. I've decided to make a separate branch to put all the changes necessary to compile on Ubuntu. It's already working with 5265da3 and the other step I described above with manually downloading the i386 packages and putting their usr folder in the root.

I already put a fix on the main repository for one of the buffer overflow issues, but on Ubuntu it's necessary to disable FORTIFY_SOURCE to get it to fully work otherwise the emulator will crash when loading a new game after one is already loaded. This is probably due to a GCC bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
trying-to-reproduce-the-issue In the process of reproducing the issue
Projects
None yet
Development

No branches or pull requests

2 participants