goncurses
goncurses copied to clipboard
Go get with M1 mac fails
When I try to go get the library I'm given the following error. Does this mean that there are system calls being made in the library that are not supported on ARM?
# github.com/rthornton128/goncurses
Undefined symbols for architecture arm64:
"_current_item", referenced from:
__cgo_a651d9278453_Cfunc_current_item in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_current_item, __cgo_a651d9278453_Cfunc_current_item )
"_free_item", referenced from:
__cgo_a651d9278453_Cfunc_free_item in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_free_item)
"_free_menu", referenced from:
__cgo_a651d9278453_Cfunc_free_menu in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_free_menu)
"_item_count", referenced from:
__cgo_a651d9278453_Cfunc_item_count in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_item_count)
"_item_description", referenced from:
__cgo_a651d9278453_Cfunc_item_description in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_item_description)
"_item_index", referenced from:
__cgo_a651d9278453_Cfunc_item_index in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_item_index)
"_item_name", referenced from:
__cgo_a651d9278453_Cfunc_item_name in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_item_name)
"_item_opts_off", referenced from:
__cgo_a651d9278453_Cfunc_item_opts_off in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_item_opts_off)
"_item_opts_on", referenced from:
__cgo_a651d9278453_Cfunc_item_opts_on in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_item_opts_on)
"_item_value", referenced from:
__cgo_a651d9278453_Cfunc_item_value in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_item_value, __cgo_a651d9278453_Cfunc_item_value )
"_item_visible", referenced from:
__cgo_a651d9278453_Cfunc_item_visible in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_item_visible)
"_menu_back", referenced from:
__cgo_a651d9278453_Cfunc_menu_back in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_back, __cgo_a651d9278453_Cfunc_menu_back )
"_menu_driver", referenced from:
__cgo_a651d9278453_Cfunc_menu_driver in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_menu_driver)
"_menu_fore", referenced from:
__cgo_a651d9278453_Cfunc_menu_fore in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_fore, __cgo_a651d9278453_Cfunc_menu_fore )
"_menu_items", referenced from:
__cgo_a651d9278453_Cfunc_menu_items in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_items, __cgo_a651d9278453_Cfunc_menu_items )
"_menu_opts_off", referenced from:
__cgo_a651d9278453_Cfunc_menu_opts_off in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_menu_opts_off)
"_menu_opts_on", referenced from:
__cgo_a651d9278453_Cfunc_menu_opts_on in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_menu_opts_on)
"_menu_pad", referenced from:
__cgo_a651d9278453_Cfunc_menu_pad in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_pad, __cgo_a651d9278453_Cfunc_menu_pad )
"_menu_pattern", referenced from:
__cgo_a651d9278453_Cfunc_menu_pattern in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_pattern, __cgo_a651d9278453_Cfunc_menu_pattern )
"_menu_request_by_name", referenced from:
__cgo_a651d9278453_Cfunc_menu_request_by_name in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_menu_request_by_name)
"_menu_request_name", referenced from:
__cgo_a651d9278453_C2func_menu_request_name in _x006.o
__cgo_a651d9278453_Cfunc_menu_request_name in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_menu_request_name, __cgo_a651d9278453_C2func_menu_request_name )
"_menu_spacing", referenced from:
__cgo_a651d9278453_Cfunc_menu_spacing in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_spacing, __cgo_a651d9278453_Cfunc_menu_spacing )
"_menu_win", referenced from:
__cgo_a651d9278453_Cfunc_menu_win in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_menu_win, __cgo_a651d9278453_Cfunc_set_menu_win )
"_new_item", referenced from:
__cgo_a651d9278453_C2func_new_item in _x006.o
__cgo_a651d9278453_Cfunc_new_item in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_new_item, __cgo_a651d9278453_C2func_new_item )
"_new_menu", referenced from:
__cgo_a651d9278453_C2func_new_menu in _x006.o
__cgo_a651d9278453_Cfunc_new_menu in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_new_menu, __cgo_a651d9278453_C2func_new_menu )
"_pos_menu_cursor", referenced from:
__cgo_a651d9278453_Cfunc_pos_menu_cursor in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_pos_menu_cursor)
"_post_menu", referenced from:
__cgo_a651d9278453_Cfunc_post_menu in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_post_menu)
"_scale_menu", referenced from:
__cgo_a651d9278453_Cfunc_scale_menu in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_scale_menu)
"_set_current_item", referenced from:
__cgo_a651d9278453_Cfunc_set_current_item in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_current_item)
"_set_item_value", referenced from:
__cgo_a651d9278453_Cfunc_set_item_value in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_item_value)
"_set_menu_back", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_back in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_back)
"_set_menu_fore", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_fore in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_fore)
"_set_menu_format", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_format in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_format)
"_set_menu_grey", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_grey in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_grey)
"_set_menu_items", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_items in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_items)
"_set_menu_mark", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_mark in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_mark)
"_set_menu_pad", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_pad in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_pad)
"_set_menu_pattern", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_pattern in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_pattern)
"_set_menu_spacing", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_spacing in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_spacing)
"_set_menu_sub", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_sub in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_sub)
"_set_menu_win", referenced from:
__cgo_a651d9278453_Cfunc_set_menu_win in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_set_menu_win)
"_unpost_menu", referenced from:
__cgo_a651d9278453_Cfunc_unpost_menu in _x006.o
(maybe you meant: __cgo_a651d9278453_Cfunc_unpost_menu)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm not familiar enough with M1s to really offer much support. What I do know is that ncurses can be built for the M1s and CGO should work out of box. From the looks of things, though, it strikes me that your system might not have the forms or menu libraries? It might be something similar to: https://gist.github.com/cnruby/960344
I have ncurses programs running on my computer, so you're right that it should be supported. I can compile ncurses programs written in c, with gcc -lform -lncurses
so I believe I do have the form library installed, unless it's different for golang. I don't know what the menu library is though, and a google search didn't help.
I don't know how to apply anything in the page you linked to golang because I'm not that familiar with how the compiler works. It seems like the main problem people had there was not having ncurses installed, or not linking it when compiling. I have it installed, but is it possible to link libraries when using go get
?
Yes, go get should link them properly. I'm wondering though if your ncurses, specifically the menu and form libraries, are actually natively compiled (ARM64) or are actually Intel. I'm not 100% sure if this will work but you could try setting the architecture for building to AMD64 just to test this theory out:
GOARCH=amd64 go get github.com/rthornton128/goncurses
If that successfully links, that is likely the issue.
I have the same issue, but on a Intel mac. clang -lncurses -lform
works perfectly fine.
Hi! I successfully got it working. What happened in my machine was that cgo, somehow, was unable to find the installed libraries. I'm using macos Monterey on a M1 mac and I installed ncurses with brew.
This is what I did: as indicated in this site, ncurses installed by brew doesn't include .pc files (which is true). So here are they!
File: /opt/homebrew/lib/pkgconfig/ncurses.pc
prefix=/opt/homebrew/Cellar/ncurses/6.3
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/ncurses
major_version=6
version=6.3
Name: ncurses
Description: ncurses 6.3 library
Version: ${version}
Requires:
Libs: -L${libdir} -lncurses
Cflags: -I${includedir} -I${includedir}/..
File: /opt/homebrew/lib/pkgconfig/form.pc
prefix=/opt/homebrew/Cellar/ncurses/6.3
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/ncurses
major_version=6
version=6.3
Name: form
Description: ncurses 6.3 add-on
Version: ${version}
Requires: ncurses
Libs: -L${libdir} -lform
Cflags: -I${includedir} -I${includedir}/..
File: /opt/homebrew/lib/pkgconfig/menu.pc
prefix=/opt/homebrew/Cellar/ncurses/6.3
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/ncurses
major_version=6
version=6.3
Name: menu
Description: ncurses 6.3 add-on
Version: ${version}
Requires: ncurses
Libs: -L${libdir} -lmenu
Cflags: -I${includedir} -I${includedir}/..
File: /opt/homebrew/lib/pkgconfig/panel.pc
prefix=/opt/homebrew/Cellar/ncurses/6.3
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/ncurses
major_version=6
version=6.3
Name: panel
Description: ncurses 6.3 add-on
Version: ${version}
Requires: ncurses
Libs: -L${libdir} -lpanel
Cflags: -I${includedir} -I${includedir}/..
With that, I could successfully use pkg-config
:
% pkg-config --cflags ncurses form menu ncurses ncurses panel
-I/opt/homebrew/Cellar/ncurses/6.3/include/ncurses -I/opt/homebrew/Cellar/ncurses/6.3/include/ncurses/.. -I/opt/homebrew/Cellar/ncurses/6.3/include/ncurses -I/opt/homebrew/Cellar/ncurses/6.3/include/ncurses/.. -I/opt/homebrew/Cellar/ncurses/6.3/include/ncurses -I/opt/homebrew/Cellar/ncurses/6.3/include/ncurses/.. -I/opt/homebrew/Cellar/ncurses/6.3/include/ncurses -I/opt/homebrew/Cellar/ncurses/6.3/include/ncurses/..
which is nice! So, now I should indicate CGO that these flags should be used when calling the linker. This can be done by setting CGO_LDFLAGS
:
export CGO_LDFLAGS="${CGO_LDFLAGS} $(pkg-config --libs ncurses)"
and, voi-lá, it worked :)
My application is indeed very simple - it's just a test to print a character in bold. But I think that this solution might be used if further problems appear, such as missing headers or other libraries.