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

Cant compile the solution on Ubuntu #725

Closed
Marcelo20XX opened this issue Jan 29, 2023 · 39 comments
Closed

Cant compile the solution on Ubuntu #725

Marcelo20XX opened this issue Jan 29, 2023 · 39 comments
Labels
Help wanted Extra attention is needed

Comments

@Marcelo20XX
Copy link

Marcelo20XX commented Jan 29, 2023

I followed the instructions on the Contibutions.MD file. Installed docker, make package and the gcc-mingw-w64 package yet still I get the following error when entering the command on the terminal: sudo make debug

mkdir -p build
docker run --rm --user 0:0 --entrypoint /app/docker/game/entrypoint.sh -e TARGET="release" -v /media/x/Data_2/Z-Sources/Tomb1Main/Tomb1Main:/app/ rrdash/tomb1main:latest
+ set -e
+ [ ! -f /app/build/build.ninja ]
+ meson --buildtype release /app/build/ --cross /app/docker/game/meson_linux_mingw32.txt --pkg-config-path=/ext/lib/pkgconfig/
The Meson build system
Version: 0.64.1
Source dir: /app
Build dir: /app/build
Build type: cross build
Project name: Tomb1Main
Project version: undefined

meson.build:1:0: ERROR: Unknown compiler(s): [['/usr/bin/i686-w64-mingw32-gcc']]
The following exception(s) were encountered:
Running `/usr/bin/i686-w64-mingw32-gcc --version` gave "[Errno 1] Operation not permitted: '/usr/bin/i686-w64-mingw32-gcc'"

A full log can be found at /app/build/meson-logs/meson-log.txt
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
make: *** [Makefile:23: release] Error 1```

this is the meson.log

```Build started at 2023-01-29T04:09:17.078252
Main binary: /usr/bin/python3
Build Options: -Dbuildtype=release -Dpkg_config_path=/ext/lib/pkgconfig/ --cross-file=/app/docker/game/meson_linux_mingw32.txt
Python system: Linux
The Meson build system
Version: 0.64.1
Source dir: /app
Build dir: /app/build
Build type: cross build
Project name: Tomb1Main
Project version: undefined
-----
Detecting compiler via: /usr/bin/i686-w64-mingw32-gcc --version

