Skip to content

[3.x] Godot build with summator shared library failed. #56887

@Devilsparta

Description

@Devilsparta

Godot version

3.4.dev(dfdc2b3)

System information

MacOS

Issue description

My godot build with summator failed when I'm building it a shared library.

I'm using the 3.4 branch. The building enviroment is MacOS.
I can build it to static library, but cannot build it a shared library.

My summator is exactly the same with the tutrial.

modules/summator
├── SCsub
├── __pycache__
│   └── config.cpython-310.pyc
├── config.py
├── register_types.cpp
├── register_types.h
├── register_types.os
├── register_types.osx.opt.tools.64.o
├── summator.cpp
├── summator.h
├── summator.os
└── summator.osx.opt.tools.64.o

and my SCsub file is:

Import('env')

sources = [
    "register_types.cpp",
    "summator.cpp"
]

# First, create a custom env for the shared library.
module_env = env.Clone()

# Position-independent code is required for a shared library.
module_env.Append(CCFLAGS=['-fPIC'])

# Don't inject Godot's dependencies into our shared library.
module_env['LIBS'] = []

# Define the shared library. By default, it would be built in the module's
# folder, however it's better to output it into `bin` next to the
# Godot binary.
shared_lib = module_env.SharedLibrary(target='#bin/summator', source=sources)

# Finally, notify the main build environment it now has our shared library
# as a new dependency.

# LIBPATH and LIBS need to be set on the real "env" (not the clone)
# to link the specified libraries to the Godot executable.

env.Append(LIBPATH=['#bin'])

# SCons wants the name of the library with it custom suffixes
# (e.g. ".x11.tools.64") but without the final ".so".
shared_lib_shim = shared_lib[0].name.rsplit('.', 1)[0]
env.Append(LIBS=[shared_lib_shim])

My terminal of scons command output is:

