OpenSWE1R / openswe1r

An Open-Source port of the 1999 Game "Star Wars Episode 1: Racer"
https://openswe1r.github.io/
GNU General Public License v2.0
312 stars 26 forks source link

Build failure on Mac OS 10.13.6 #180

Closed Thom1729 closed 4 years ago

Thom1729 commented 5 years ago

I couldn't successfully build the project on Mac OS 10.13.6. Please let me know if any other information would help.

$ cmake ..
-- The C compiler identification is AppleClang 10.0.0.10001044
-- The CXX compiler identification is AppleClang 10.0.0.10001044
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ENet: /usr/local/lib/libenet.dylib  
-- Found unicorn: /usr/local/lib/libunicorn.dylib  
-- Found OpenGL: /System/Library/Frameworks/OpenGL.framework   
-- Found GLEW: /usr/local/lib/cmake/glew/glew-config.cmake  
-- Found SDL2: /usr/local/lib/libSDL2main.a;/usr/local/lib/libSDL2.dylib;-framework Cocoa  
-- Found OpenAL: /System/Library/Frameworks/OpenAL.framework  
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/thom/Desktop/Racer/openswe1r/build
$ make
[ 11%] Generating .generated, app_version.h
Scanning dependencies of target openswe1r
[ 11%] Generating .generated, app_version.h
[ 22%] Building C object CMakeFiles/openswe1r.dir/main.c.o
/Users/thom/Desktop/Racer/openswe1r/main.c:270:35: warning: format specifies type 'unsigned long long' but the argument has type
      'Uint32' (aka 'unsigned int') [-Wformat]
  printf("Time is %" PRIu64 "\n", SDL_GetTicks());
                  ~~~             ^~~~~~~~~~~~~~
/Users/thom/Desktop/Racer/openswe1r/main.c:880:37: warning: format string is not a string literal (potentially insecure)
      [-Wformat-security]
      count += sprintf(&out[count], in); // Copy rest of the input to output
                                    ^~
/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
/Users/thom/Desktop/Racer/openswe1r/main.c:880:37: note: treat the string as an argument to avoid this
      count += sprintf(&out[count], in); // Copy rest of the input to output
                                    ^
                                    "%s", 
/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^
/Users/thom/Desktop/Racer/openswe1r/main.c:2093:70: warning: format specifies type 'int' but the argument has type 'unsigned long'
      [-Wformat]
  printf("halCaps is %d bytes (known: %d bytes)\n", halCaps->dwSize, sizeof(API(DDCAPS)));
                                      ~~                             ^~~~~~~~~~~~~~~~~~~
                                      %lu
/Users/thom/Desktop/Racer/openswe1r/main.c:3758:28: warning: 'memset' call operates on objects of type 'Exe' while the size is based
      on a different type 'Exe *' [-Wsizeof-pointer-memaccess]
  memset(exe, 0x00, sizeof(exe));
         ~~~               ^~~
/Users/thom/Desktop/Racer/openswe1r/main.c:3758:28: note: did you mean to dereference the argument to 'sizeof' (and multiply it by the
      number of elements)?
  memset(exe, 0x00, sizeof(exe));
                           ^~~
