Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Log: ObjectFactorySystem::AddConstructors() called with no constructors #122

Open
vermaayu opened this issue May 12, 2021 · 3 comments
Labels

Comments

@vermaayu
Copy link

vermaayu commented May 12, 2021

HI. I have been following the tutorial and GLFW/ImGui example files to integrate RCC++ into my game engine (ImGui, GLFW). Everything is linked using CMake and it compiles.
I keep getting this Log:
ObjectFactorySystem::AddConstructors() called with no constructors in the console. Following this, the IObjectConstructor* array constructors in ObjectFactorySystem is empty and I couldn't understand how and where to populate it.
Also I went through the ConsoleExample and the ConsoleGame.cpp has IObjectConstructor* pCtor = m_pRuntimeObjectSystem->GetObjectFactorySystem()->GetConstructor( "RuntimeObject01" ); which I assumed had something to do with the error but it didn't help either.
Please help me out as this has become really confusing for me.

What I am trying to achieve is to add a run time scripting system where the user creates a script from the engine and codes into it, and it compiles real-time. I need to add the source files to the compile stream and have changes reflected in the engine according to the code because the script cannot be a part of the project as they don't exist before.
Any advice on this would be appreciated as well.

@dougbinks
Copy link
Collaborator

This isn't the intended way of using RCC++, which is designed for changing your own code at runtime. It is possible, but it's an advanced use case.

You need to use m_pRuntimeObjectSystem->AddToRuntimeFileList( filename, projectId );.

I think you will also need to set off the first compile after adding a file. I would use a different projectId (default is 0) to your main code so you can recompile only that code if needed and set options for that project separately.

Since the file doesn't exist to start with, RCC++ won't have a pre-compiled set of information about the libraries, includes etc. which this file uses. If the user writes their code by first adding the correct library and includes as per RCC++ before writing any code this should work, but you may want to make sure they always include a header which has the correct includes in it to work well.

One issue for using RCC++ this way is that the scripting system will always need to recompile the source code every run, though it you do not delete the temporary files this should be fairly fast.

I am considering adding improved support for scripting with RCC++ at some point, but currently do not have the time.

@vermaayu
Copy link
Author

vermaayu commented May 13, 2021

Thanks for the suggestion. I'll try to implement that.
But before I do that, the problem at hand right now is the program is not able to find RCCppMainloop.cpp as given in step 3 of the tutorial. It keeps on returning ObjectFactorySystem::AddConstructors() called with no constructors in the console along with Found Directory Maps. I have the file, RCCppMainloop.cpp, in the directory.
RCCppInit()

bool dag::EditorUILayer::RCCppInit()
{
    g_SystemTable.pRuntimeObjectSystem = new RuntimeObjectSystem;
    g_SystemTable.pLogger = &g_Logger;
    if (!g_SystemTable.pRuntimeObjectSystem->Initialise(&g_Logger, &g_SystemTable))
    {
        delete g_SystemTable.pRuntimeObjectSystem;
        g_SystemTable.pRuntimeObjectSystem = NULL;
        return false;
    }

     g_SystemTable.pRuntimeObjectSystem->CleanObjectFiles();
#ifndef _WIN32
    g_SystemTable.pRuntimeObjectSystem->SetAdditionalCompileOptions("-std=c++11");
#endif

    return true;
}

I have the program compiling and running. What might be causing this?

@dougbinks
Copy link
Collaborator

Have you first tried compiling the full example:
https://github.com/juliettef/RCCpp-DearImGui-GLFW-example

If this works then check for differences in logic or build (cmake) settings.

My initial thought is that you don't have RCCppMainloop.cpp in your CMakeLists.txt as per:
https://github.com/juliettef/RCCpp-DearImGui-GLFW-example/blob/main/CMakeLists.txt#L51-L52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants