Author Topic: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)  (Read 619 times)

Offline macksting

  • Newbie
  • *
  • Posts: 16
The last instructions of any sort for Linux talked about a need to copy the files into another folder; that was half a year ago, so presumably 0.7.1. Has anything changed in that regard?

I notice these are .cpp files. That means C++ as far as I can tell. To my knowledge this in turn means gcc, which I have. Past that, I can't really figure much out here. Could somebody give me a quick set of instructions how to build this in Linux?

For debugging purposes, would it help to run this in gdb? I used that to good effect in some Pioneer bug reports.

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 1925
    • LairWorks Entertainment
I'm not sure there is a quick set of instructions for building on Linux. I'm unfamiliar with the development environment on Linux but I know it does build on both Ubuntu and Arch linux.

There is a make file in the source tree -- so a 'make' command might be all you need to do. I don't know if it'll pull all of the dependencies you'll need in order to build OutpostHD. Hooman and lhark can provide additional details.

You may need to copy the asset files to a './lom' directory within your User directory -- again Hooman/lhark will need to confirm this though since none of the assets are really dynamic it ought to be able to load directly from the binary directory.

Sorry I can't be more help, I just am very unfamiliar with Linux and distributing software on it.
- Leeor
LairWorks Entertainment

Titanum UFO's

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4438
Yes, the project is written in C++. You can compile it on Linux with either gcc or clang.

You'll need to download and compile the NAS2D library first, which OutpostHD uses, then compile the OutpostHD project.
NAS2D
OutpostHD

You should be able to downloaded both projects to the same parent folder. The Makefile for OPHD references NAS2D in the LIBDIR variable in the Makefile.

There may be some changes coming up for this, if NAS2D is added as a Git Submodule. That would mean a few changes to the folder layout and the Makefile.

Compile the NAS2D project first, using Make. Then compile OutpostHD, using make.

Hopefully at this point you'll have an OPHD executable file.

Trying to run the executable may show a bunch of errors concerning missing data files. Hopefully that will be fixed at some point. It's basically just not looking in the right place for them. A simple hack is to copy them to where it's looking, which is something like ~/.lom or to make some source code modifications.


Edit:
You'll also need to have a few libraries installed, such as SDL2. Some packages can be installed with Apt. Others may need a source install or special repository added to get the needed versions. Ubuntu Apt packages are often a bit dated. The makefile (of NAS2D) should provide some help for a source install of SDL2.
« Last Edit: May 27, 2018, 12:51:48 PM by Hooman »

Offline macksting

  • Newbie
  • *
  • Posts: 16
I'll take a shot at this when I can, with attention to which version of SDL2 it's trying to use/give me if I need to figure out what's hanging it up. Thanks for the prompt replies!

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 1925
    • LairWorks Entertainment
I do need to specify, SDL2 2.0.5 or newer must be used as it includes functions that are not present in older versions. These are related to window resizing.
- Leeor
LairWorks Entertainment

Titanum UFO's

Offline macksting

  • Newbie
  • *
  • Posts: 16
Yeah, I caught that in the other topic, but it's good to have it here, especially in case anybody else follows this thread not too long from now for the same answers.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4438
If you have the choice of using Ubuntu 18.04, that will solve a lot of the source install issues, since the Apt packages are recent enough to just work. No need for a source install there. Ubuntu 18.04 came out in the last month or so.

Offline macksting

  • Newbie
  • *
  • Posts: 16
I guess I gotta update some time.

Offline macksting

  • Newbie
  • *
  • Posts: 16
Well, the nice thing about doing things bass ackwards in Linux is the error messages can be illuminating, and with a little looking up they can remind you what you forgot to do.

I mean, there's dependency hell, but Sartre said life's a series of waiting for waiting for waiting, so whatever.

Well. Maybe despite my efforts just now I haven't adequately installed SDL 2.0.5 or later. "src/Renderer/OGL_Renderer.cpp:14:23: fatal error: SDL_image.h"

Edit: No, this is clearly 2.0.9. sudo make install ought to have made it available throughout, yes? Which would imply I don't actually understand what I'm looking at with that error at all.
« Last Edit: June 02, 2018, 09:20:00 AM by macksting »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4438
Looks like an error on the #include line, which means it can't find the header anywhere in the include path.

The include path is passed to the compiler with the -I command line option. The makefile tries to find the system install of SDL2 using the sdl2-config command. The sdl2-config command should get installed along with the SDL2 files. You can run it manually to check. Pass the --cflags parameter to see the C compiler flags, which contains the include path.

