godot-cpp
godot-cpp copied to clipboard
Couldn't read OBJ file, it seems to be binary, corrupted, or empty
Godot version
v4.2.1.stable.official [b09f793f5]
godot-cpp version
78ffea5b136f3178c31cddb28f6b963ceaa89420 (HEAD, tag: godot-4.2.1-stable, origin/4.2, 4.2)
System information
Windows 11
Issue description
This is mostly likely an issue in my config/setup, but I couldn't find this error anywhere across google/reported issues, so thought it might be helpful to log any likely causes/suggested debugging steps for others who may encounter in the future.
I'm following the GDExtension tutorial, successfully built godot-cpp & the example cpp code. When opening my project I get the following errors:
Couldn't read OBJ file 'res://src/gdexample.windows.template_debug.x86_64.obj', it seems to be binary, corrupted, or empty.
editor/import/resource_importer_obj.cpp:572 - Condition "err != OK" is true. Returning: err
Error importing 'res://src/gdexample.windows.template_debug.x86_64.obj'.
Couldn't read OBJ file 'res://src/register_types.windows.template_debug.x86_64.obj', it seems to be binary, corrupted, or empty.
editor/import/resource_importer_obj.cpp:572 - Condition "err != OK" is true. Returning: err
Steps to reproduce
- Run
scons platform=windows custom_api_file=../extension_api.jsoninside godot-cpp - Run
scons platform=windows - Close Godot and re-open
My SConstruct file at the root
#!/usr/bin/env python
import os
import sys
env = SConscript("godot-cpp/SConstruct")
env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")
if env["platform"] == "macos":
library = env.SharedLibrary(
"bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary(
"bin/libgdexample{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
Default(library)
Minimal reproduction project
Attached is the contents of bin/:
gdexample.gdextensionlibgdexample.windows.template_debug.x86_64.dlllibgdexample.windows.template_debug.x86_64.explibgdexample.windows.template_debug.x86_64.lib
And the two obj files in src/
gdexample.windows.template_debug.x86_64.objregister_types.windows.template_debug.x86_64.obj
You need to add a .gdignore file with the source files, otherwise these files will be treated as mesh files, this is if the source files are in the project
The example does say to keep the source next to the project, not under it
ahhh, that fixed it, thank you!!
The example does say to keep the source next to the project, not under it
yes that is true. I suspected this might be related but I updated all the paths thinking that was sufficient. I thought this error was telling me the GDExtension failed to load (whereas now I realize it's tell us it's trying to import it as asset/source code which doesn't make sense)
Let's keep this open and look at documenting this :)
- Related to https://github.com/godotengine/godot/issues/8461.
I suggest adding a .gdignore file at the root of https://github.com/godotengine/godot-cpp-template, so you won't need to do it manually.