Page 1 of 2

My experience building higan and bsnes-plus on Ubuntu

Posted: Sat Feb 06, 2016 10:09 am
by tepples
In another post, it was suggested that I try building bsnes performance to see how well it runs on the Atom N450 in my laptop. The first momentary problem came when I tried to download higan into a new folder.

Code: Select all

$ wget http://download.byuu.org/higan_v097-source.7z
--2016-02-06 10:46:20--  http://download.byuu.org/higan_v097-source.7z
Resolving download.byuu.org (download.byuu.org)... 2001:19f0:4009:344::, 173.199.117.126
Connecting to download.byuu.org (download.byuu.org)|2001:19f0:4009:344::|:80... failed: Connection timed out.
Connecting to download.byuu.org (download.byuu.org)|173.199.117.126|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1034204 (1010K) [application/x-7z-compressed]
Saving to: ‘higan_v097-source.7z’

100%[======================================>] 1,034,204   1005KB/s   in 1.0s   

2016-02-06 10:48:29 (1005 KB/s) - ‘higan_v097-source.7z’ saved [1034204/1034204]
Despite a 10/10 in my PC's IPv6 readiness, it had to drop back to IPv4.

I start by ensuring some dependencies:

Code: Select all

$ sudo sh -c "apt-get update && apt-get upgrade"
$ sudo apt-get install build-essential libgtk2.0-dev libgtksourceview2.0-dev p7zip-full
So here goes nothing:

Code: Select all

$ 7za x higan_v097-source.7z
$ cd higan_v097-source
$ ls | grep -iE "make|readme|install"
Somehow README and INSTALL files were left out. I'll have to do it the hard way.

Code: Select all

$ ls
higan  hiro  icarus  libco  nall  ruby
$ cd higan
$ ls | grep -iE "make|readme|install"
GNUmakefile
$ make
g++-4.9 -x c++ -std=c++14 -fwrapv -I. -I.. -O3 -march=native -fopenmp -DPROFILE_ACCURACY -c target-tomoko/tomoko.cpp -o obj/ui-tomoko.o
make: g++-4.9: Command not found
make: *** [obj/ui-tomoko.o] Error 127
pino@pino-laptop:~/develop/bullcrap/higan_v097-source/higan$ g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Ubuntu 14.04 LTS updates packages for bug fixes, not so much for new features. Let's see if it'll build with earlier GCC:

Code: Select all

$ less GNUmakefile
$ grep g++-4.9 ../nall/GNUmakefile
    compiler := g++-4.9
$ export compiler=g++
$ make
g++ -x c++ -std=c++14 -fwrapv -I. -I.. -O3 -march=native -fopenmp -DPROFILE_ACCURACY -c target-tomoko/tomoko.cpp -o obj/ui-tomoko.o
g++: error: unrecognized command line option ‘-std=c++14’
make: *** [obj/ui-tomoko.o] Error 1
$ unset compiler
$ firefox https://www.google.com/search?q=ubuntu+14.04+c%2B%2B14
The first two results from a Google search for ubuntu 14.04 c++14 were this question and a question that hasn't yet been marked as a duplicate. Answers to both offered essentially the same solution, involving the Ubuntu Toolchain Test Builds PPA:

Code: Select all

$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install g++-4.9
So let's try that again:

Code: Select all

$ make
g++-4.9 -x c++ -std=c++14 -fwrapv -I. -I.. -O3 -march=native -fopenmp -DPROFILE_ACCURACY -c target-tomoko/tomoko.cpp -o obj/ui-tomoko.o
g++-4.9 -x c++ -std=c++14 -fwrapv -I. -I.. -O3 -march=native -fopenmp -DPROFILE_ACCURACY -c target-tomoko/program/program.cpp -o obj/ui-program.o
Is the profile a compile-time thing? Again, no README file.

And would there be a cache or RAM benefit in a compile-time option to disable coprocessors that I know I'll never use in my projects?

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 10:25 am
by Near
The lack of documentation has long been a sore point. Not sure what to tell you, I simply don't want to maintain it, and nobody's going to do it for me, so it's not going to get done.

Code: Select all

cd ~/Desktop
mkdir higan_v097
cd higan_v097
wget http://download.byuu.org/higan_v097-source.7z
tar -xJf higan_v097-source.7z
cd higan
sudo apt-get build-dep higan
make profile=performance
make install
cd ../icarus
make
make install
Don't skimp on any of that. Build higan and icarus, install both.

