1. Forum moved (you can use login and pass from old forum)

Linux

Discussion in 'Ports' started by JonnyH, Jul 17, 2014.

  1. JonnyH

    JonnyH Well-Known Member Official Developer Administrator
    0/28

    Joined:
    Jul 17, 2014
    Messages:
    167
    Likes Received:
    15
    Best Answers:
    0
    Hi,

    I got an initial CMake file for building on linux - it is build tested (using gcc 4.8) only at this point.

    I'm keeping my work in https://github.com/JonnyH/OpenApoc 'linux' branch, I'll probably keep working on this if it ends up being useful...

    --
    JonnyH
     
  2. pmprog

    pmprog Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 8, 2014
    Messages:
    173
    Likes Received:
    5
    Best Answers:
    0
    Nice one. I'll happily merge it as and when you're ready.
     
  3. JonnyH

    JonnyH Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 17, 2014
    Messages:
    167
    Likes Received:
    15
    Best Answers:
    0
    It builds and 'works' (Shows the menu screen at least) on my machine using the linux branch on my github.

    One problem - I hit a few issues with inconsistent upper/lowercase filenames (At least on my steam-acquired Apoc copy) - it's a problem in Linux (and presumably other OSs that also are case-sensitive, such as MacOS).

    I'm not sure if we should fix this ourselves? I started looking at adding a data class for all file loading, so there is just a single point where we need to do any path/case fixups.... Any thoughts on what should be done here?

    Also, I added a pull request (I think, I don't really use github much...) that fixes a gcc warning about undefined behaviour - should be nothing specific to Linux.

    --
    Jonny
     
  4. darkestaxe

    darkestaxe Registered
    26/28

    Joined:
    Jul 17, 2014
    Messages:
    15
    Likes Received:
    5
    Best Answers:
    1
    Why not avoid case sensitivity entirely by selecting the files by a criteria at runtime, possibly using regex, ordering alphabetically as appropriate (map01, map02, map03) and then loading the selected files. This would add some potential early mod support for future modders also: by matching the file selection criteria someone could add mod files (CraZYhourse%s_ExtremeZoneXXX_MaP01) without us having to change anything on our end.
     
  5. marad

    marad Registered
    0/28

    Joined:
    Jul 18, 2014
    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Hi,

    I didn't notice the work done by JonnyH and I was so anxious to compile OpenApoc on GNU/Linux myself, I patched up a quick Autotools build system (the same one OpenXCom uses). It's on gitorious here: gitorious.org/openapoc/openapoc. Feel free to use it or do whatever you want with it.

    While at it I noticed gcc (tested version 4.7.3) still doesn't support scoped enums by default, which is a feature of the recent c++11 standard (it does only with -std=c++11 switch). Something to watch out for.

    I did run into some problems with game data, because so far OpenApoc just segfaults silently if it doesn't find the files it needs. It took me some time to figure out what's happening, so taking this opportunity, here is what I did to make it actually run (I have two versions, one from GamersGate and one from recent HumbleBundle and as far as I can tell, they're the same):

    First, copy the files from XCOMA to data folder, but that is not enough since some of the files are also on the cd image. By default, mount will map the file names on a DOS cd to lower case and remove trailing ;1's. This is a problem, since GNU/Linux filesystem is case sensitive and the game looks for upper case names, so it might not see the files (the problem also highlighted by JonnyH). Solution I used to work around this was to disable the mapping altogether
    Code:
    sudo mount -o loop -o map=off cd.iso /mnt/floppy
    Now, copy the files from the XCOM3 folder and the MUSIC;1 file. Then, fixing the trailing ;1's is really easy
    Code:
    find data -exec rename ";1" "" {} \;
    Now it should work. Hope it helps someone :)

    Cheers, and good luck with OpenApoc!
     
  6. pmprog

    pmprog Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 8, 2014
    Messages:
    173
    Likes Received:
    5
    Best Answers:
    0
    Yep, that's because I'm barely even started :) It'll work better, I promise

    Thanks, and welcome to the boards
     
  7. kkmic

    kkmic Undefined
    0/28

    Joined:
    Jul 17, 2014
    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    Nice one! :)

    Please make a pull request once you think it is stable enough.
     
  8. JonnyH

    JonnyH Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 17, 2014
    Messages:
    167
    Likes Received:
    15
    Best Answers:
    0
    I have no great attachment to CMake, I find it useful for a quick get-something-building, but have found it unwieldy for larger projects as you try to do more complex stuff.

    I actually 'fixed' this in my branch - now it prints out the file it failed to open to stderr before crashing. Much better!

    As an aside, I had some code I wrote ages ago when looking into a similar project, trying to reverse-engineer the apoc file formats, https://github.com/JonnyH/xcapoc-resources, iit looks like we already have much of the functionalty already, but there may be something useful there. Note it is very much prototype code written while trying to figure out the formats, and is slow/awful/etc.
     
  9. pmprog

    pmprog Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 8, 2014
    Messages:
    173
    Likes Received:
    5
    Best Answers:
    0
    Interesting, I'll take a look, thank you
     
  10. kkmic

    kkmic Undefined
    0/28

    Joined:
    Jul 17, 2014
    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    I got this from ccmake:

    Code:
     CMake Error at /usr/share/cmake-2.8/Modules/FindPkgConfig.cmake:266 (message):
       A required package was not found
     Call Stack (most recent call first):
       /usr/share/cmake-2.8/Modules/FindPkgConfig.cmake:320 (_pkg_check_modules_internal)
       CMakeLists.txt:45 (pkg_check_modules)
    I'm a bit lost. Line number 45 in CmakeLists.txt reads:

    Code:
    pkg_check_modules(PC_ALLEGRO REQUIRED allegro-5.0)
    However, I have installed the latest version of Allegro from the Git repo (branch 5.1 I believe - how can I check to be sure?), yet there seems to be something wrong with the Cmake script.
     
  11. JonnyH

    JonnyH Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 17, 2014
    Messages:
    167
    Likes Received:
    15
    Best Answers:
    0
    I only tested with allegro 5.0 - we currently use none of the features in 5.1, and if they changed the pkgconfig name that would cause this error.

    I should make it 5.0 or 5.1 - you should be able to change the version in the pkg_check_modules macro to 'allegro-5.1' for the time being...

    Jonny
     
  12. kkmic

    kkmic Undefined
    0/28

    Joined:
    Jul 17, 2014
    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    I tried setting the version to 5.1 in CmakeLists.txt, got the same error.

    I'll try with the 5.0 branch.

    Edit: Worked with the 5.0 branch.

    However, I got another error, this time when running
    Code:
    make
    :
    Code:
    Scanning dependencies of target OpenApoc
    [  3%] Building CXX object CMakeFiles/OpenApoc.dir/framework/event.cpp.o
    cc1plus: error: unrecognized command line option ‘-std=c++11’
    make[2]: *** [CMakeFiles/OpenApoc.dir/framework/event.cpp.o] Error 1
    make[1]: *** [CMakeFiles/OpenApoc.dir/all] Error 2
    make: *** [all] Error 2
    Compiler too old? Wrong compiler? I'm not a C++ programmer, so I'm not too 'in the know' about this...
     
  13. marad

    marad Registered
    0/28

    Joined:
    Jul 18, 2014
    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Very probably. The line with cc1plus indicates you're using gcc; you need at least version 4.7 for it to understand -std=c++11. If you have older gcc (but at least 4.3), you can try changing "-std=c++11" to "-std=c++0x" in CMakelists.txt. It could work, but no guarantees. Otherwise try updating your gcc.

    Edit: I checked. You need at least gcc 4.4 and then -std=c++0x should work you you.
     
  14. JonnyH

    JonnyH Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 17, 2014
    Messages:
    167
    Likes Received:
    15
    Best Answers:
    0
    Yeah, I only tested with gcc 4.7 and 4.8, both of which have the -std=c++11 option. Older versions have -std=c++0x instead (As before 2011 the standard didn't have a name), but I haven't tested compiling with them so you should only try if you know what you're doing.

    Generally, this project is at an early stage, I would not recommend trying anything unless you're trying to help development. If you're trying to use a new system/compiler version, you may end up having to test it yourselves....

    Jonny
     
  15. kkmic

    kkmic Undefined
    0/28

    Joined:
    Jul 17, 2014
    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    It worked. But as this project is in it's very early stages, I don't think this is an option in the long run. I'm looking to upgrade my gcc (4.6.3 on Kubuntu 12.04 for the moment).





    Question: Obviously, there are some improvement in newer language specifications compared to the older versions. For example, this is a (partial?) comparison between 4.7.2 and 4.8:

    Code:
    Language Features
    - Rvalue references for *this
    - Generalized attributes
    - Alignment support
    - Inheriting constructors
    Concurreny
    - Bidirectional Fences
    - Memory model
    - Abandoning a process and at_quick_exit
    - Thread-local storage 
    My question (finally) is: do you believe that the C++11 features are
    Code:
    [b]necessary[/b]
    or
    Code:
    [b]nice to have[/b]
    in the long run? Or have you used the
    Code:
    [b]-std=c++11[/b]
    flag to force the use of a recent compiler for performance reasons?
     
  16. pmprog

    pmprog Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 8, 2014
    Messages:
    173
    Likes Received:
    5
    Best Answers:
    0
    At the minute you shouldn't need C++11; but yes, it might be required further down the line.
     
  17. JonnyH

    JonnyH Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 17, 2014
    Messages:
    167
    Likes Received:
    15
    Best Answers:
    0
    I'm actually using a number of c++11 things already in my prototyping code, at least: Lambdas (for event handling callbacks), Delegated constructors, smart pointers (Damn useful!), range-for loops, and probably any number of other things I can't recall at the time.

    I do believe they are significant time/effort savings in development, and I would lean towards c++11 certainly being nice to have, and not just an attempt at mandating a new compiler for other reasons.
     
  18. kkmic

    kkmic Undefined
    0/28

    Joined:
    Jul 17, 2014
    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    I like your answer :)

    Thanks!
     
  19. JonnyH

    JonnyH Well-Known Member Official Developer Administrator
    41/56

    Joined:
    Jul 17, 2014
    Messages:
    167
    Likes Received:
    15
    Best Answers:
    0
    I just pushed some code that now treats files as case-insensitive to match windows. This replaces the hacky try-all-lowercase-if-we-fail previous behaviour. This means there should be no more issues with (apparently just my) computer mounting the apoc iso in a different case to everyone else. It means that if you have two files differing only by case, it's undefined which will actually be read, whichever your filesystem happens to spit out first, so no adding fileA expecting it to be different to filea!

    This is enabled by default on all cmake builds, I assume this has only been tested on linux so far?

    --
    Jonny
     
  20. kkmic

    kkmic Undefined
    0/28

    Joined:
    Jul 17, 2014
    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    A correct Apocalypse install will only have only one file named "fileA" in a folder, using whichever case the OS/mounting tool decides to use:
    filea, fileA, FileA, FILEA, FiLeA, or anything in between.

    If there will be two or more files having the same name (albeit with different case) in the same folder, this is user error, and there should be no attempt by the game to find the "right" file. The current approach is right.


    Sidenote:
    Is it worth checksuming the original files to guard against bad installs/patched files & such?
     

Share This Page