OpenRCT2 / OpenRCT2

An open source re-implementation of RollerCoaster Tycoon 2 🎢
https://openrct2.io
GNU General Public License v3.0
13.55k stars 1.56k forks source link

Compiling OpenRCT2 v0.4.3 failed on Rpi2b wth Rasbian #19633

Closed Gothic-Gargoyle closed 8 months ago

Gothic-Gargoyle commented 1 year ago

Operating System

Rasbian Bullseye

OpenRCT2 build

OpenRCT2 0.4.3, develop-ac2afdc

Base game

RollerCoaster Tycoon 2

Area(s) with this issue?

Issues building the game

Describe the issue

When compiling OpenRCT2 as prescribed by the guide on the repo's wiki on the Rpi2b, the build fails when linking the game.

Steps to reproduce

  1. follow steps in OpenRCT2 wiki to build the game
  2. build game
  3. error at 100% when linking the executable, build fails

Attachments

cmake :

pi@pithanc:/srv/openrct2/OpenRCT2/build $ sudo cmake -S .. -B build -DCMAKE_INSTALL_PREFIX=. -DCMAKE_BUILD_TYPE=RelWith
DebInfo                                                                                    
-- Found CCache: /usr/bin/ccache                                                                                       
-- The CXX compiler identification is GNU 10.2.1                                                                       
-- Detecting CXX compiler ABI info                                                                                     
-- Detecting CXX compiler ABI info - done                                                                              
-- Check for working CXX compiler: /usr/bin/c++ - skipped                                                              
-- Detecting CXX compile features                                                                                      
-- Detecting CXX compile features - done                                                                               
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")                                                       
-- IPO supported and enabled in RelWithDebInfo.                                                                        
CMake Warning at cmake/LibFindMacros.cmake:263 (message):                                                              
  WARNING: MISSING PACKAGE                                                                                             

  We could not find development headers for DISCORDRPC.  Do you have the                                               
  necessary dev package installed? This package is NOT REQUIRED and you may                                            
  ignore this warning but by doing so you may miss some functionality of                                               
  openrct2.                                                                                                            

  Relevant CMake configuration variables:                                                                              

    DISCORDRPC_INCLUDE_DIR=<not found>                                                                                 
    DISCORDRPC_LIBRARY=<not found>                                                                                     

  You may use CMake GUI, cmake -D or ccmake to modify the values.  Delete                                              
  CMakeCache.txt to discard all values and force full re-detection if                                                  
  necessary.                                                                                                           

Call Stack (most recent call first):                                                                                   
  cmake/FindDiscordRPC.cmake:25 (libfind_process)                                                                      
  CMakeLists.txt:208 (find_package)                                                                                    