Once you run it, spend some time configuring options. Bind your input settings, set your controller port options once you load a game, change your driver settings if things aren't working and restart, etc. I already know the setup isn't nice and automagical out of the box.

> Despite a 10/10 in my PC's IPv6 readiness, it had to drop back to IPv4.

Well it used to work. I switched ISPs, my new one is 300/20mpbs instead of 50/5mbps, and is 30% cheaper. But it lacks IPv6. Apparently my support for it magically broke even though I didn't touch anything, because technology loves doing shit like that.

I guess I'll delete the AAAA record then. Maybe in another ten years Wide Open West will join the 20th century with IPv6 support.

> Somehow README and INSTALL files were left out. I'll have to do it the hard way.

higan isn't a Linux application. It's a multi-platform application. I don't put files with no extensions unless absolutely required (hi, GNUmakefile). Also, see my comment about documentation. This isn't likely to happen. I'm only one person writing an emulator for five systems, and a UI toolkit for four major platforms, and a hardware abstraction layer for three major operating systems, and a standard library for C++, and everything else non-higan that I do.

> Let's see if it'll build with earlier GCC:

I wouldn't have made 4.9 a requirement if 4.8 worked. 4.8 has too many bugs like expecting "override/final" in the wrong place. Once the LTS runs out and everyone has gcc >= 4.9, I'll revert to the compiler defaulting to just g++

> And would there be a cache or RAM benefit in a compile-time option to disable coprocessors that I know I'll never use in my projects?

Very unlikely, and I don't offer any command-line options for this, so you'd be doing it yourself.

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 11:00 am
by tepples
byuu wrote:

Code: Select all

cd higan
sudo apt-get build-dep higan
What does apt-get build-dep do?

Code: Select all

make profile=performance
make install
cd ../icarus
make
make install
Don't skimp on any of that. Build higan and icarus, install both.
Will do. I'll see how well it works tonight after I get back from doing laundry.
Once you run it, spend some time configuring options. Bind your input settings, set your controller port options once you load a game, change your driver settings if things aren't working and restart, etc.
Yes, I'm familiar with that dance after having used plenty of emulators. In older Wine, for example, I had to disable sound to get FCEUX to work, and I often still have to reduce frequency or increase buffer length.
> Somehow README and INSTALL files were left out. I'll have to do it the hard way.

higan isn't a Linux application. It's a multi-platform application. I don't put files with no extensions unless absolutely required (hi, GNUmakefile).
Hence my use of filenames such as README.txt and CHANGES.txt in my own projects. Though lately, I've been writing a lot of these files in Markdown (e.g. README.md), which a Markdown reader (such as GitHub or ReText) can read natively and a plain UTF-8 text file reader (such as Notepad or a web browser) can read with slight degradation.

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 11:52 am
by Sik
But .md is usually not tied to any program on Windows so it's just as good as extensionless (the issue being that in this case it's considered a problem, otherwise it wouldn't matter). Not like standard filenames are useful, it seems every other project uses something different anyway.

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 12:59 pm
by Near
.md at least can be associated with a file, although I'd probably just go with .txt anyway. The point of markdown is that it's supposed to be readable as plain-text, so why not?

Extensionless files, though ... such a pain on Windows. I use kaijuu so that I can open my Makefiles just by double-clicking them.

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 1:56 pm
by tepples

Code: Select all

target-tomoko/GNUmakefile:81: *** "make install should not be run as root".  Stop.
I found this unusual. Most other programs I've built from source default to installation for all users, usually under /usr/local needing a special switch to install into a home directory.

Code: Select all

$ higan
The program 'higan' is currently not installed. You can install it by typing:
sudo apt-get install higan
Is there a hierarchy standard specifying $HOME/.local/bin as a common place to put executables? A bit of searching reveals something about PEP 370 and a 2008 post to python-dev for ~/.local reflecting /usr/local.

Code: Select all

$ nano ~/.profile
$ source ~/.profile
$ higan
Under "Load ROM File..." I navigate to the ROM in question, I hear a short burst of sound from the SPC (as expected), and then

Code: Select all

Segmentation fault (core dumped)
$ 
How should I debug into this? Is there a way to compile or link a program such that it will automatically give a traceback? That was one of the things I liked about DJGPP back when I used that roughly half my life ago: segfaults produced a traceback.

I tried it another way:

Code: Select all