➜  godot git:(3.4) scons target=release_debug platform=osx -j6
scons: Reading SConscript files ...
Building for macOS 10.12+, platform x86-64.
Checking for C header file mntent.h... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
[ 77%] Linking Shared Library ==> bin/libsummator.osx.opt.tools.64.dylib
[ 80%] Undefined symbols for architecture x86_64:
  "_global_lock()", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
  "_global_unlock()", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
  "_err_print_error(char const*, char const*, int, char const*, ErrorHandlerType)", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
      MethodBind1<int>::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
      MethodBind0::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
      MethodBind0RC<int>::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
  "postinitialize_handler(Object*)", referenced from:
      Object* ClassDB::creator<Summator>() in register_types.os
  "D_METHOD(char const*)", referenced from:
      Summator::_bind_methods() in summator.os
  "D_METHOD(char const*, char const*)", referenced from:
      Summator::_bind_methods() in summator.os
  "MethodBind::_set_const(bool)", referenced from:
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      MethodBind* create_method_bind<Summator>(void (Summator::*)()) in summator.os
      MethodBind0RC<int>::MethodBind0RC() in summator.os
  "MethodBind::_set_returns(bool)", referenced from:
      MethodBind0RC<int>::MethodBind0RC() in summator.os
  "MethodBind::_generate_argument_types(int)", referenced from:
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      MethodBind* create_method_bind<Summator>(void (Summator::*)()) in summator.os
      MethodBind0RC<int>::MethodBind0RC() in summator.os
  "MethodBind::MethodBind()", referenced from:
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      MethodBind* create_method_bind<Summator>(void (Summator::*)()) in summator.os
      MethodBind0RC<int>::MethodBind0RC() in summator.os
  "MethodBind::~MethodBind()", referenced from:
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      MethodBind1<int>::~MethodBind1() in summator.os
      MethodBind1<int>::~MethodBind1() in summator.os
      MethodBind* create_method_bind<Summator>(void (Summator::*)()) in summator.os
      MethodBind0::~MethodBind0() in summator.os
      MethodBind0::~MethodBind0() in summator.os
      MethodBind0RC<int>::MethodBind0RC() in summator.os
      ...
  "StringName::StringName(char const*)", referenced from:
      Summator::_get_property_listv(List<PropertyInfo, DefaultAllocator>*, bool) const in summator.os
      Reference::_get_property_listv(List<PropertyInfo, DefaultAllocator>*, bool) const in summator.os
  "StringName::StringName(String const&)", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
      void ClassDB::_add_class<Summator>() in register_types.os
      void ClassDB::_add_class<Reference>() in register_types.os
      Summator::_get_class_namev() const in summator.os
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      PropertyInfo::PropertyInfo(Variant::Type, String, PropertyHint, String const&, unsigned int, StringName const&) in summator.os
      MethodBind* create_method_bind<Summator>(void (Summator::*)()) in summator.os
      ...
  "StringName::StringName()", referenced from:
      Summator::Summator() in summator.os
      Summator::Summator() in summator.os
      Summator::_get_property_listv(List<PropertyInfo, DefaultAllocator>*, bool) const in summator.os
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      MethodBind1<int>::_gen_argument_type_info(int) const in summator.os
      GetTypeInfo<int, void>::get_class_info() in summator.os
      PropertyInfo::PropertyInfo(Variant::Type, String, PropertyHint, String const&, unsigned int, StringName const&) in summator.os
      ...
  "StringName::~StringName()", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
      void ClassDB::_add_class<Summator>() in register_types.os
      void ClassDB::_add_class<Reference>() in register_types.os
      Summator::_bind_methods() in summator.os
      Summator::_get_property_listv(List<PropertyInfo, DefaultAllocator>*, bool) const in summator.os
      Summator::_get_class_namev() const in summator.os
      Summator::~Summator() in summator.os
      ...
  "StringName::operator=(StringName const&)", referenced from:
      Summator::_get_class_namev() const in summator.os
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      PropertyInfo::PropertyInfo(Variant::Type, String, PropertyHint, String const&, unsigned int, StringName const&) in summator.os
      MethodBind* create_method_bind<Summator>(void (Summator::*)()) in summator.os
      MethodBind* create_method_bind<Summator, int>(int (Summator::*)() const) in summator.os
      PropertyInfo::operator=(PropertyInfo const&) in summator.os
  "Memory::free_static(void*, bool)", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
      void ClassDB::_add_class<Summator>() in register_types.os
      void ClassDB::_add_class<Reference>() in register_types.os
      Summator::_bind_methods() in summator.os
      Summator::_get_property_listv(List<PropertyInfo, DefaultAllocator>*, bool) const in summator.os
      Summator::_get_class_namev() const in summator.os
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      ...
  "Memory::alloc_static(unsigned long, bool)", referenced from:
      DefaultAllocator::alloc(unsigned long) in summator.os
  "Object::call_multilevel(StringName const&, Variant const**, int)", referenced from:
      vtable for Summator in summator.os
  "Object::initialize_class()", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
      Summator::_initialize_classv() in summator.os
  "Object::_changed_callback(Object*, char const*)", referenced from:
      vtable for Summator in summator.os
  "Object::call_multilevel_reversed(StringName const&, Variant const**, int)", referenced from:
      vtable for Summator in summator.os
  "Object::call(StringName const&, Variant const**, int, Variant::CallError&)", referenced from:
      vtable for Summator in summator.os
  "Object::setvar(Variant const&, Variant const&, bool*)", referenced from:
      vtable for Summator in summator.os
  "Object::to_string()", referenced from:
      vtable for Summator in summator.os
  "String::String(char const*)", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
      void ClassDB::_add_class<Summator>() in register_types.os
      void ClassDB::_add_class<Reference>() in register_types.os
      Summator::_get_property_listv(List<PropertyInfo, DefaultAllocator>*, bool) const in summator.os
      Summator::_get_class_namev() const in summator.os
      Summator::get_class() const in summator.os
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      ...
  "ClassDB::_add_class2(StringName const&, StringName const&)", referenced from:
      void ClassDB::_add_class<Summator>() in register_types.os
      void ClassDB::_add_class<Reference>() in register_types.os
      void ClassDB::_add_class<Summator>() in summator.os
      void ClassDB::_add_class<Reference>() in summator.os
  "ClassDB::bind_methodfi(unsigned int, MethodBind*, MethodDefinition const&, Variant const**, int)", referenced from:
      Summator::_bind_methods() in summator.os
  "ClassDB::get_property_list(StringName, List<PropertyInfo, DefaultAllocator>*, bool, Object const*)", referenced from:
      Summator::_get_property_listv(List<PropertyInfo, DefaultAllocator>*, bool) const in summator.os
      Reference::_get_property_listv(List<PropertyInfo, DefaultAllocator>*, bool) const in summator.os
  "ClassDB::classes", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
  "Variant::can_convert_strict(Variant::Type, Variant::Type)", referenced from:
      MethodBind1<int>::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
  "Variant::clear()", referenced from:
      MethodBind1<int>::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
      MethodBind0RC<int>::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
  "Variant::Variant(Variant const&)", referenced from:
      MethodBind1<int>::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
      MethodBind0RC<int>::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
  "Variant::Variant(int)", referenced from:
      MethodBind0RC<int>::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
  "Reference::_bind_methods()", referenced from:
      void ClassDB::register_class<Summator>() in register_types.os
      Summator::_initialize_classv() in summator.os
  "Reference::Reference()", referenced from:
      Summator::Summator() in summator.os
      Summator::Summator() in summator.os
  "Reference::~Reference()", referenced from:
      Summator::Summator() in summator.os
      Summator::Summator() in summator.os
      Summator::~Summator() in summator.os
      Summator::~Summator() in summator.os
  "Object::_validate_property(PropertyInfo&) const", referenced from:
      vtable for Summator in summator.os
  "Object::get_argument_options(StringName const&, int, List<String, DefaultAllocator>*) const", referenced from:
      vtable for Summator in summator.os
  "Object::get_translatable_strings(List<String, DefaultAllocator>*) const", referenced from:
      vtable for Summator in summator.os
  "Object::getvar(Variant const&, bool*) const", referenced from:
      vtable for Summator in summator.os
  "String::operator==(char const*) const", referenced from:
      Summator::is_class(String const&) const in summator.os
  "Variant::operator int() const", referenced from:
      MethodBind1<int>::call(Object*, Variant const**, int, Variant::CallError&) in summator.os
  "typeinfo for MethodBind", referenced from:
      typeinfo for MethodBind1<int> in summator.os
      typeinfo for MethodBind0 in summator.os
      typeinfo for MethodBind0RC<int> in summator.os
  "typeinfo for Reference", referenced from:
      typeinfo for Summator in summator.os
  "operator new(unsigned long, void* (*)(unsigned long))", referenced from:
      List<PropertyInfo, DefaultAllocator>::push_back(PropertyInfo const&) in summator.os
  "operator new(unsigned long, char const*)", referenced from:
      Object* ClassDB::creator<Summator>() in register_types.os
      MethodBind* create_method_bind<Summator, int>(void (Summator::*)(int)) in summator.os
      MethodBind* create_method_bind<Summator>(void (Summator::*)()) in summator.os
      MethodBind* create_method_bind<Summator, int>(int (Summator::*)() const) in summator.os
ld: symbol(s) not found for architecture x86_64
[ 80%] clang: error: linker command failed with exit code 1 (use -v to see invocation)
[ 80%] scons: *** [bin/libsummator.osx.opt.tools.64.dylib] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:00:53.897]

Please help me!! If you need any detail information, just replay and I will edit here.

Steps to reproduce

Put project downbelow in godot/modules and run scons target=release_debug platform=osx -j6

Minimal reproduction project

summator.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    For team assessment

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions