To make the library I add the following:
Code: Select all
staticlib: $(OBJ)
$(Q)$(AR) -r -o libmicropython.a $(OBJ)
Code: Select all
staticlib: $(OBJ)
$(Q)$(AR) -r -o libmicropython.a $(OBJ)
Can you post some examples of the missing symbols and also a minimal example of a program linking against your static library.
These are the undefined symbols. Note they are also undefined in their corresponding object files.
Code: Select all
undefined reference to `mp_hal_stdout_tx_strn_cooked'
undefined reference to `mp_builtin_open_obj'
undefined reference to `gc_collect'
undefined reference to `mp_hal_set_interrupt_char'
undefined reference to `mp_module_time'
undefined reference to `mp_unix_free_exec'
undefined reference to `mp_stderr_print'
undefined reference to `mp_module_uselect'
undefined reference to `mp_module_machine'
undefined reference to `mp_module_os'
undefined reference to `mp_unix_alloc_exec'
I added exactly the fragment you posted to unix/Makefile and I get (for example, gc_collect)
Code: Select all
$ nm libmicropython.a | grep 'gc_collect'
U gc_collect
0000000000000000 T gc_collect_end
0000000000000000 T gc_collect_root
0000000000000000 T gc_collect_start
U gc_collect
0000000000000000 D gc_collect_obj
0000000000000000 t py_gc_collect
0000000000000000 T gc_collect <------------
U gc_collect_end
U gc_collect_start
U gc_collect_root
U gc_collect_root
U gc_collect_root
Thank you for the help...finally found out what my problem was. I wasn't including any of the lib files into the compile. I simply removed the main function from main.c and compiled with main.c included. That did the trick.jimmo wrote: ↑Mon Jul 11, 2022 6:10 amI added exactly the fragment you posted to unix/Makefile and I get (for example, gc_collect)
Code: Select all
$ nm libmicropython.a | grep 'gc_collect' U gc_collect 0000000000000000 T gc_collect_end 0000000000000000 T gc_collect_root 0000000000000000 T gc_collect_start U gc_collect 0000000000000000 D gc_collect_obj 0000000000000000 t py_gc_collect 0000000000000000 T gc_collect <------------ U gc_collect_end U gc_collect_start U gc_collect_root U gc_collect_root U gc_collect_root