$ higan ~/path/to/lorom-template.sfc
This gave no video. I changed video from OpenGL to SDL and tried again, and it worked about as well as bsnes-classic does, choppily but only once. I carelessly forgot to write down the resulting FPS. When I tried to reopen it in order to write down the FPS:

Code: Select all

$ higan ~/path/to/lorom-template.sfc
Segmentation fault (core dumped)
And speaking of debugging, if I want to work around the lack of loki by using gdb to debug the game by debugging the emulator in which it runs, is there a good guide to that? The last time I asked, the answer was "that's not really something I'm interested in."
Sik wrote:But .md is usually not tied to any program on Windows
Nor is .cpp or .sfc for that matter. It's not like a game folder, which is associated with Windows Explorer by default (which is not what you want if you have higan installed). Nor is it like .py, which was problematic on Windows from Python 3.0 through 3.2 until 3.3 added the shebang line processor defined in PEP 397.
Sik wrote:so it's just as good as extensionless
The difference between folders and extensionless filenames on the one hand and files with an unknown extension on the other hand is that with the latter, File Explorer prompts the user to associate it to something. With extensionless filenames such as GNUmakefile, File Explorer asks every time with what app and doesn't allow associating a particular filename.
byuu wrote:I don't put files with no extensions unless absolutely required (hi, GNUmakefile).
The contents of GNUmakefile could be set to just include higan.mk or icarus.mk or whatever, with all build logic in the included file.

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 2:14 pm
by Sik
.cpp usually gets associated when you install an IDE or a text editor meant for programming, though. Meanwhile, readme.md would be something you want to be able to open immediately before having to do anything else (and I'm not sure that many people are aware that .md is a file extension for Markdown)

On the traceback: that's how Linux works. Run it through a debugging tool and it'll inevitably spew out the traceback (valgrind tends to be better than gdb at this, since the latter needs the stack to not be smashed and in my experience that's rarely the case...)

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 2:50 pm
by Near
> I found this unusual.

I don't like having to type my password every time I compile a new build. I think relying on admin privileges to install per-user software is kind of backwards. You'll find with my stuff that you have to deal with a lot of my "refuses to play by the rules" quirks >_>

> Is there a hierarchy standard specifying $HOME/.local/bin as a common place to put executables?

At least with Xfce, .local/applications holds .desktop files that show up in the menus, .local/share/icons works for pulling icons for the file browser, etc. I don't know how well it works elsewhere, but Xfce usually isn't the one to have the excess of features.

> How should I debug into this?

Code: Select all

gdb higan
r
<run the app until it crashes>
bt
> When I tried to reopen it in order to write down the FPS:

I am not at all surprised that of ~10,000 users, only you are completely unable to get the program to function. Thanks for trying it, at least.

> if I want to work around the lack of loki by using gdb to debug the game by debugging the emulator in which it runs, is there a good guide to that? The last time I asked, the answer was "that's not really something I'm interested in."

Still the same answer. I'm probably going to start on loki again very soon, now that all the UI stuff is done. Working on a few side projects first.

But, I'm sure loki won't run at all for you, so I'd recommend against getting your hopes up for that.

If you could hire any random person on the street with a normal computer, I'd recommend to ask them to run bsnes-plus for you. That thing has a really spiffy-looking debugger, even if it is an ancient version of bsnes.

> With extensionless filenames such as GNUmakefile, File Explorer asks every time with what app and doesn't allow associating a particular filename.

Even worse is it won't even remember things you've picked. So every time, I have to click "browse", then navigate to where I installed Notepad2, since it's 2016 and Windows Notepad still can't support files without carriage returns.

> The contents of GNUmakefile could be set to just include higan.mak or icarus.mak or whatever, with all build logic in the included file.

I'm much too stubborn for pragmatism :)

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 3:12 pm
by tepples
byuu wrote:> How should I debug into this?

Code: Select all

gdb higan
r
<run the app until it crashes>
bt
Thanks. I got it to work once in gdb: 35 fps. That one time, I was able to configure it to use a key mapping resembling what appears to be the de facto standard for emulators, and I could move the little guy back and forth.

Control Pad: Arrow keys
Select, Start: Tab, Enter
LXRYBA: ASDZXC

And again, the second time it failed.

Code: Select all

(gdb) bt
#0  0x082f99bb in SuperFamicom::PPU::render_scanline() [clone .part.14] ()
#1  0x083009af in SuperFamicom::PPU::enter() ()
#2  0x08300ab0 in SuperFamicom::PPU::Enter() ()
#3  0x081e34e0 in ?? ()
Where do I take it from here? Should we jump on EFnet IRC this evening so we can do this in real time?
byuu wrote:If you could hire any random person on the street with a normal computer, I'd recommend to ask them to run bsnes-plus for you. That thing has a really spiffy-looking debugger, even if it is an ancient version of bsnes.
I've got a "normal computer", but it's a desktop. Before I figured out how to run FCEUX in Wine, I had to wait until I got home to do any debugging. I'll have to think about how to proceed.
Even worse is it won't even remember things you've picked. So every time, I have to click "browse", then navigate to where I installed Notepad2, since it's 2016 and Windows Notepad still can't support files without carriage returns.
On the Windows PC at work, I use Notepad++, which puts "Edit in Notepad++" in all files' context menu. Just make sure that if Windows is 64-bit, you install 64-bit Notepad++ and 64-bit 7-Zip, as File Explorer doesn't support cross-arch shell extensions.

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 3:22 pm
by Revenant
byuu wrote:>If you could hire any random person on the street with a normal computer, I'd recommend to ask them to run bsnes-plus for you. That thing has a really spiffy-looking debugger, even if it is an ancient version of bsnes.
I'm a bit curious as to how bsnes-plus builds (and runs) on Linux as well. I haven't had the opportunity to try it myself (too lazy to set up a remotely up-to-date VM), but hopefully the non-Windows build instructions other people have contributed are able to get the job done.

Re: My experience building higan on Ubuntu

Posted: Sat Feb 06, 2016 6:25 pm
by lidnariq
I didn't have any problems at all building/using bsnes-plus on linux. It does help that it ships with linux-ready makefiles.

If I were trying for something esoteric, I might find it annoying, but, well, all the commercial UNIX vendors are effectively gone.

Re: My experience building higan on Ubuntu

Posted: Sun Feb 07, 2016 6:36 am
by Near
> Thanks. I got it to work once in gdb: 35 fps.

Fascinating that my N450 hit 80fps and yours hits 35fps.

I would show you the screenshot proof, but unfortunately imageshack deletes old images, and my Wind died a long time ago.

Here's the best I can do now.
bsnes at 151fps on a Celeron @ 1.4GHz
Also demonstrates this profile runs without crashing.

> (gdb) bt
> #0 0x082f99bb in SuperFamicom::PPU::render_scanline() [clone .part.14] ()
> Where do I take it from here? Should we jump on EFnet IRC this evening so we can do this in real time?

I'm sorry, but I really don't have the bandwidth to chase down a phantom bug that only happens for you. In the middle of several large projects. But if you manage to find a bug in PPU::render_scanline(), I'll send you $20. (hint: it's a ten-line function that only contains a boolean test and ten other function calls.)

> On the Windows PC at work, I use Notepad++, which puts "Edit in Notepad++" in all files' context menu.

That might be a smarter way to do it than installing kaijuu everywhere. I tend to like Notepad2 more, even though it lacks tab support. I guess I can always add Notepad2 to my context menu manually via HKCR.

Re: My experience building higan on Ubuntu

Posted: Sun Feb 07, 2016 1:12 pm
by tepples
Bernie Sanders Needs Everyone's Support, so I went for it:

Code: Select all

$ git clone https://github.com/devinacker/bsnes-plus.git
$ cd bsnes-plus/bsnes
$ sudo apt-get install libqt4-dev libqt4-dev-bin libxv-dev libsdl1.2-dev libao-dev libopenal-dev g++
$ nice make
$ out/bsnes
It built without a hitch and ran at 25 fps once I switched from the default QtRaster to SDL. (I run all tests with SDL to compare apples to apples.)

Re: My experience building higan on Ubuntu

Posted: Sun Apr 09, 2017 1:18 pm
by tepples
After upgrading from Xubuntu 14.04 (32-bit) to Xubuntu 16.04 (64-bit), the frame rate of lorom-template in bsnes-plus improved to 30 fps.

Re: My experience building higan and bsnes-plus on Ubuntu

Posted: Sun Nov 18, 2018 2:10 pm
by tepples
Tried bsnes-plus again in Xubuntu 18.04 on a Dell Inspiron 11 3168 with a Pentium N3710 CPU. After switching output to SDL and restarting bsnes, I got 60 fps with a few hiccups. Intel's come a long way with Pentium N (the successor to Atom). It worked well enough for me to install it to my user account:

Code: Select all

make install prefix="$HOME/.local"