4 warnings generated.
[ 33%] Building C object CMakeFiles/openswe1r.dir/emulation.c.o
/Users/thom/Desktop/Racer/openswe1r/emulation.c:77:53: warning: pointer type mismatch ('uc_err (*)(uc_engine *, int, const void *)'
      (aka 'enum uc_err (*)(struct uc_struct *, int, const void *)') and 'uc_err (*)(uc_engine *, int, void *)' (aka 'enum uc_err
      (*)(struct uc_struct *, int, void *)')) [-Wpointer-type-mismatch]
  uc_err(*transfer)(uc_engine*, int, void*) = write ? uc_reg_write : uc_reg_read;
                                                    ^ ~~~~~~~~~~~~   ~~~~~~~~~~~
/Users/thom/Desktop/Racer/openswe1r/emulation.c:170:153: warning: format specifies type 'unsigned long long' but the argument has type
      'Uint32' (aka 'unsigned int') [-Wformat]
  ...0x%X (ESP: 0x%X); eax = 0x%08" PRIX32 " esi = 0x%08" PRIX32 " (TS: %" PRIu64 ")\n", id++, eip, esp, eax, esi, SDL_GetTicks());
                                                                        ~~~                                        ^~~~~~~~~~~~~~
/Users/thom/Desktop/Racer/openswe1r/emulation.c:565:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
3 warnings generated.
[ 44%] Building C object CMakeFiles/openswe1r.dir/export.c.o
/Users/thom/Desktop/Racer/openswe1r/export.c:18:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/Users/thom/Desktop/Racer/openswe1r/export.c:21:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/Users/thom/Desktop/Racer/openswe1r/export.c:24:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
3 warnings generated.
[ 55%] Building C object CMakeFiles/openswe1r.dir/shader.c.o
[ 66%] Building C object CMakeFiles/openswe1r.dir/dll/kernel32.c.o
[ 77%] Building C object CMakeFiles/openswe1r.dir/com/a3d.c.o
[ 88%] Building C object CMakeFiles/openswe1r.dir/com/dplay.c.o
[100%] Linking C executable openswe1r
ld: warning: text-based stub file /System/Library/Frameworks//OpenGL.framework/OpenGL.tbd and library file /System/Library/Frameworks//OpenGL.framework/OpenGL are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//OpenGL.framework/OpenGL.tbd and library file /System/Library/Frameworks//OpenGL.framework/OpenGL are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//Cocoa.framework/Cocoa.tbd and library file /System/Library/Frameworks//Cocoa.framework/Cocoa are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.tbd and library file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.tbd and library file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//AppKit.framework/Versions/C/AppKit.tbd and library file /System/Library/Frameworks//AppKit.framework/Versions/C/AppKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation.tbd and library file /System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//ApplicationServices.framework/Versions/A/ApplicationServices.tbd and library file /System/Library/Frameworks//ApplicationServices.framework/Versions/A/ApplicationServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//Foundation.framework/Versions/C/Foundation.tbd and library file /System/Library/Frameworks//Foundation.framework/Versions/C/Foundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreGraphics.framework/Versions/A/CoreGraphics.tbd and library file /System/Library/Frameworks//CoreGraphics.framework/Versions/A/CoreGraphics are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreText.framework/Versions/A/CoreText.tbd and library file /System/Library/Frameworks//CoreText.framework/Versions/A/CoreText are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//ImageIO.framework/Versions/A/ImageIO.tbd and library file /System/Library/Frameworks//ImageIO.framework/Versions/A/ImageIO are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS.tbd and library file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreServices.framework/Versions/A/CoreServices.tbd and library file /System/Library/Frameworks//CoreServices.framework/Versions/A/CoreServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices.tbd and library file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis.tbd and library file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CFNetwork.framework/Versions/A/CFNetwork.tbd and library file /System/Library/Frameworks//CFNetwork.framework/Versions/A/CFNetwork are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList are out of sync. Falling back to library file for linking.
Undefined symbols for architecture x86_64:
  "___glewActiveTexture", referenced from:
      _Hook_IDirect3DDevice3__38 in main.c.o
  "___glewAttachShader", referenced from:
      _CreateShaderProgram in shader.c.o
  "___glewBindBuffer", referenced from:
      _LoadVertices in main.c.o
      _LoadIndices in main.c.o
  "___glewBindVertexArray", referenced from:
      _main in main.c.o
  "___glewBufferData", referenced from:
      _LoadVertices in main.c.o
      _LoadIndices in main.c.o
  "___glewClearDepthf", referenced from:
      _Hook_IDirectDrawSurface4__5 in main.c.o
  "___glewCompileShader", referenced from:
      _CreateShader in shader.c.o
  "___glewCreateProgram", referenced from:
      _CreateShaderProgram in shader.c.o
  "___glewCreateShader", referenced from:
      _CreateShader in shader.c.o
  "___glewEnableVertexAttribArray", referenced from:
      _SetupRenderer in main.c.o
  "___glewGenBuffers", referenced from:
      _LoadVertices in main.c.o
      _LoadIndices in main.c.o
  "___glewGenVertexArrays", referenced from:
      _main in main.c.o
  "___glewGetAttribLocation", referenced from:
      _SetupRenderer in main.c.o
  "___glewGetProgramInfoLog", referenced from:
      _PrintShaderProgramLog in shader.c.o
  "___glewGetProgramiv", referenced from:
      _PrintShaderProgramLog in shader.c.o
      _LinkShaderProgram in shader.c.o
  "___glewGetShaderInfoLog", referenced from:
      _PrintShaderLog in shader.c.o
  "___glewGetShaderiv", referenced from:
      _PrintShaderLog in shader.c.o
  "___glewGetUniformLocation", referenced from:
      _SetupRenderer in main.c.o
  "___glewLinkProgram", referenced from:
      _LinkShaderProgram in shader.c.o
  "___glewShaderSource", referenced from:
      _CreateShader in shader.c.o
  "___glewUniform1f", referenced from:
      _SetupRenderer in main.c.o
  "___glewUniform1i", referenced from:
      _SetupRenderer in main.c.o
  "___glewUniform3f", referenced from:
      _SetupRenderer in main.c.o
  "___glewUniform3fv", referenced from:
      _SetupRenderer in main.c.o
  "___glewUniformMatrix4fv", referenced from:
      _SetupRenderer in main.c.o
  "___glewUseProgram", referenced from:
      _main in main.c.o
  "___glewVertexAttribPointer", referenced from:
      _SetupRenderer in main.c.o
  "_glewExperimental", referenced from:
      _main in main.c.o
  "_glewGetErrorString", referenced from:
      _main in main.c.o
  "_glewInit", referenced from:
      _main in main.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [openswe1r] Error 1
make[1]: *** [CMakeFiles/openswe1r.dir/all] Error 2
make: *** [all] Error 2
JayFoxRox commented 5 years ago

This is weird - and it doesn't seem to be an issue with OpenSWE1R (as you can safely ignore the warnings).

It appears to be an issue with how your CMake / GLEW are configured. CMake seems to find GLEW, but probably doesn't set the right variables / paths, so the linker fails.

Thom1729 commented 5 years ago

I followed the build instructions, installing from brew:

brew install cmake
brew install sdl2 unicorn glew openal-soft enet

Here's my complete brew list --versions:

cabextract 1.9.1
cmake 3.15.1
coreutils 8.30
enet 1.3.14
gdbm 1.18.1
glew 2.1.0
icu4c 63.1
ncurses 6.1
node 11.10.0
openal-soft 1.19.1
openssl 1.0.2q
p7zip 16.02_1
python 3.7.2
readline 7.0.5
sdl2 2.0.9_1
sqlite 3.26.0
unicorn 1.0.1
unrar 5.7.5
wine 4.0.1
winetricks 20190615
xz 5.2.4
zsh 5.6.2_1

I've verified that the cmake I ran is the brew version. I also tried running the brew version of gmake, with the same result.

JayFoxRox commented 5 years ago

I've looked into it.

Starting in CMake 3.15, the GLEW handling was updated. It now prefers the cmake config that ships with GLEW.

I consider this problematic, because the GLEW config is not compatible with old CMake versions / configurations; it only has the import target.

Note how the standard / legacy CMake variables are gone.


The solution will be to change OpenSWE1R to import targets, away from legacy result variables.

Last time I intended to do this, I had reports that this wasn't in all distributions yet because of older CMake versions. Support for GLEW::GLEW was added in 2014 - however, we already target CMake 3.1 anyway, and the import targets remained stable.