I am a gameplay programmer out of my element here as I am trying to compile the ancient Unreal Engine 3 for macOS. The game builds fine for Windows. The Mac build however is failing to build because the .o files apparently contain dozens of undefined symbols.
The way the build works is like this: I start off with a project in Visual Studio on a Windows machine. On a Mac on the same network, I run a tool that listens for commands on a certain port. I think the important information on the Mac is that it is running macOS 10.15, with Xcode 11 and the command line tools for Xcode 11. On the Windows machine, I start the Mac build, which causes a program called the Unreal Build Tool to copy files to the Mac, and then it sends a very long series of command to the Mac. I think the important parts of the command are
clang++ -c -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.9 -O3
And the command varies a little depending on the file being compiled, but for .cpp files, the command adds
-x c++ -fno-rtti -std=c++11
All of the files appear to compile successfully for several minutes until we get to this point:
Undefined symbols for architecture x86_64:
2> "_SteamGameServer_GetHSteamUser", referenced from:
2> SteamInternal_Init_SteamGameServer(ISteamGameServer**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamGameServerStats(ISteamGameServerStats**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamGameServerNetworking(ISteamNetworking**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> "_SteamInternal_FindOrCreateGameServerInterface", referenced from:
2> SteamInternal_Init_SteamGameServer(ISteamGameServer**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamGameServerStats(ISteamGameServerStats**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamGameServerNetworking(ISteamNetworking**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamGameServerUtils(ISteamUtils**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> "_SteamAPI_GetHSteamUser", referenced from:
2> SteamInternal_Init_SteamApps(ISteamApps**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamInput(ISteamInput**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamUser(ISteamUser**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamFriends(ISteamFriends**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamRemoteStorage(ISteamRemoteStorage**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamUserStats(ISteamUserStats**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> SteamInternal_Init_SteamMatchmakingServers(ISteamMatchmakingServers**) in Unity_VoiceInterfaceSteamworksEtAl.cpp.o
2> ...
There are a lot of lines very similar those.
I tried taking a closer look at the problematic .o file using nm
and dwarfdump
but I wasn't sure what I was looking for. It's a 10-megabyte file. nm
just told me that a bunch of symbols were undefined. I also tried running the build with "-v" added, and it gave me more information about clang and where it was looking for header files, but I wasn't sure if any of that information was useful either.
I have also tried various combinations of other macOS SDKs and minimum macOS versions. I also tried with "-stdlib=libc++" and "-std=c++98" but nothing has gotten me any further.
Because the game builds fine in Windows, I think the source code must be OK, and the problem is just with the Mac configuration. Any idea what I should look at to make sure that the various symbols get defined when the .o file gets built?
Edit: According to the comments, it seems the linker, and not clang, would cause this error. I'm looking at what the build tool runs, and I think this is the linker command.
clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.9 -dead_strip -framework AudioToolbox -framework AudioUnit -framework Cocoa -framework CoreAudio -framework OpenGL -framework IOKit -framework Security -L ../External/PhysX/SDKs/lib/osxstatic/ -L ../External/libogg-1.2.2/macosx/ -L ../External/libvorbis-1.3.2/macosx/ -l ogg
Actually, there are a whole lot of -L and -l entries, like maybe 20-30 of them. And the tool also sets up include paths and "additional shadow files." There was one .dylib file that seemed relevant that didn't look like it was included with the other shadow files. I added it, but that didn't change anything either. Am I looking in the right place here to enter the file that needs to be linked?