More Mac Linker Errors

I never figured out my last linker problem on the Mac, but I’m experiencing a similar, but different one now. I have a class - subclass of [FONT=Courier New]ACharacter - that works fine, until I try to add this function

FString AEnemyCharacter::AlertStatusString()

    EEnemyAlertStatus::Type AlertStatus = GetAlertStatus();
    return GetNameForAlertStatus(AlertStatus);

The actual contents of the function don’t seem to matter - I replaced it with [FONT=Courier New]return TEXT(“Test”); and I got the same error.

Actually adding the member function to the .cpp file doesn’t trigger the error. It’s not until I add the declaration to the .h file that it stops building.

    /** Returns a string representing the character's current alert status */
    UFUNCTION(BlueprintCallable, Category=Alertness)
    FString AlertStatusString();

The error I’m getting is:

xternalBuildToolExecution RepublicSniperAIEditor\ -\ Mac
    cd /Users/Shared/UnrealEngine/4.4
    export ACTION=
    /Users/Shared/UnrealEngine/4.4/Engine/Build/BatchFiles/Mac/ RepublicSniperAIEditor macosx DebugGame /Users/jeff/Dropbox\ (MartianCraft)/RepublicSniperAI/RepublicSniperAI.uproject

Building RepublicSniperAIEditor...
Compiling with Mac SDK 10.9
Parsing headers for RepublicSniperAIEditor
Reflection code generation finished for RepublicSniperAIEditor and took 3.721
Performing 8 actions (max 8 parallel jobs)
[3/8] Compile EnemyCharacter.cpp
[4/8] Compile RepublicSniperAI.generated.cpp
[5/8] Compile BaseNPCCharacter.cpp
[6/8] Compile FriendController.cpp
[2/8] Compile EnemyController.cpp
[7/8] Compile FriendCharacter.cpp
[1/8] Compile BaseNPCController.cpp
[8/8] Link UE4Editor-RepublicSniperAI-Mac-DebugGame.dylib
Undefined symbols for architecture x86_64:
  "AEnemyCharacter::AlertStatusString()", referenced from:
      AEnemyCharacter::execAlertStatusString(FFrame&, void*) in RepublicSniperAI.generated.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-------- End Detailed Actions Stats -----------------------------------------------------------
ERROR: UBT ERROR: Failed to produce item: /Users/jeff/Dropbox (MartianCraft)/RepublicSniperAI/Binaries/Mac/UE4Editor-RepublicSniperAI-Mac-DebugGame.dylib
Cumulative action seconds (8 processors): 0.00 building projects, 37.33 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.12 linking, 0.00 other
UBT execution time: 13.22 seconds
Command /Users/Shared/UnrealEngine/4.4/Engine/Build/BatchFiles/Mac/ failed with exit code 2

I suspect that the problem may actually be somewhere else and not in this method (despite the fact that it compiles successfully without this one method). Here’s the entire class along with its superclass (which descends from [FONT=Courier New]ACharacter):

I’m pulling my hair out over this - been stuck in my track for several days, so if anyone can help me figure out what boneheaded thing I’m doing, I’d very much appreciate it.

I’ve also asked on AnswerHub, and have put the entire project in the answer if anyone wants to just download it and try it out:

AnswerHub question:

Entire project for download (Warning - 750 megs):

Thank you!

So I downloaded your project and after porting it to VS2013 by removing pragmas and some constants; I hate to tell you… But it compiles.

Sorry don’t have a Mac that can run UE4.

My best guess is the same as before - some sort of environmental configuration.

Hopefully someone on a Mac can help you out.

EDIT: Thought I’d double check and noticed your download didn’t contain the changes you’re having issues with. Added them in and it compiles.

Come to the dark side and use a PC :mad: (In case anyone is wondering this is a joke, this should work on a Mac)

Yeah, I went through that same process on my game machine at home last night. Had to change a few things - the assignments of NULL to FName variables, and had to get rid of the #pragmas, but yeah, it works, though I did get the a linker error trying to subclass [FONT=Courier New]PostInitializeComponents(). It’s not the same error, exactly, that I saw on the Mac, but it still didn’t seem to like it.

I really appreciate you looking at it, though.

Honestly, I don’t think there’s a lot of people yet using UE4 on the Mac with C++. Most of the questions that I’ve asked in the forums that had a Mac-specific element have had few or no responses. I think you’re right that it’s either an environment variable or compiler/linker flag, but I don’t know how to chase it down, which is frustrating. :frowning:

Eh, the bulk of our work is iOS and Mac contracting work, and our current game project is for iOS (first, at least). Most of the projects I’m responsible for have to be developed on Macs. And while I don’t mind booting into Windows to play games, I’m just a lot more efficient working on a Mac. Years of muscle memory, several of the programs I use regularly are Mac only, plus I use the command line a lot. Cygwin helps some, but not enough. :slight_smile:

I do have a bootcamp partition on my work machine. Unreal doesn’t seem to work on it for some reason and I haven’t been able to spend the time to figure out why. I may invest some time in it now that 4.5 seems to have fully restored the ability to generate iOS games from Windows, though.

Heh heh heh. One of my developers figured it out today. I thought I’d share on the off chance somebody else runs into this rather odd error.

Somehow, the .cpp class got duplicated so there was a copy of [FONT=Courier New]AEnemyCharacter.cpp in /private and one in /public, I didn’t notice that there was a second copy. I’m not sure why Rocket gave that particular error instead of something more sane (duplicate symbol, perhaps??), but the important thing is that it seems to work now and all is well in the world.

Thanks again for looking at it.

Great to hear :slight_smile: