emacs-libvterm
emacs-libvterm copied to clipboard
vterm-module compile fails for x86_64 Emacs on Apple Silicon
Hi, I am unable to solve this issue.
My Setup:
I am using Homebrew, from a terminal set to x86_64. I installed the Mitsuharu Emacs with brew install emacs-mac
, and I can confirm the app shows as Intel (x86_64). I have checked that modules are enabled.
emacs-libvterm installed with all these methods (following the README): :
- installing libvterm through homebrew
- not pre-installing it and letting emacs-libvterm install it with the MELPA install
- installing manually from source
Each method gives the following error (with variation on the path of the ignored file) It is building for macOs-arm64 but attempting to link with file built for macOS-x86_64. I have tried this from Emacs and terminal all running x86_64, all with software that was downloaded only for x86_64. I did also try using an arm64 terminal to see if I had a different result, but the same thing happened, although I expected that as the other programs are not arm64, eg. cmake is x86_64 as it was installed through Homebrew.
Scanning dependencies of target vterm-module
[ 25%] Building C object CMakeFiles/vterm-module.dir/vterm-module.c.o
[ 50%] Building C object CMakeFiles/vterm-module.dir/utf8.c.o
[ 75%] Building C object CMakeFiles/vterm-module.dir/elisp.c.o
[100%] Linking C shared module ../vterm-module.so
ld: warning: ignoring file /usr/local/lib/libvterm.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_vterm_color_is_equal", referenced from:
_refresh_lines in vterm-module.c.o
"_vterm_free", referenced from:
_term_finalize in vterm-module.c.o
"_vterm_get_size", referenced from:
_get_col_offset in vterm-module.c.o
"_vterm_input_write", referenced from:
_Fvterm_write_input in vterm-module.c.o
"_vterm_keyboard_end_paste", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_keyboard_key", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_keyboard_start_paste", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_keyboard_unichar", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_new", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_obtain_screen", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_obtain_state", referenced from:
_Fvterm_new in vterm-module.c.o
_term_redraw in vterm-module.c.o
_get_col_offset in vterm-module.c.o
_refresh_lines in vterm-module.c.o
_cell_rgb_color in vterm-module.c.o
"_vterm_output_get_buffer_current", referenced from:
_term_flush_output in vterm-module.c.o
"_vterm_output_read", referenced from:
_term_flush_output in vterm-module.c.o
"_vterm_screen_enable_altscreen", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_screen_flush_damage", referenced from:
_Fvterm_update in vterm-module.c.o
_Fvterm_write_input in vterm-module.c.o
_Fvterm_set_size in vterm-module.c.o
"_vterm_screen_get_cell", referenced from:
_get_col_offset in vterm-module.c.o
_refresh_lines in vterm-module.c.o
"_vterm_screen_is_eol", referenced from:
_get_col_offset in vterm-module.c.o
_refresh_lines in vterm-module.c.o
"_vterm_screen_reset", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_screen_set_callbacks", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_screen_set_damage_merge", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_set_size", referenced from:
_Fvterm_set_size in vterm-module.c.o
"_vterm_set_utf8", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_state_get_cursorpos", referenced from:
_term_redraw in vterm-module.c.o
"_vterm_state_get_default_colors", referenced from:
_get_col_offset in vterm-module.c.o
_refresh_lines in vterm-module.c.o
"_vterm_state_get_palette_color", referenced from:
_cell_rgb_color in vterm-module.c.o
"_vterm_state_set_unrecognised_fallbacks", referenced from:
_Fvterm_new in vterm-module.c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/vterm-module.dir/build.make:134: ../vterm-module.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:123: CMakeFiles/vterm-module.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
FWIW, I have an intel mac where I can reproduce the same issue. My environment:
- macOS 10.15.7
- cmake 3.19.2
I cloned this repo (sha a670b786539d3c8865d8f68fe0c67a2d4afbf1aa
) and run cmake
and make
.
[100%] Linking C shared module ../vterm-module.so
ld: warning: ignoring file libvterm-prefix/src/libvterm/.libs/libvterm.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
"_vterm_color_is_equal", referenced from:
_refresh_lines in vterm-module.c.o
"_vterm_free", referenced from:
_term_finalize in vterm-module.c.o
"_vterm_get_size", referenced from:
_get_col_offset in vterm-module.c.o
"_vterm_input_write", referenced from:
_Fvterm_write_input in vterm-module.c.o
"_vterm_keyboard_end_paste", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_keyboard_key", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_keyboard_start_paste", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_keyboard_unichar", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_new", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_obtain_screen", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_obtain_state", referenced from:
_Fvterm_new in vterm-module.c.o
_term_redraw in vterm-module.c.o
_get_col_offset in vterm-module.c.o
_refresh_lines in vterm-module.c.o
_cell_rgb_color in vterm-module.c.o
"_vterm_output_get_buffer_current", referenced from:
_term_flush_output in vterm-module.c.o
"_vterm_output_read", referenced from:
_term_flush_output in vterm-module.c.o
"_vterm_screen_enable_altscreen", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_screen_flush_damage", referenced from:
_Fvterm_update in vterm-module.c.o
_Fvterm_write_input in vterm-module.c.o
_Fvterm_set_size in vterm-module.c.o
"_vterm_screen_get_cell", referenced from:
_get_col_offset in vterm-module.c.o
_refresh_lines in vterm-module.c.o
"_vterm_screen_is_eol", referenced from:
_get_col_offset in vterm-module.c.o
_refresh_lines in vterm-module.c.o
"_vterm_screen_reset", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_screen_set_callbacks", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_screen_set_damage_merge", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_set_size", referenced from:
_Fvterm_set_size in vterm-module.c.o
"_vterm_set_utf8", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_state_get_cursorpos", referenced from:
_term_redraw in vterm-module.c.o
"_vterm_state_get_default_colors", referenced from:
_get_col_offset in vterm-module.c.o
_refresh_lines in vterm-module.c.o
"_vterm_state_get_palette_color", referenced from:
_cell_rgb_color in vterm-module.c.o
"_vterm_state_set_unrecognised_fallbacks", referenced from:
_Fvterm_new in vterm-module.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../vterm-module.so] Error 1
make[1]: *** [CMakeFiles/vterm-module.dir/all] Error 2
make: *** [all] Error 2
This seems to have been fixed with an update to cmake 3.19.3. Like @soonho-tri I was also on 3.19.2.
Just did a brew update and upgrade, then ran M-x vterm
and it seemed to compile and run with no issues, without having to manually install libvterm anywhere.
@kepler471 , thanks. I can confirm that using cmake 3.19.3 resolves this issue on my side (note: I'm not using an M1 mac).
Try running brew install libvterm
I was using intel macbook pro (2015) and ran into the same compile error. After reinstalling cmake and make, libvterm, now emacs can open vterm without an issue. I'm on Emacs v28.1.
This happens to me, I'm on an M1 macbook
$ cmake --version master
cmake version 3.23.2
$ mkdir build
$ cd build
$ cmake -DLIBVTERM_INCLUDE_DIR=/opt/homebrew/opt/libvterm/include -DLIBVTERM_LIBRARY=/opt/homebrew/opt/libvterm/lib/libvterm.dylib ..
-- System libvterm detected
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/dlevy/.config/emacs/.local/straight/build-28.1/vterm/build
$ [[email protected]] ~/.config/emacs/.local/straight/build-28.1/vterm/build make master
[ 25%] Building C object CMakeFiles/vterm-module.dir/vterm-module.c.o
[ 50%] Building C object CMakeFiles/vterm-module.dir/utf8.c.o
[ 75%] Building C object CMakeFiles/vterm-module.dir/elisp.c.o
[100%] Linking C shared module ../vterm-module.so
ld: warning: ignoring file /opt/homebrew/opt/libvterm/lib/libvterm.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
"_vterm_color_is_equal", referenced from:
_refresh_lines in vterm-module.c.o
"_vterm_free", referenced from:
_term_finalize in vterm-module.c.o
"_vterm_get_size", referenced from:
_goto_col in vterm-module.c.o
"_vterm_input_write", referenced from:
_Fvterm_write_input in vterm-module.c.o
"_vterm_keyboard_end_paste", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_keyboard_key", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_keyboard_start_paste", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_keyboard_unichar", referenced from:
_Fvterm_update in vterm-module.c.o
"_vterm_new", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_obtain_screen", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_obtain_state", referenced from:
_Fvterm_new in vterm-module.c.o
_term_redraw in vterm-module.c.o
_goto_col in vterm-module.c.o
_refresh_lines in vterm-module.c.o
_cell_rgb_color in vterm-module.c.o
"_vterm_output_get_buffer_current", referenced from:
_term_flush_output in vterm-module.c.o
"_vterm_output_read", referenced from:
_term_flush_output in vterm-module.c.o
"_vterm_screen_enable_altscreen", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_screen_flush_damage", referenced from:
_Fvterm_update in vterm-module.c.o
_Fvterm_write_input in vterm-module.c.o
_Fvterm_set_size in vterm-module.c.o
"_vterm_screen_get_cell", referenced from:
_goto_col in vterm-module.c.o
_refresh_lines in vterm-module.c.o
"_vterm_screen_is_eol", referenced from:
_goto_col in vterm-module.c.o
_refresh_lines in vterm-module.c.o
"_vterm_screen_reset", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_screen_set_callbacks", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_screen_set_damage_merge", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_set_size", referenced from:
_Fvterm_set_size in vterm-module.c.o
"_vterm_set_utf8", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_state_get_cursorpos", referenced from:
_term_redraw in vterm-module.c.o
"_vterm_state_get_default_colors", referenced from:
_goto_col in vterm-module.c.o
_refresh_lines in vterm-module.c.o
"_vterm_state_get_palette_color", referenced from:
_cell_rgb_color in vterm-module.c.o
"_vterm_state_set_bold_highbright", referenced from:
_Fvterm_new in vterm-module.c.o
"_vterm_state_set_unrecognised_fallbacks", referenced from:
_Fvterm_new in vterm-module.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../vterm-module.so] Error 1
make[1]: *** [CMakeFiles/vterm-module.dir/all] Error 2
make: *** [all] Error 2
I have no idea why it tries to compile for x86_64. The link dyn lib is arm64
$ cc -v
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gcc -v
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Anyone has any ideas?
In my solution
- brew install libvterm (will be installed in /opt/homebrew)
- remove all libvterm of symbolics in path /usr/local/lib (libvterm.dylib, libvterm.a libvterm.0.dylib)
- add new symbolic, eg: ln -s /opt/homebrew/lib/libvterm.0.dylib /usr/local/lib
brew install libvterm
cd /usr/local/lib
rm libvterm.dylib libvterm.a libvterm.0.dylib
ln -s /opt/homebrew/lib/libvterm.0.dylib /usr/local/lib
ln -s /opt/homebrew/lib/libvterm.a /usr/local/lib
ln -s /opt/homebrew/lib/libvterm.dylib /usr/local/lib
Symlinking like that has a very good chance of confusing the hell out of something else that expects to find an x86_64 libvterm.
Symlinking like that has a very good chance of confusing the hell out of something else that expects to find an x86_64 libvterm.
Yes, the better solution is reinstall all of x86_64 version packages by the new arm homebrew, and clean the x86_64 homebrew
there's a cmake build folder need to be remove or cmake will keep using the wrong path to find libvterm. here's how I solved the problem in my m1 pro
- remove 'libvterm' from x86 environment ->
/usr/local/bin/brew uninstall libvterm
- install 'libvterm', 'cmake' with arm64 homebrew
- make sure the correct cmake binary is reachable in $PATH
check the variable
exec_path
in emacs - remove
build
folder in vterm directory