-- Performing Test CXX_WARN_SUGGEST_OVERRIDE                                                                           
-- Performing Test CXX_WARN_SUGGEST_OVERRIDE - Success                                                                 
-- Performing Test CXX_WARN_DUPLICATED_COND                                                                            
-- Performing Test CXX_WARN_DUPLICATED_COND - Success                                                                  
-- Performing Test CXX_WARN_NON_VIRTUAL_DTOR                                                                           
-- Performing Test CXX_WARN_NON_VIRTUAL_DTOR - Success                                                                 
-- Performing Test CXX_WARN_MISSING_VARIABLE_DECLARATIONS                                                              
-- Performing Test CXX_WARN_MISSING_VARIABLE_DECLARATIONS - Failed                                                     
-- Unsupported CXXFLAG: -Wmissing-variable-declarations                                                                
-- Performing Test CXX_WARN_DUPLICATED_BRANCHES                                                                        
-- Performing Test CXX_WARN_DUPLICATED_BRANCHES - Success                                                              
-- Performing Test CXX_WARN_RESTRICT                                                                                   
-- Performing Test CXX_WARN_RESTRICT - Success                                                                         
-- Performing Test CXX_WARN_MISSING_FIELD_INITIALIZERS                                                                 
-- Performing Test CXX_WARN_MISSING_FIELD_INITIALIZERS - Success                                                       
-- Performing Test CXX_WARN_UNREACHABLE_CODE_BREAK                                                                     
-- Performing Test CXX_WARN_UNREACHABLE_CODE_BREAK - Failed                                                            
-- Unsupported CXXFLAG: -Wunreachable-code-break                                                                       
-- Performing Test CXX_WARN_LOGICAL_OP                                                                                 
-- Performing Test CXX_WARN_LOGICAL_OP - Success                                                                       
-- Performing Test CXX_WARN_RANGE_LOOP_ANALYSIS                                                                        
-- Performing Test CXX_WARN_RANGE_LOOP_ANALYSIS - Failed                                                               
-- Unsupported CXXFLAG: -Wrange-loop-analysis                                                                          
-- Performing Test CXX_WARN_TAUTOLOGICAL_ZERO_COMPARE                                                          [0/1976]
-- Performing Test CXX_WARN_TAUTOLOGICAL_ZERO_COMPARE - Failed                                                         
-- Unsupported CXXFLAG: -Wtautological-unsigned-zero-compare                                                           
-- Performing Test CXX_WARN_OLD_STYLE_CAST                                                                             
-- Performing Test CXX_WARN_OLD_STYLE_CAST - Success                                                                   
-- Performing Test CXX_WARN_UNUSED_CONST_VARIABLE                                                                      
-- Performing Test CXX_WARN_UNUSED_CONST_VARIABLE - Success                                                            
-- Performing Test CXX_WNO_CLOBBERED                                                                                   
-- Performing Test CXX_WNO_CLOBBERED - Success                                                                         
-- Performing Test CXX_WARN_REDUNDANT_DECLS                                                                            
-- Performing Test CXX_WARN_REDUNDANT_DECLS - Success                                                                  
-- Performing Test CXX_WARN_NULL_DEREFERENCE                                                                           
-- Performing Test CXX_WARN_NULL_DEREFERENCE - Success                                                                 
-- Performing Test CXX_WARN_IGNORED_QUALIFIERS                                                                         
-- Performing Test CXX_WARN_IGNORED_QUALIFIERS - Success                                                               
-- Performing Test CXX_WARN_STRICT_OVERFLOW                                                                            
-- Performing Test CXX_WARN_STRICT_OVERFLOW - Success                                                                  
-- Found OpenSSL: /usr/lib/arm-linux-gnueabihf/libcrypto.so (found suitable version "1.1.1n", minimum required is "1.0.
0")                                                                                                                    
-- Checking for module 'libcurl'                                                                                       
--   Found libcurl, version 7.74.0                                                                                     
-- Checking for module 'fontconfig'                                                                                    
--   Found fontconfig, version 2.13.1                                                                                  
-- Checking for module 'freetype2'                                                                                     
--   Found freetype2, version 23.4.17                                                                                  
Found Google benchmark, enabling support                                                                               
-- Checking for module 'libzip>=1.0'                                                                                   
--   Found libzip, version 1.7.3                                                                                       
-- Checking for module 'zlib'                                                                                          
--   Found zlib, version 1.2.11                                                                                        
-- Checking for module 'libpng>=1.6'                                                                                   
--   Found libpng, version 1.6.37                                                                                      
-- Looking for C++ include pthread.h                                                                                   
-- Looking for C++ include pthread.h - found                                                                           
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD                                                                             
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed                                                                    
-- Check if compiler accepts -pthread                                                                                  
-- Check if compiler accepts -pthread - no                                                                             
-- Looking for pthread_create in pthreads                                                                              
-- Looking for pthread_create in pthreads - not found                                                                  
-- Looking for pthread_create in pthread                                                                               
-- Looking for pthread_create in pthread - found                                                                       
-- Found Threads: TRUE                                                                                                 
-- Found the following ICU libraries:                                                                                  
--   uc (required)                                                                                                     
-- Found ICU: /usr/include (found suitable version "67.1", minimum required is "59.0")                                 
-- Checking for module 'sdl2'                                                                                          
--   Found sdl2, version 2.0.14                                                                                        
-- Checking for module 'speexdsp'                                                                                      
--   Found speexdsp, version 1.2rc1                                                                                    
-- Checking for module 'flac'                                                                                          
--   Found flac, version 1.3.3                                                                                         
-- Checking for module 'ogg'                                                                                           
--   Found ogg, version 1.3.4                                                                                          
-- Checking for module 'vorbisfile'                                                                                    
--   Found vorbisfile, version 1.3.7                                                                                   
-- Checking for module 'gl'                                                                                            
--   Found gl, version 1.2                                                                                             
-- Configuring done                                                                                                    
-- Generating done                                                                                                     
-- Build files have been written to: /srv/openrct2/OpenRCT2/build/build                                                

error when linking the game:

[100%] Linking CXX executable openrct2                                                                                
/usr/bin/ld: libopenrct2.a(ScriptEngine.cpp.o): in function `std::__atomic_base<unsigned long long>::load(std::memory_
rder) const':                                                                                                         
/usr/include/c++/10/bits/atomic_base.h:426: undefined reference to `__atomic_load_8'                                  
/usr/bin/ld: libopenrct2.a(Context.cpp.o): in function `std::__atomic_base<unsigned long long>::load(std::memory_order
 const':                                                                                                              
/usr/include/c++/10/bits/atomic_base.h:426: undefined reference to `__atomic_load_8'                                  
/usr/bin/ld: libopenrct2.a(Profiling.cpp.o): in function `std::__atomic_base<unsigned long long>::fetch_add(unsigned l
ng long, std::memory_order)':                                                                                         
/usr/include/c++/10/bits/atomic_base.h:548: undefined reference to `__atomic_fetch_add_8'                             
/usr/bin/ld: libopenrct2.a(Profiling.cpp.o): in function `std::__atomic_base<unsigned long long>::store(unsigned long 
ong, std::memory_order)':                                                                                             
/usr/include/c++/10/bits/atomic_base.h:404: undefined reference to `__atomic_store_8'                                 
/usr/bin/ld: libopenrct2.a(Profiling.cpp.o): in function `std::__atomic_base<unsigned long long>::load(std::memory_ord
r) const':                                                                                                            
/usr/include/c++/10/bits/atomic_base.h:426: undefined reference to `__atomic_load_8'                                  
/usr/bin/ld: /usr/include/c++/10/bits/atomic_base.h:426: undefined reference to `__atomic_load_8'                     
/usr/bin/ld: /usr/include/c++/10/bits/atomic_base.h:426: undefined reference to `__atomic_load_8'                     
collect2: error: ld returned 1 exit status                                                                            
gmake[2]: *** [CMakeFiles/openrct2.dir/build.make:1963: openrct2] Error 1                                             
gmake[1]: *** [CMakeFiles/Makefile2:128: CMakeFiles/openrct2.dir/all] Error 2                                         
gmake: *** [Makefile:149: all] Error 2                                                                                
tupaschoal commented 1 year ago

Can you try whether #17146 would have fixed it for you?

Gothic-Gargoyle commented 1 year ago

No, as this was already contained in the commit (develop-ac2afdc) i was trying to build.

I found out i did not have the package latomic installed, so installed that first and tried again,

That did not work, same error as given in bug report.

I found something in a completely unrelated project, they had the same errors so i tried

sudo cmake .. -DCMAKE_SHARED_LINKER_FLAGS=’-latomic’ ` 
make -j4 -latomic

This also did not work, same error as in the bug report. I also tried

sudo cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_SHARED_LINKER_FLAGS=’-latomic’ -D CMAKE_CXX_FLAGS=-latomic

make -j4 -latomic

This also did not work, same error as in the bug report. Any more ideas?

janisozaur commented 1 year ago

Note that #17146 was reverted: https://github.com/OpenRCT2/OpenRCT2/pull/17168 and you have to reapply it manually.

Please report back with #17146 reapplied

janisozaur commented 1 year ago

And don't use sudo for compilation

janisozaur commented 1 year ago

Your attempt to pass additional cmake flags failed because you only provided shared linker flags, whilst you actually compiled a static library. You'd have to provide exe longer flags instead, which #17146 already addresses

Gothic-Gargoyle commented 1 year ago

Note that #17146 was reverted: #17168 and you have to reapply it manually.

Please report back with #17146 reapplied

Adding this back manually on the same line did not fix the issue, instead it caused cmake to fail

Adding it to the end of the file did not do anything, it still gave the same errors.

I also just found out that im on 32bit rasbian 11, is this the reason why it fails?

And don't use sudo for compilation

I do this because i have it in my /srv folder because i intend to host a openrct2 server on this device,

Your attempt to pass additional cmake flags failed because you only provided shared linker flags, whilst you actually compiled a static library. You'd have to provide exe longer flags instead, which https://github.com/OpenRCT2/OpenRCT2/pull/17146 already addresses

i am not too familiar with building without IDEs, this is the first time, apart from compiling openttd, thanks for the info!

Gothic-Gargoyle commented 1 year ago

Managed to build with

sudo cmake .. -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang 
sudo make -j4  

it seems it cant be built on rasbian with gcc, but it can be done with clang, maybe add this to the wiki?

janisozaur commented 1 year ago

I do this because i have it in my /srv folder because i intend to host a openrct2 server on this device,

This is even worse than just compiling it as root for local use. Don't.

You haven't posted the cmake error you got.

tupaschoal commented 1 year ago

Aside from providing the cmake error, can you share what are your clang and GCC versions?

janisozaur commented 1 year ago

http://archive.raspbian.org/multiarch/dists/bullseye/main/binary-arm64/Packages.xz claims it is clang 10 and GCC 10.2, corroborated by cmake output in the opening post.

Gothic-Gargoyle commented 1 year ago

I do this because i have it in my /srv folder because i intend to host a openrct2 server on this device,

This is even worse than just compiling it as root for local use. Don't.

You haven't posted the cmake error you got.

Cmake error is:

CMake Error at CMakeLists.txt:278 (target_link_libraries):                  
  Cannot specify link libraries for target "openrct2" which is not built by 
  this project.                                                             

Aside from providing the cmake error, can you share what are your clang and GCC versions?

Clang

Raspbian clang version 11.0.1-2+rpi1  
Target: armv6k-unknown-linux-gnueabihf
Thread model: posix                   
InstalledDir: /usr/bin                

GCC:

gcc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110                               
Copyright (C) 2020 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.
Gymnasiast commented 8 months ago

@Gothic-Gargoyle Is this still an issue?

Gothic-Gargoyle commented 8 months ago

I have since switched homeservers so i wouldnt know, i think that it can be closed.

Gymnasiast commented 8 months ago

Very well then, if you run into this issue again, feel free to open a new one.