Note that a system package manager install of SDL2 may have a slightly different path than a source install. If the wrong copy of sdl2-config is found in the path, it may point to the older install of SDL2. You might want to consider uninstalling the SDL2 package with the system package manager.

Another related note, is the source install script section of the makefile. If you use the makefile script for a source install, it can attempt to download and build the core SDL2 files for you. It does this in a subfolder of the project. The makefile has additional -I options to try and use such a source install before the system install. Its use was mainly to ease deployment to automated build and test machines. It uses version SDL2 version 2.0.5. It might miss a few additional components though, such as SDL2_mixer, SDL2_image, and SDL2_ttf. Those might be the same version as the system package manager, though due to subtle path differences, there might be issues picking up files from both a source install and a package manager install.


Anyway, sounds like you have a path issue concerning sdl2-config, either of the tool itself, or the path it returns.

Offline macksting

  • Newbie
  • *
  • Posts: 16
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #10 on: June 03, 2018, 10:50:49 AM »
Note that a system package manager install of SDL2 may have a slightly different path than a source install. If the wrong copy of sdl2-config is found in the path, it may point to the older install of SDL2. You might want to consider uninstalling the SDL2 package with the system package manager.
Following the instructions I found available, I installed it using Mercurial. I'm having a weirdly difficult time discerning what version number my SDL2 is just now. What Mercurial installed (using the hg command line thingy) was, as best I can tell, 2.0.9

Quote
Another related note, is the source install script section of the makefile. If you use the makefile script for a source install, it can attempt to download and build the core SDL2 files for you. It does this in a subfolder of the project. The makefile has additional -I options to try and use such a source install before the system install. Its use was mainly to ease deployment to automated build and test machines. It uses version SDL2 version 2.0.5. It might miss a few additional components though, such as SDL2_mixer, SDL2_image, and SDL2_ttf. Those might be the same version as the system package manager, though due to subtle path differences, there might be issues picking up files from both a source install and a package manager install.
That's an interesting little something. It'd certainly account for the specific problem.

Quote
Anyway, sounds like you have a path issue concerning sdl2-config, either of the tool itself, or the path it returns.
sdl2-config itself does seem to give a proper result of some variety, though I wish it was more clear how to check its version number and such. But command line is something I've still not managed to get very good at since I started using Win98. (I defaulted to DOS even during Win95 days, but had to give it up at some point.)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4438
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #11 on: June 03, 2018, 01:31:51 PM »
These commands might help troubleshoot:
Code: [Select]
which sdl2-config  # Show path to sdl2-config
sdl2-config --version  # Show SDL2 version number
sdl2-config --cflags  # Show C++ compile flags, which reveal header install location
apt show sdl2  # (Ubuntu) Show details of system package for SDL2 (versions, installed or not)

You can also check the make file and the build folder for details on the local source install scripts, and where it caches the data for that. Though this probably isn't so interesting if you've already managed a system install (either source or package).

Offline macksting

  • Newbie
  • *
  • Posts: 16
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #12 on: June 04, 2018, 07:42:15 AM »
These commands might help troubleshoot:
Code: [Select]
which sdl2-config: /usr/local/bin/sdl2-config
sdl2-config --version: 2.0.8*
sdl2-config --cflags: -I/usr/local/include/SDL2 -D_REENTRANT
Fair enough, results included above. *whiskey tango foxtrot?

Code: [Select]
apt show sdl2  # (Ubuntu) Show details of system package for SDL2 (versions, installed or not)
N: Unable to locate package sdl2
N: Unable to locate package sdl2
E: No packages found
Heh. Is this related to the fact that, in order to get the latest version number I could, I went with a downloaded sourcecode install?

Quote
You can also check the make file and the build folder for details on the local source install scripts, and where it caches the data for that. Though this probably isn't so interesting if you've already managed a system install (either source or package).

Would it look like this?
Code: [Select]
HDRS = \
SDL.h \
SDL_assert.h \
SDL_atomic.h \
SDL_audio.h \
SDL_bits.h \
SDL_blendmode.h \
SDL_clipboard.h \
SDL_cpuinfo.h \
SDL_egl.h \
SDL_endian.h \
SDL_error.h \
SDL_events.h \
SDL_filesystem.h \
SDL_gamecontroller.h \
SDL_gesture.h \
SDL_haptic.h \
SDL_hints.h \
SDL_joystick.h \
SDL_keyboard.h \
SDL_keycode.h \
SDL_loadso.h \
SDL_log.h \
SDL_main.h \
SDL_messagebox.h \
SDL_mouse.h \
SDL_mutex.h \
SDL_name.h \
SDL_opengl.h \
SDL_opengl_glext.h \
SDL_opengles.h \
SDL_opengles2_gl2ext.h \
SDL_opengles2_gl2.h \
SDL_opengles2_gl2platform.h \
SDL_opengles2.h \
SDL_opengles2_khrplatform.h \
SDL_pixels.h \
SDL_platform.h \
SDL_power.h \
SDL_quit.h \
SDL_rect.h \
SDL_render.h \
SDL_rwops.h \
SDL_scancode.h \
SDL_shape.h \
SDL_stdinc.h \
SDL_surface.h \
SDL_system.h \
SDL_syswm.h \
SDL_thread.h \
SDL_timer.h \
SDL_touch.h \
SDL_types.h \
SDL_version.h \
SDL_video.h \
SDL_vulkan.h \
begin_code.h \
close_code.h
« Last Edit: June 04, 2018, 08:42:38 AM by Hooman »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4438
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #13 on: June 04, 2018, 09:44:41 AM »
It looks like the install prefix is: /usr/local/
The binaries go into bin/, and include files go into include/, hence the paths:
/usr/local/bin/
/usr/local/include/

Based on both the /usr/local/ prefix, and the version 2.0.8 tag, I'd say it looks like you're seeing a system wide source install. That matches up with what you've said you tried earlier, so probably a good thing.


You should aim for a source install rather than a package manager install. This is because Ubuntu 16.04 has outdated package manager packages, which aren't recent enough. But, since there is a potential for both versions to be installed at the same time, which can lead to confusing situations, I'm going to include info on the package manager packages too, so you can understand your own setup a little better, and debug any problems you might encounter.




Now to the package manager.

I'm afraid I got the package name wrong for the last command. I played around with user generated packaged using checkinstall on my system, hence I ended up with a self-created "sdl2" package. That had confused me when I was posting earlier.

If you want to see a list of packages matching the pattern "sdl2", use:
Code: [Select]
apt-cache search sdl2

The result should include the main development package:
Code: [Select]
libsdl2-dev - Simple DirectMedia Layer development files

You can get package details with:
Code: [Select]
apt show libsdl2-dev

For Ubuntu 16.04, it should list version 2.0.4 available, and tell you if it is installed or not. If it is installed, you can get the installed contents of the package with:
Code: [Select]
dpkg -L libsdl2-dev

Typically that will list a bunch of files under the prefix: /usr/
Hence you should have stuff like:
/usr/bin/sdl2-config
/usr/include/SDL2/SDL.h
/usr/lib/x86_64-linux-gnu/libSDL2.so
There should be many files listed, but only if you have the package manager's package installed, not if you have only a source install.


The prefix and the include folder is the important part for the -I option to g++ or clang, and is returned by sdl2-config (which exists at separate locations for the package install versus the source install, so you might have both available).

Code: [Select]
/usr/local/bin/sdl2-config --version
/usr/bin/sdl2-config --version


You may also note there are multiple sdl2 packages listed by apt-cache search. There are various optional components involved with SDL. There are also binary versus development versions of packages. You need the development versions, which include the source header files to compile against. The development packages have the "-dev" suffix.

Note the development packages include the binary packages as dependencies, so installing the development packages will automatically install the binary packages too. If you just want to run the game, and already have a compiled game executable file, installing the binary packages would be sufficient. That would satisfy the executable's dependencies, and allow it to run.

For OutpostHD the relevant (outdated on Ubuntu 16.04) packages needed to compile are:
Code: [Select]
libsdl2-dev
libsdl2-mixer-dev
libsdl2-image-dev
libsdl2-ttf-dev
libglew-dev
libphysfs-dev

The last 2 are not SDL related.

If you are doing a source install of SDL, you may need to do a source install of all those SDL packages.



As for the makefile install script, I mean part of the NAS2D library's makefile. It depends on these same packages, and has some code appended to the makefile to build the core SDL2 dependency. In particular, look for the last rule install-deps-source-sdl2. It shows the download, untar, configure, and make steps for a source build. It just builds locally in a subfolder. It doesn't try to install system wide, though you could do so with sudo make install. You could adapt this to download and build the other SDL2 packages.
« Last Edit: June 04, 2018, 09:50:52 AM by Hooman »

