Skip to content

Project build system errors. Problems, notes, requests. #1736

Open
@f9x0

Description

@f9x0

Godot version

godot 4.4

godot-cpp version

godot-cpp 4.4

System information

windows 10 x64

Issue description

Hello. I'll note right away that I'm not a professional C++ developer. I have to use C++, I don't have enough performance of GDscript\C#(Godot).
My toolchain: clang + cmake + ninja and clang + scons.
I'll probably test MSVC\MinGW in the future.

Result godot-cpp 4.4:
scons -j4 platform=windows

register_types.windows.template_debug.x86_64.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl godot::MyNode2D::_bind_methods(void)" (?_bind_methods@MyNode2D@godot@@KAXXZ) referenced in function "private: static void __cdecl godot::ClassDB::_register_class<class godot::MyNode2D,0>(bool,bool,bool)" (??$_register_class@VMyNode2D@godot@@$0A@@ClassDB@godot@@CAX_N00@Z)
register_types.windows.template_debug.x86_64.obj : error LNK2019: unresolved external symbol "public: __cdecl godot::MyNode2D::MyNode2D(void)" (??0MyNode2D@godot@@qeaa@XZ) referenced in function "private: static void * __cdecl godot::ClassDB::_create_instance_func(void *,unsigned char)" (??$_create_instance_func@VMyNode2D@godot@@@ClassDB@godot@@CAPEAXPEAXE@Z)
demo\bin\libgdexample.windows.template_debug.x86_64.dll : fatal error LNK1120: 2 unresolved externals

I encountered this error in cmake . Version godot-cpp 4.3
Solution.

target_compile_definitions(${PROJECT_NAME} PUBLIC
$<$CONFIG:Debug:
DEBUG_ENABLED
DEBUG_METHODS_ENABLED
>
TYPED_METHOD_BIND
)

I don't know how to fix this in godot-cpp 4.4 scons.

Why did I decide to try scons?
I was very tired of cmake breaking and thought it would be better.
Previously, I chose cmake because.
For me, scons took 20-30% longer to build.
4-5 sec vs 7-9 sec. Rebuild.
Now scons didn't build at all.
When I tried to google additional flags.
Scons decided to rebuild everything and I left it. I was tired like a blind kitten picking up library build flags.

Cmake. I compiled it in two ways. A separate library + my cmake for the project.
And including godot-cpp as an additional dependency.
I got different errors. Runtime conflicts. Incorrect std++ library, its name is broken.

windows.cmake
option( GODOTCPP_DEBUG_CRT "Compile with MSVC's debug CRT (/MDd)" OFF )
Is this really necessary? I built it in debug mode.
Which conflicted with the main runtime. A strange default setting or my stupidity.

Cmake cache clearly showed that the hot reload option was not set.
Had to set it manually.
Additionally.
set_target_properties(
${PROJECT_NAME}
PROPERTIES
COMPILE_DEFINITIONS HOT_RELOAD_ENABLED
)

My lines in cmake. So that this function would work as a separate cmake project.
Previously, I spent hours to understand how to run this. By github + commit + changes.
I want to see such things in a normal wiki!

godot-cpp 4.4 --target godot-cpp.template_debug
lld-link: error: /failifmismatch: mismatch detected for '_ITERATOR_DEBUG_LEVEL':

CMakeFiles/re.dir/src/register_types.cpp.obj has value 2
libgodot-cpp.windows.template_debug.x86_64.lib(array.cpp.obj) has value 0

Other minor inconsistencies. Which are poorly documented.
In godot-cpp 4.3 I had 2 failures.
HOT_RELOAD_ENABLED
TYPED_METHOD_BIND
And only when I created the library and used it manually.

godot-cpp 4.4 did not build anything.
I spent many hours and the best I got.
cmake -GNinja -Bbuild/debug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug -DGODOTCPP_USE_HOT_RELOAD=ON -DGODOTCPP_DEBUG_CRT=ON

lld-link: warning: section name .debug_abbrev is longer than 8 characters and will use a non-standard string table
lld-link: warning: section name .debug_info is longer than 8 characters and will use a non-standard string table
lld-link: warning: section name .debug_line is longer than 8 characters and will use a non-standard string table
lld-link: warning: section name .debug_ranges is longer than 8 characters and will use a non-standard string table
lld-link: warning: section name .debug_str is longer than 8 characters and will use a non-standard string table

Sorry for the long message. I'm trying to convey that it might be hard for a newbie. Getting started quickly is important!
The second issue that has already been raised.
Building godot-cpp separately. I dream of building godot-cpp with 1 command and connecting it to my cmake with one line.
Like in SDL3\EnTT\flecs\SFML\DXTK\Love2D ect. I can just do it, I don't need additional knowledge inside their cmake. Rarely do I need to configure flags that the docs have.
Why is this important to me? I develop games. I have many projects. I figure out the details of C++ Godot or test ideas. Sometimes I connect other languages. When I am asked to build godot-cpp every time, I feel sad. 20-30 minutes (on average and depends on CPU load).
I also need a release version to check performance. Why? I am ready to guarantee the same env toolchain. For one version, for example, godot 4.4.
Probably it is even possible to create it at the level of github actions.
Why can rust-godot provide ready-made artifacts, but godot-cpp not? Or a normal way of organizing this function. Development is one thing, in the release I can assemble everything as it should be.
Documentation is really lacking.
I also don't know. Can I somehow get documentation for all godot-cpp? It would also be better to integrate this into clangd.
A little off topic. Maybe cmake should not try to make it closer to scons?
Maybe make different build options? scons. cmake all in one. cmake light version, assemble and get artifacts. I understand this is a lot of work. I am not qualified to help here, perhaps documentation of your difficulties.
But it seems to me that this is a basic need. To start quickly.
I spend more time on assembling and organizing the project than writing the functionality. And I want to spend less time on creating when, that's why I want Ninja + Cmake + other tool.

Steps to reproduce

build project scons windows clang + bind method.

Minimal reproduction project

"N/A"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions