Compiled C++ code does not execute

We’re using 4.11.2 and I’m seeing something so odd that I can’t explain how it could happen, but I suspect its some issue with UBT setup for our project.

I’ve got a plugin with C++ source code in it that defines a new component. That component declares a TickComponent function, within which I make a number of calls to other functions to do time-based updates for decaying values etc.

Anyway, my issue is that although the TickComponent function is run, the other functions do not seem to get called from within the TickComponent function. If I add a breakpoint in visual studio in TickComponent it does break, but if I try and step into the other functions, the debugger simply ignores those lines.

Normally I’d attribute that kind of behaviour to a mismatch between the pdb and the code, but I’ve cleaned the build and intermediate directories and rebuilt the plugin’s DLL and see no difference.

I’ve checked the module loading in visual studio’s debugger and it does appear that the correct PDB is loaded for the appropriate DLL, so it must be something to do with how the build or link steps are setup.

So can anyone enlighten me as to what might be affecting this build?

Ta,

Phil.

Hey -

Can you provide the setup for the plugin you’re using? Type of plugin (Blank, toolbar button, etc.) as well as header/source file setup? Please provide as much information as possible to help me replicate this issue on my machine.

Hey ,

Its one of the ones generated from the plugin generator, its got a menu and a toolbar button although I don’t use those yet.

One thing I did notice is that some of the variables are optimized away, which seems weird given the game is being built for DebugGame Editor, which suggests that maybe the plugin is being compiled with a different build config than the main game source? Is there a place I can check what configuration the plugin is being built for? It does say its the debug dll when it loads the dll and pdb.

I’ll throw the same code into a fresh project and see what happens, I’ve not actually done much with the plugin itself, just added a few classes for the main game to implement as components. Not had a problem until a specific component was added and I started noticing strange behavior (the slate UI won’t render part of the fields for the UPROPERTIES that one of the components is derived from).

To help me reproduce the issue you’re seeing can you provide any details about the plugin? Which one specifically was used as the template? What classes/variables have been added? Also let me know if copying the setup you have into a new project gives the same result for you.

So I shifted the plugin with just a single class to a different project and it runs fine. So I suspect there’s something in the build setup that’s causing the issue I’m seeing.

Can you point me to some in-depth info on how the plugin DLL’s are built against the main project when specified as debuggame engine? Might be an issue with Unity builds I guess. I do recall seeing some warning about optimisation flags, so perhaps one of the build settings enabled optimization for the plugin DLL?

Hey ,

I’ve noticed I’m getting this line when compiling the main game project:

[Adaptive unity build] Excluded from TacticalAI unity file: AITacticalPerceptionComponent.cpp

Which suggests that something is specifically happening with that file (which is the file I’m having a problem with in debug), any info on what causes this exclusion and if there’s a way to change that?

To help me reproduce the issue you’re seeing can you provide any details about the plugin and the AITacticalPerceptionComponent class? What template did you base the plugin on? What exactly has been added besides the default boilerplate code? If possible, please include the source code for the plugin. Also let me know if you are able to copy the plugin into a new 4.12 project and if the code does/does not execute.

? are you feeling ok? Did you what I posted above? I shifted the plugin code with the offending file to another project and it compiled and ran as expected.

I’m just trying out a build with unity builds switched off. I also noticed there was a warning about that file when being compiled about optimisations:

7>D:\Ground Branch\GroundBranch\Plugins\TacticalAI\Source\TacticalAI\Private\Perception\AITacticalPerceptionComponent.cpp : warning C4653: compiler option ‘Optimizations (one or more of /Oawstgp[y]) or debug checks (one or more of /GZ, /RTCcsu)’ inconsistent with precompiled header; current command-line option ignored

If this unity build doesn’t change things, I’ll probably see if I can determine what compiler flags are passed to the compiler during the compile step and see if there’s anything different.

I’m still not clear on exactly what it is you’re doing. If you can provide information to help me understand how you’re getting to the point you’re at, I can then investigate the issue and possibly find a workaround or solution. Without knowing how your plugin is setup or the other code you’re using or what exactly you’re doing, I’m not sure I can provide any actionable solutions.

If you would like advice on how to create your plugin or would like help learning more about plugins, I would suggest creating a question in the C++ section or on our Forums. When it comes to the bug report section, we need to work on getting a reproduction case so that the issue can be escalated and looked into. Unless we can get something concrete, I’m afraid we won’t be able to continue in this fashion.

I understand that , the problem is that when I moved the plugin code to a new project the issue went away, so right now I’m trying to find a way to reproduce the issue. If i can’t narrow it down I’ll just send you the plugin code to see if you can reproduce it.

As for the steps I took to get here, they are long and arduous so I don’t want to have you do that until I know why the issue is occurring or what is actually having an effect on it.

Just a quick update on this. I added the line:

OptimizeCode = CodeOptimization.Never;

To my plugin modules .build.cs file and the code acts as expected now. So it was definitely building the specific code file with a different optimisation setting. So I guess I’ll dig into what affects that situation to determine why it was this specific file. Will update with more information once I’ve found it.

Hey -

It sounds like you were able to get your code to trigger again. Were you able to find any additional information outside of the line of code added? If you are no longer experiencing this problem, I will be marking this as resolved for tracking purposes. Feel free to add a comment to reopen if this is still an issue for you.

Hey ,

Unfortunately I can’t find an exact reproduction case for it outside our project (which is big code-wise). I suspect its an edge case for some particular setup of the build system. Without any more in-depth help or information about how the build system functions I can’t really see a way to try and get to the bottom of a repro case.

Its the kind of thing that would probably take 5 minutes to track down if I could talk to the guy who wrote the build system, but trying to find the cause “in the dark” so to speak isn’t going to do anything other than waste a lot of our time.

Feel free to close the bug and I’ll chalk it up to experience :slight_smile:

I had the same problem in my current project. I have a very simple SceneComponent that scales up his AttachParent. The tick function of the component was almost all optimized out except the call to Super::TickComponent. I put the CodeOptimization.Never and now it works fine. I couldn’t find what was causing the code to be removed during the build though.

Well, I have some more information on this:
I have an existing project that is on github <-This would be the issue?

I added some .h and .cpp files, which nets me:
Excluded from VaOceanPlugin unity file: VaOceanBuoyancyComponent.cpp, VaOceanStateActor.cpp, VaOceanStateActorSimple.cpp

I would assume, once I commit those files to my repo, this would go away, but I won’t commit them while I’m still working on them…

While its nice, that UE4 does not “unity” this into the project until committed (for iteration recompile speed reasons) it did cause an compile error in another project.

Simple answer: Commit to your repo, and try again?