meson.build:1:0: ERROR: Unknown compiler(s): [['/usr/bin/i686-w64-mingw32-gcc']]
The following exception(s) were encountered:
Running `/usr/bin/i686-w64-mingw32-gcc --version` gave "[Errno 1] Operation not permitted: '/usr/bin/i686-w64-mingw32-gcc'"```
@walkawayy
Copy link
Collaborator

Going to tag @carlo-bramini since he's the only one who has compiled on Linux afaik. It's not officially supported yet but hopefully it will be soon.

@carlo-bramini
Copy link
Contributor

carlo-bramini commented Jan 30, 2023

Actually, I'm using CYGWIN as development platform and I also have been not able to make working on it according to the instructions, although I got errors different from yours.
So, since I wanted to have a working executable for testing the engine with the demo levels, I have written a script for CMake that I have used for building the engine instead of using the current one on various platforms that I could find: Windows (MinGW and MSVC), CYGWIN POSIX, linux, Haiku/BeOS, Android and AROS/AmigaOS. All tested in 32bit and 64bit Intel variants. Linux has been also tested with 32bit ARMv7 and 64bit Aarch64 on a Raspberry PI 4. Android version tested on Termux and software Mesa, 64bit only.

However, on my Debian virtual machine, I have not cross compiled for MinGW, but I created a native POSIX executable for the build target.

@Marcelo20XX
Copy link
Author

Well, I have also a PC with Windows 10 and the MSYS64 shell installed so if you have a script for compiling at all I am interested since I want to test some changes I made to the source, thank you in advance...

@oziphantom
Copy link
Collaborator

if you want to do "not using the docker real compiler version" its pretty easy to get working in MSVC with Clang for VS installed. So you can build and dev native windows with a debugger if you want. The hard part is getting the 32bit libs for FFMPEG etc but if you now have a 64bit version building that is probably not an issue anymore.

however to the original post. building with Docker on linux should be no different to building with Docker on Windows. running make release or make debug should fire up the docker instance and set up the environment.

@Marcelo20XX
Copy link
Author

Building with docker on Windows for me is not possible in this machine as is a Windows 10 LTSC 2019 and in this version the Subsytem Layer is bugged so I cant install Ubuntu...

Which leave the route of Clang for VS and compile on Visual Studio or if @carlo-bramini share his script so I can give a try on MinGW...

@oziphantom
Copy link
Collaborator

or
As I won't let any Linux corrupt my windows machines any more, I've been burned by Cygwin so many times. To which I fire up a small VM. Lubuntu is a Win2000 styled very light Ubuntu distribution that I fire up in Virtual Box. https://lubuntu.me/
You can set up a shared folder with VirtualBox to share a folder between Linux and Windows, ie. Tomb Raider game folder and make a small script that runs the docker then copies the exe to the said "shared folder" so you can then run it on the Windows side.

@carlo-bramini
Copy link
Contributor

carlo-bramini commented Feb 3, 2023

At this address, I created a branch in my fork with the scripts for CMake:

https://github.com/carlo-bramini/Tomb1Main/tree/add-cmake-support

You can clone it or you can just copy CMakeLists.txt and the content of directory cmake into your source tree.
Let's suppose that you have the sources of the engine into $HOME/Tomb1Main.
Now, you can create a working directory for the object files, for example tomb1main_ubuntu, configure and build the executable in this way:

mkdir tomb1main_ubuntu
cd tomb1main_ubuntu
cmake ../Tomb1Main
make

Obviously, the parameter ../Tomb1Main to CMake is the path to the source directory where you copied the scripts for CMake.
After make completes, you will have the executable for testing directly on Ubuntu.
So, copy the this executable into ../Tomb1Main/bin, together with the data files of the game an run it.
That's all.

If you want a way for an easier debugging experience, you can configure CMake for generating the files for opening the engine with an IDE like code::blocks, VisualStudio, Codelite, Eclipse and others, by passing an option to the generator.
For example:

cmake ../Tomb1Main -G "CodeBlocks - Unix Makefiles"

I hope that you will find it useful.

NOTE: at the time of write, the engine may not be able to find the data files because the filesystem is case sensitive on linux, so don't forget to rename the file names to lower case before running.

@Marcelo20XX
Copy link
Author

Thanks for your response, after I installed the FFMPEG libraries on Ubuntu I run the commands you posted but got this error:

Screenshot from 2023-02-03 21-50-45

@walkawayy
Copy link
Collaborator

Looks like there's something wrong with SDL 2.

@Marcelo20XX
Copy link
Author

I have installed libsdl2-dev on my system though.

@walkawayy
Copy link
Collaborator

Oh it may be working but you need a newer version. What SDL 2 version do you have?

@Marcelo20XX
Copy link
Author

version 2.0.10+dfsg1-3

@walkawayy
Copy link
Collaborator

I think you need at least 2.24 IIRC.

https://github.com/libsdl-org/SDL/releases

@Marcelo20XX
Copy link
Author

I installed the latest SDL 2.26.2 but now I got the following errors:

/usr/bin/ld: /usr/local/lib/libavformat.a(fifo.o): undefined reference to symbol 'pthread_join@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/Tomb1Main.dir/build.make:2795: Tomb1Main] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/Tomb1Main.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

@walkawayy
Copy link
Collaborator

Hm probably another @carlo-bramini question. Seems like cmake isn't finding a library.

@Marcelo20XX
Copy link
Author

Marcelo20XX commented Feb 4, 2023

Hi, I have installed tons of libraries: zlib, lzma and many more but after trying to compile I get the following error:

/usr/bin/ld: /usr/local/lib/libavcodec.a(tiff.o): in function tiff_uncompress_lzma': /media/x/Data_2/Z-Sources/Tomb1Main/ffmpeg/libavcodec/tiff.c:577: undefined reference to lzma_stream_decoder'
/usr/bin/ld: /media/x/Data_2/Z-Sources/Tomb1Main/ffmpeg/libavcodec/tiff.c:582: undefined reference to lzma_code' /usr/bin/ld: /media/x/Data_2/Z-Sources/Tomb1Main/ffmpeg/libavcodec/tiff.c:583: undefined reference to lzma_end'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/Tomb1Main.dir/build.make:2796: Tomb1Main] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/Tomb1Main.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

After searching for this specific error, many told me that I need to install the lzma dev libraries which I did yet I still got the same error, another person told me to add -lzma to the linker flags but I could not find where to set this flag...

@carlo-bramini
Copy link
Contributor

carlo-bramini commented Feb 4, 2023

Where does this source came from?

/media/x/Data_2/Z-Sources/Tomb1Main/ffmpeg/libavcodec/tiff.c

It doesn't exist into the repository of the engine.
By installing runtime and development libraries with apt, you should be able to build without adding foreign source codes.

@walkawayy
Copy link
Collaborator

It looks like it's required by ffmpeg. Some quick googling mentions installing apt-get install liblzma-dev which you said you did. I saw some stuff about linking but cmake is supposed to take care of doing that in the makefile if it's needed. Did you clean your build folder and run cmake again after installing liblzma-dev?

@Marcelo20XX
Copy link
Author

Where does this source came from?

/media/x/Data_2/Z-Sources/Tomb1Main/ffmpeg/libavcodec/tiff.c

It doesn't exist into the repository of the engine. By installing runtime and development libraries with apt, you should be able to build without adding foreign source codes.

I installed FFMPEG from source since installing from apt-get wasn't working, the makefile was unable to detect the FFMPEG libraries.

It looks like it's required by ffmpeg. Some quick googling mentions installing apt-get install liblzma-dev which you said you did. I saw some stuff about linking but cmake is supposed to take care of doing that in the makefile if it's needed. Did you clean your build folder and run cmake again after installing liblzma-dev?

Yes I cleaned the build folder...

@Marcelo20XX
Copy link
Author

Marcelo20XX commented Feb 4, 2023

There is really no way I can compile this source, I uninstalled the source compiled ffmpeg and installed ffmpeg via: sudo apt install ffmpeg and still the same error...

I think the problem is that Cmake isnt adding the necessary linker flags because previously the compiler was complaining that it needed pthreads on so I added to CMakeLists.txt:

set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
and to the target_link_libraries
${CMAKE_THREAD_LIBS_INIT}
then the compilation continued but eventually got stuck on the lzma part

@carlo-bramini
Copy link
Contributor

carlo-bramini commented Feb 4, 2023

I installed FFMPEG from source since installing from apt-get wasn't working, the makefile was unable to detect the FFMPEG libraries.

Probably, this happens because you didn't configured CMake properly for searching your libraries in the right place, by setting FFMPEG_ROOT_DIR variable. However, I used Debian for testing, but I had no need to rebuild system libraries.

@Marcelo20XX
Copy link
Author

Marcelo20XX commented Feb 4, 2023

Yes after setting the variable that you posted it isn't complaining anymore but I still got the lzma error I posted before :(

I gave up on Ubuntu, I will try to install Debian on a virtual machine and try again...

@carlo-bramini
Copy link
Contributor

carlo-bramini commented Feb 4, 2023

I did a new, clean installation of Debian 11 into a virtual machine.
Next, I have opened a root console and I typed this command:

apt-get install build-essential cmake git ffmpeg libsdl2-dev libswresample-dev libavutil-dev libavformat-dev libavdevice-dev libavfilter-dev libpostproc-dev libswscale-dev libgl-dev libglx-dev

Then, I typed this to clone my repo:

git clone https://github.com/carlo-bramini/Tomb1Main

Next, I selected the branch with my scripts for CMake:

cd Tomb1Main
git checkout add-cmake-support
cd ..

Finally, I created a space for configuring and compiling:

mkdir Tomb1Main_Debian
cd Tomb1Main_Debian
cmake ../Tomb1Main
make

That's all.

ATTENTION - ATTENTION - ATTENTION
The stable version of Debian includes SDL2-2.0.14, so if you will try it, then it will give an error at compile time:

[ 97%] Building C object CMakeFiles/Tomb1Main.dir/src/specific/s_input.c.o
/home/carlo/Tomb1Main/src/specific/s_input.c: In function ‘S_Input_GetButtonName’:
/home/carlo/Tomb1Main/src/specific/s_input.c:622:14: error: ‘SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR’ undeclared (first use in this function); did you mean ‘SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO’?
  622 |         case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR:
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |              SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO
/home/carlo/Tomb1Main/src/specific/s_input.c:622:14: note: each undeclared identifier is reported only once for each function it appears in

Hopefully, this can be fixed in the way that I have written into issue #716 or by just commenting those lines if you want to bypass the error quickly.

@Marcelo20XX
Copy link
Author

Marcelo20XX commented Feb 5, 2023

Ok thanks for all the patience, hopefully this time I will be able to compile, I will take into account the SDL suggestion...

EDIT: I finally compiled the source, as you said, there were no surprises on Debian, it was really straightforward, no errors, no nothing... thank you for all the assistance BUT I though I was cross compiling a win32 exe XD

Could you perhaps give me the command to compile a win32 exe

EDIT2: I was able to compile a win32 exe on Debian using the instructions on the Contributions.MD file, there was no issue while running sudo make debug on a terminal console, well this finally ends my journey trying to compile the source, perhaps the only suggestion I would make would be to change the instructions to "Compiling on Debian" instead of Ubuntu... thanks for all the help guys...

@carlo-bramini
Copy link
Contributor

Happy to know that you built the engine successfully.
Besides compiling, did you succeed to run and play the full game also on linux?

@Marcelo20XX
Copy link
Author

Sadly no, while I could compile on Debian the repository you gave me the link when running the app on Ubuntu it just give errors about not finding the necessary files, although I put the data, fmv and music files and folders in the root folder of the app and all in lowercase... On Debian I didnt tryyet because the OS is running on VMWare and I installed only the minimum to compile the source...

@walkawayy
Copy link
Collaborator

Hm glad you got something working at least. I'm not sure why it wouldn't work on Ubuntu though.

Did you pull the latest develop branch? There was a commit in the last week to change the path separators to work for Linux. Also, the filenames are case sensitive on Linux, so make sure your FMV, level, and music filenames match the names exactly in the Tomb1Main_gameflow.json5.

@carlo-bramini
Copy link
Contributor

carlo-bramini commented Feb 5, 2023

I will also try on Ubuntu ASAP, to understand what it is happening.

@Marcelo20XX
Copy link
Author

Marcelo20XX commented Feb 5, 2023

Nevermind your latest commit fixed it, I compiled the latest source but used the json file from a previous installation, after using the latest json I ran the game without any problems.

Besides compiling, did you succeed to run and play the full game also on linux?

Thing is I am not very good at Tomb Raider, I am learning though, so I am only at the St Francis Folly level but didn't notice anything out of the ordinary...

@carlo-bramini
Copy link
Contributor

carlo-bramini commented Feb 6, 2023

I did a quick test on Ubuntu 22.10 and I haven't got problems.
I followed exactly the same steps of Debian and everything has been built successfully at the first try.
Next, I imported my patch for testing the demo levels and the game started.

VirtualBox_ubuntu_06_02_2023_11_30_30

@walkawayy walkawayy added Feature New functionality Help wanted Extra attention is needed and removed Feature New functionality labels Feb 6, 2023
@Marcelo20XX
Copy link
Author

Marcelo20XX commented Feb 6, 2023

I was trying to compile on Ubuntu LTS 22.04 and got the errors I posted.

@carlo-bramini
Copy link
Contributor

I will also try Ubuntu LTS 22.04 ASAP.
That version of Ubuntu is shipped with SDL2-2.0.20, so I expect that it will print the same error of Debian stable.
However, this error can be bypassed, hopefully.

@Marcelo20XX
Copy link
Author

Upon further inspect I had Ubuntu 20.04.5 LTS codename Focal, sorry for the inconvenience

@carlo-bramini
Copy link
Contributor

Upon further inspect I had Ubuntu 20.04.5 LTS codename Focal, sorry for the inconvenience

This explains the errors into the screenshot that you attached to this thread.
Ubuntu 20.04.5 LTS is shipped with SDL2-2.0.10 and it does not provide enough support for the engine.

@rr-
Copy link
Collaborator

rr- commented Feb 16, 2023

Taking a step back here, @Marcelo20XX what are you trying to accomplish?

Officially we only support Windows as the target platform for now, and the only official toolchain is Docker which should let you compile from either Windows (via WSL) or Linux. People seem to be focusing on helping you build the game natively on Linux, but this will result in a Linux executable. Is this what you want?

Anyhow the errors from the logs in your opening post are quite surprising and I'd focus on addressing these.

@carlo-bramini going forwards I'd welcome a Dockerfile that does a fully static build for Linux. (It could use cmake underneath.) Distros change, packages get outdated and eventually removed and a Docker image would help us futureproof the build system a bit, the same way we've done with the Windows target.

@Marcelo20XX
Copy link
Author

Marcelo20XX commented Feb 19, 2023

No, I originally wanted just to compile the solution for a windows executable, but then I got my first problem, having an installed Windows 10 LTSC without WSL support (due to Microsoft's bug in the version I had, solved on recent builds). Then I tried on Ubuntu 20.04.5 LTS which as per the instructions on the contribution.MD file was the OS that is used for the official way of building and got tons of errors which I posted, then thanks to a suggestion I installed Debian on a virtual machine, used Docker and all my issues disappeared, got the source compiled without any problems and finally got a window's exe for testing changes...

In the end I could compile a Linux and a windows executable, tested the game on both OSes too thanks to @carlo-bramini scripts and detailed instructions...

@walkawayy
Copy link
Collaborator

Great news! Better Linux compatibility is hopefully coming at some point. Is this issue good to close?

@carlo-bramini
Copy link
Contributor

carlo-bramini commented Feb 24, 2023

The engine cannot be compiled with the old packages provided by Ubuntu 20.04.5, unfortunately there is nothing that can be done to bypass this limitation except doing a upgrade by either using apt or the Software Updater tool, which solves the trouble at the root.
With just an #ifdef...#endif, the requirements for SDL2 could be downgraded a bit to version 2.0.14 and I could run the demo under Haiku OS, but actually it was not enough for that version of Ubuntu.
So, also in my opinion this issue may be solved.

@Marcelo20XX
Copy link
Author

Ok I will close the issue as solved because on the latest Ubuntu distro is working...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants