Page 1 of 1

Linker errors (OSX)

Posted: Sun Sep 21, 2014 6:33 pm
by p-i-
I have copied /py/* into my project and am trying to to get it build.

I'm getting Linker errors:

Code: Select all

Undefined symbols for architecture x86_64:
  "_malloc_with_finaliser", referenced from:
      _m_malloc_with_finaliser in malloc.o
     (maybe you meant: _m_malloc_with_finaliser)
  "_mp_builtin_input_obj", referenced from:
      _mp_builtin_object_table in builtintables.o
  "_mp_builtin_open_obj", referenced from:
      _mp_module_io_globals_table in modio.o
      _mp_builtin_object_table in builtintables.o
  "_mp_import_stat", referenced from:
      _mp_builtin___import__ in builtinimport.o
      _stat_dir_or_file in builtinimport.o
  "_mp_module_os", referenced from:
      _mp_builtin_module_table in builtintables.o
  "_mp_module_socket", referenced from:
      _mp_builtin_module_table in builtintables.o
  "_mp_module_uctypes", referenced from:
      _mp_builtin_module_table in builtintables.o
      _mp_constants_table in compile.o
  "_mp_module_zlibd", referenced from:
      _mp_builtin_module_table in builtintables.o
  "_mp_sys_exit_obj", referenced from:
      _mp_module_sys_globals_table in modsys.o
  "_mp_sys_stderr_obj", referenced from:
      _mp_module_sys_globals_table in modsys.o
  "_mp_sys_stdin_obj", referenced from:
      _mp_module_sys_globals_table in modsys.o
  "_mp_sys_stdout_obj", referenced from:
      _mp_builtin_print in builtin.o
      _mp_module_sys_globals_table in modsys.o
  "_mp_type_fileio", referenced from:
      _mp_module_io_globals_table in modio.o
  "_mp_type_textio", referenced from:
      _mp_module_io_globals_table in modio.o
  "_mp_verbose_flag", referenced from:
      _mp_emit_glue_assign_bytecode in emitglue.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
 
I'm trying to follow the first one: _malloc_with_finaliser

But '_malloc_with_finaliser' doesn't even exist in the source

m_malloc_with_finaliser occurs in three places...

What is going on here?

π

PS Image here: http://pasteboard.co/nifMJvj.png

PPS I already had to make some changes such as performing the UNIX build and copying across qstrdefs.generated.h, and modifying mpconfigport.h -- setting:

Code: Select all

#ifndef NULL
#define NULL 0
#endif

#define MICROPY_EMIT_X64            (0)

#define MICROPY_GCREGS_SETJMP       (1)

Re: Linker errors (OSX)

Posted: Sun Sep 21, 2014 7:19 pm
by dhylands
Looking at the source code for malloc.c, I see that if MICROPY_ENABLE_GC is defined, then malloc_with_finaliser is #defined to be gc_alloc
https://github.com/micropython/micropyt ... lloc.c#L60

So I have to conclude that you have MICROPY_ENABLE_GC disabled. When I tried to build unix with MICROPY_ENABLE_GC, I also had to disable MICROPY_ENABLE_FINALISER before it would build.

Re: Linker errors (OSX)

Posted: Sun Sep 21, 2014 7:46 pm
by blmorris
Were you able to build the latest source for unix under OSX? While I have been able to make it work before (running Lion - 10.7.5), I tried yesterday with the latest source and couldn't get past the linker - see https://github.com/micropython/micropython/issues/782 and https://github.com/micropython/micropython/issues/865

Compiling for stmhal on OSX always works for me because it uses the dedicated cross-compiler gcc for ARM; compiling the unix port for OSX has frequently had issues.

-Bryan