5

I am trying to compile Xash3D on GuixSD v1.0.0 and gcc 8.3.0.

As is shown below, ld (GNU Linker) is giving me errors, that ctr1.o and ctri.o are missing. These files exist elsewhere under multiple directories, within /gnu/store/{specificProgramName}, however, I surprisingly wasn't able to make a symbolic link to ~/.guix_profile, where other libraries sit, even with root access. There are multiple versions of them with different sizes so I would assume that they are only compatible with their respective programs. Furthermore. ~/.guix_profile seems to emulate the root directory of a Unix system, however in GuixSD /usr is missing from both the root directory, and ~/.guix_profile, so I would not know where to link the c objects even if I had the actual files.

In essence, ld cannot find crt1.o, crti.o, and libgcc_s.so, and it is quite possible that just like before, after linking or installing these 2 c objects and libgcc, cmake will halt with yet a further error regarding other other dependencies.

Anyways, here is what is printed/logged by the following command (which is instructed as the recommended way of installing Xash3D)

sudo cmake -DHL_SDK_DIR=../hlsdk -DXASH_SDL=yes -DXASH_VGUI=yes -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32" -DCMAKE_EXE_LINKER_FLAGS="-m32" ../ && sudo make
-- The C compiler identification is GNU 9.1.0
-- The CXX compiler identification is GNU 9.1.0
-- Check for working C compiler: /home/nick/.guix-profile/bin/gcc
-- Check for working C compiler: /home/nick/.guix-profile/bin/gcc -- broken
CMake Error at /gnu/store/nrsbv2df55abwji1gsb1ilf22n3rc1xa-cmake-3.13.1/share/cmake-3.13/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/home/nick/.guix-profile/bin/gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/nick/xash3d/build/CMakeFiles/CMakeTmp
    Run Build Command:"/home/nick/.guix-profile/bin/make" "cmTC_7635d/fast"
    /home/nick/.guix-profile/bin/make -f CMakeFiles/cmTC_7635d.dir/build.make CMakeFiles/cmTC_7635d.dir/build
    make[1]: Entering directory '/home/nick/xash3d/build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_7635d.dir/testCCompiler.c.o
    /home/nick/.guix-profile/bin/gcc   -m32    -o CMakeFiles/cmTC_7635d.dir/testCCompiler.c.o   -c /home/nick/xash3d/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_7635d
    /gnu/store/nrsbv2df55abwji1gsb1ilf22n3rc1xa-cmake-3.13.1/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7635d.dir/link.txt --verbose=1
    /home/nick/.guix-profile/bin/gcc -m32     -rdynamic CMakeFiles/cmTC_7635d.dir/testCCompiler.c.o  -o cmTC_7635d 
    /home/nick/.guix-profile/bin/ld: cannot find crt1.o: No such file or directory
    /home/nick/.guix-profile/bin/ld: cannot find crti.o: No such file or directory
    /home/nick/.guix-profile/bin/ld: skipping incompatible /gnu/store/69x60a1pn0mf5jv68al8awjfkyp1miwi-gcc-8.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/8.3.0/libgcc.a when searching for -lgcc
    /home/nick/.guix-profile/bin/ld: cannot find -lgcc
    /home/nick/.guix-profile/bin/ld: skipping incompatible /gnu/store/69x60a1pn0mf5jv68al8awjfkyp1miwi-gcc-8.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/8.3.0/../../../libgcc_s.so.1 when searching for libgcc_s.so.1
    /home/nick/.guix-profile/bin/ld: cannot find libgcc_s.so.1
    /home/nick/.guix-profile/bin/ld: skipping incompatible /gnu/store/69x60a1pn0mf5jv68al8awjfkyp1miwi-gcc-8.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/8.3.0/libgcc.a when searching for -lgcc
    /home/nick/.guix-profile/bin/ld: cannot find -lgcc
    collect2: error: ld returned 1 exit status
    make[1]: *** [CMakeFiles/cmTC_7635d.dir/build.make:87: cmTC_7635d] Error 1
    make[1]: Leaving directory '/home/nick/xash3d/build/CMakeFiles/CMakeTmp'
    make: *** [Makefile:121: cmTC_7635d/fast] Error 2

Much like Debian, Guix has a bash command for package installation: "guix install $PACKAGE" however its library of ~10,000 does not include one with the name 'gcc-multilib' which would have fixed the problem in Debian. Perhaps there is an alternative package that includes this and other libraries?

