godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Couldn't read OBJ file, it seems to be binary, corrupted, or empty

Open OmarShehata opened this issue 1 year ago • 4 comments

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

  1. Run scons platform=windows custom_api_file=../extension_api.json inside godot-cpp
  2. Run scons platform=windows
  3. 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.gdextension
  • libgdexample.windows.template_debug.x86_64.dll
  • libgdexample.windows.template_debug.x86_64.exp
  • libgdexample.windows.template_debug.x86_64.lib

bin.zip

And the two obj files in src/

  • gdexample.windows.template_debug.x86_64.obj
  • register_types.windows.template_debug.x86_64.obj

src.zip

OmarShehata avatar Feb 07 '24 14:02 OmarShehata

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

AThousandShips avatar Feb 07 '24 16:02 AThousandShips

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)

OmarShehata avatar Feb 07 '24 19:02 OmarShehata

Let's keep this open and look at documenting this :)

AThousandShips avatar Feb 07 '24 19:02 AThousandShips

  • 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.

Calinou avatar Feb 07 '24 21:02 Calinou