Offline macksting

  • Newbie
  • *
  • Posts: 16
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #14 on: June 07, 2018, 02:04:54 AM »
I've found myself a little daunted trying to figure out where to find sources for those. It occurs to me I could Google that, but if you know something likely, it'd probably save me a little stress and hair-pulling.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4438
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #15 on: June 07, 2018, 02:14:06 AM »
I was working on a Dockerfile to standardize the process for Ubuntu 16.04. I haven't gotten it done quite yet, though it does include SDL2 source archives info:

Code: [Select]
ARG sdlVersion=2.0.5
ARG sdlImageVersion=2.0.3
ARG sdlMixerVersion=2.0.2
ARG sdlTtfVersion=2.0.14

# ...

RUN curl https://www.libsdl.org/release/SDL2-$(sdlVersion).tar.gz | \
  tar -xjC /sdl-src && \
  make -C /sdl-src

RUN curl https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$(sdlImageVersion).tar.gz | \
  tar -xjC /sdl-src && \
  make -C /sdl-src

RUN curl https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-$(sdlMixerVersion).tar.gz | \
  tar -xjC /sdl-src && \
  make -C /sdl-src

RUN curl https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(sdlTtfVersion).tar.gz | \
  tar -xjC /sdl-src && \
  make -C /sdl-src

Offline macksting

  • Newbie
  • *
  • Posts: 16
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #16 on: June 09, 2018, 05:48:08 PM »
That's super duper useful, thank you. Sorry it's taking me so long to get around to this; I hope nobody particularly minds. It's just been kind of a weird, often sleepless couple weeks, and last night was the first night in quite a while I got anything resembling a full night's sleep.

And well. There's other things too.

I've still got the greatest enthusiasm and confidence in the mission. -_^

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 1925
    • LairWorks Entertainment
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #17 on: June 09, 2018, 06:33:53 PM »
It's just been kind of a weird, often sleepless couple weeks, and last night was the first night in quite a while I got anything resembling a full night's sleep.

And well. There's other things too.

That's very well understood, at least on my end. It's been like that for me for about two weeks now as well though I have yet to get anything restful.

Side note -- thank you for continuing to push through this. Can help me (and other inexperienced linux users and developers) get OPHD building on Ubuntu. I still want to be able to distribute official packages for Ubuntu/Arch Linux builds but I wouldn't know where to even begin with it.  :-[ :-[
- Leeor
LairWorks Entertainment

Titanum UFO's

Offline macksting

  • Newbie
  • *
  • Posts: 16
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #18 on: June 09, 2018, 11:53:07 PM »
I suppose strictly speaking knowing a recipe to make it happen is a really good place to start, and that's part of what I, if I can get it working, can offer.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4438
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #19 on: June 10, 2018, 08:19:35 AM »
You may also be interested in the thread where I was experimenting with a Dockerfile for compiling OutpostHD.

You'd need Docker installed, and it would need to download the Ubuntu 18.04 image base, but it's a largely already setup solution to get things to compile. I was also experimenting with an Ubuntu 16.04 image base, though hadn't completed the work.

I was doing this work in a private local branch, but it had fallen by the wayside. You've reminded me about this work, and by trying things out yourself, it's been encouraging me to look back into it.

Offline macksting

  • Newbie
  • *
  • Posts: 16
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #20 on: July 03, 2018, 08:42:15 AM »
Sorry about not being able to get back into this of late. Summer's not a great season for me. My shrink says I seem to have a poorly characterized but known condition where direct sunlight and such cause, rather than alleviate, depression; in me, this manifests as fatigue.

Not trying to make a fuss or make anybody sad, just explaining that I haven't forgotten, nor am I allowing myself to beat myself up over it. It's just a lousy time of year for me, and it might be a little while before I can really get the energy to make this happen.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4438
Re: Eternal Linux n00b drawing a blank. How do I build it? (Ubuntu 16.04)
« Reply #21 on: July 03, 2018, 08:52:36 AM »
Hey, a Makefile was recently pushed to a branch on GitHub to build source dependencies. It's a little finicky, but if you run it twice, it should get everything installed. I tested it on Ubuntu 16.04.

Hopefully over the next few days I'll find time to make it a bit better.


Link:
https://github.com/lairworks/nas2d-core/tree/add-docker-support
« Last Edit: July 03, 2018, 08:56:01 AM by Hooman »