I am looking for a solution that does not involve using Wine. Solving the libgcc problem alone might not be sufficient, so in order to arrive at a genuine solution, I will be trying any advice left in the comments (there is no danger to me, the OS is installed in an isolated environment on a USB key).

Here is what my $PATH looks like:

/gnu/store/hk4f641r18vpj44m42pny6rp1nwg3d4w-glib-2.56.3-bin/bin
/run/setuid-programs
/home/nick/.config/guix/current/bin
/home/nick/.guix-profile/bin
/home/nick/.guix-profile/sbin
/run/current-system/profile/bin
/run/current-system/profile/sbin

The two packages that should be installed are named gcc-multilib and libc-dev in Debian-based OS's. These packages (or their elements) should exist somewhere in the Guix library of packages, but under different name(s).

I have tried binding various paths for LIBRARY_PATH in the shell, including:

$HOME/.guix-profile/lib
$HOME/.guix-profile/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
## Containing many c object/shared object and header files
/gnu/store/aqv6njg05w2yqh8krgrjy0wcbfxb4nn3-gcc-toolchain-9.1.0/lib/crt1.o
## Containing crt1.o and crti.o
Nick Bailuc
  • 260
  • 4
  • 15
  • I've already tried to install packages that seem relevant, such as variants of libc and glibc, binutils, and graphics libraries. Initially cmake gave me errors of gcc not working (even a simple hello.c didn't compile) however installing binutils fixed this. The solution may actually be quite simple: when I first installed GuixSD, the upmost basic bash commands like ls, man, gcc, and even its very own guile were all missing (had to install gnu coreutils, man-db...) so these libraries might just be part of some package similar to what Debian used to call ia-32libs before it introduced multiarch. –  May 15 '19 at 00:09
  • I'd suggest you look at [merging](https://unix.stackexchange.com/help/merging-accounts) your old and current accounts. It'll make subsequent editing easier and you'll gain any points added to this question. – roaima Nov 02 '19 at 11:06

3 Answers3

2

Write a package. This is a rough outline, and it needs improvement:

(define-module (gnu packages xash3d)
  #:use-module (guix packages)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module (guix build-system cmake)
  #:use-module ((guix licenses) #:select (gpl3))
  #:use-module (gnu packages))

(define-public xash3d
  (package
    (name "xash3d")
    (version "0.19.2")
    (let (commit (string-append "v" version))
          (revision "1")) 
    (source (origin
              (method git-fetch)
              (uri (git-reference
                   (url (string-append "https://github.com/FWGS/" name "/"))
                   (commit commit)))))
    (build-system cmake-build-system)
    (synopsis "Xash3D FWGS Engine.")
    (description "Xash3D Engine is a custom Gold Source engine rewritten from scratch.")
    (home-page "https://xash.su/")
    (license gpl3)))

Resource: https://www.gnu.org/software/guix/manual/en/html_node/Defining-Packages.html

S.S. Anne
  • 453
  • 3
  • 15
  • thank you for the answer. I have tried both building the guix environment iwth those packages (plus some other relevant ones like LibG), and I also tried running the build command without the 32bit parameters, however the output was the same, missing libgcc and crti/1.o –  May 23 '19 at 22:18
  • @NickBailuc Please see updated answer. – S.S. Anne May 23 '19 at 22:59
  • like i said in the question, the /usr directory is completely missing in guixsd. some part of the usual linux filesystem is emulated under ~/.guix_profile/ but once again no /usr i think that source you provided is for guix the package manager when installed ontop debian, since it mentions apt-get, not GuixSD (guix system distribution) i appreciate the effort tho –  May 23 '19 at 23:38
  • @NickBailuc Sorry, made a mistake. Please look again. – S.S. Anne May 24 '19 at 00:45
  • @NickBailuc Does this work? – S.S. Anne May 25 '19 at 22:28
  • unfortunately no, same exact error. ive tried everything with both the -32 and without, and with sudo and without (jus in case, cuz the .guix-profile is root) I also attempted to export various other directories for LD and updated the error message for the full message. please check question changes –  May 26 '19 at 20:39
  • @NickBailuc Does it work with just `/gnu/store/aqv6njg05w2yqh8krgrjy0wcbfxb4nn3-gcc-toolchain-9.1.0/lib/` as LIBRARY_PATH? – S.S. Anne May 26 '19 at 21:56
  • yeah thats what i meant, included the .o in the question by accident do you think theres a way to add a flag to gcc or cmake/make directly to check in that directory? as you can see in the error log, it finds the files elsewhere but skips them for being 'incompatible' –  May 26 '19 at 22:18
  • 1
    They're "incompatible" because they're 64-bit instead of 32-bit. I don't think that will work. Anyway, see my updated answer. – S.S. Anne May 26 '19 at 22:20
  • for c libs its probably different but when i ran into the 32/64bit problem with graphics and sound libraries, id always link 32 when 64 isnt available. if this is only for the test program, it might not even matter Ive been wanting to get into guile/scheme, but i barely know the syntax. when running, i get "expected keyword arg" on line 7. also theres a ) missing in the end if a proper scheme file is all thats needed to get this to run on guix, it could be published officially. ive been in touch with the xash dev, he just doesnt know how to use guile/guix but he is for publishing it in guix –  May 26 '19 at 22:34
  • @NickBailuc Can you try it again? – S.S. Anne May 26 '19 at 22:38
  • received error in base32 string: guix package: error: exception thrown: # –  May 26 '19 at 22:45
  • @NickBailuc Give it another shot. We can add the sha256sum later. – S.S. Anne May 26 '19 at 22:48
  • unfortunately, it seems to be a requirement, i got error missing field initializers (sha256) p.s. i really appreciate the effort! –  May 26 '19 at 22:54
  • @NickBailuc I've added some of it back. Could you try again? Would it be better if we talked on [GitHub](https://github.com/JL2210)? – S.S. Anne May 26 '19 at 22:57
  • 1
    Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/94131/discussion-between-nick-bailuc-and-jl2210). –  May 26 '19 at 22:58
0

Make sure to install the gcc-toolchain package, as explained in the manual.

  • tried it out, didnt seem to change anything i even set gcc-toolchain as the $LIBRARY_PATH –  May 31 '19 at 00:15
-1

I run into this crt*.o error each time I compile a new GNU compiling framework, either cross or native.

crt[1,i,n].o are c runtime files used for low-level link. ld and collect2 use them for every single compilation. The catch comes when you try to compile something very close to the compiler itself. From your log (building testCCompiler.c.o) you are trying to do that.

In all my struggles to find a unique and elegant way to solve this problem once and for all I failed, although I always end up overcoming errors. I assume you know your way through the GNU Make compiling process (debugging errors in particular). CMake is just a configuration wrapper around GNU Make. Here are useful clues that might help you:

  • Before you start any compiling, identify the path of the crt*.o files, they are essential to getting you through the errors.

  • During compilation, the staging compiler: xgcc, uses the -B 'directory' path search option (see gcc man page). Use it by manually adding the crt files path to it.

  • Creating symlinks, based on the error output, for crt files, will get your way out of the compilation errors. But beware that you will very probably have to redo it several times during the compilation process.

hope this helps.

P.S. if I were in your situation, I would ask myself: do I really need this testCCompiler?

Vincent Achard
  • 340
  • 1
  • 5
  • Like i mentioned, there are multiple crt[[.o's on the system, existing inside the program files of specific programs under /gnu/store, and they have various weights so I do not know which one i could even use. furthermore, i am not able to link things in an out and within /gnu/store or /home/nick/.guix where the linux filesystem is emulated. even further, I cannot run binaries in guix at all, only if they were compiled on that instance of the system, so they probablty wouldnt work if i just copied the libraries from one program to the other. –  May 23 '19 at 22:16
  • Also xgcc doesnt exist as a package or as a bash command. I have provided above the output of $PATH if that helps. PS I didnt downvote your answer, not sure who did. Stack can have some hardliners in terms of following rules –  May 23 '19 at 22:16
  • There are several inconsistencies in your answer: The `testCCompiler.c` file is used by CMake to ensure that the C compiler works. CMake is *NOT* a wrapper around GNU make, it can generate build files for other build systems. `xgcc` is used during the bootstrap of GCC, not during normal use. The OP is not trying to bootstrap a GNU compiler toolchain, but compile software using the provided GNU compiler toolchain on the system. – S.S. Anne May 24 '19 at 00:54