rohit-px2/nvui

Mac OSX build instructions?

Closed this issue · 21 comments

I would love to try this out on Mac OSX, are there any build instructions you can provide?

Sorry, none right now. Someone asked about building on macOS on Reddit as well and I responded here, but that probably won't work, reason being that I don't know which packages the dependencies might need from the system (if they need any at all). I'm currently trying to set up a macOS VM to figure out how it all goes.

I built it on Mac OS using the following. However, it is unusable as <c-keys> does not work.

brew install fmt boost qt@5 catch2

ln -s /usr/local/Cellar/qt@5/5.15.2/plugins /usr/local/plugins

Qt5Core_DIR="/usr/local/Cellar/qt@5/5.15.2/lib/cmake/Qt5Core" fmt_DIR="/usr/local/Cellar/fmt/8.0.1" cmake -B build . -DCMAKE_BUILD_TYPE=Release

cmake --build build --target nvui --config Release

I also had to comment out src/nvim.cpp

@@ -483,7 +483,7 @@ void Nvim::send_response(
   }
   catch(...)
   {
-    fmt::print("Could not send response. Msgid: {}\n");
+    /* fmt::print("Could not send response. Msgid: {}\n"); */
   }
 }

@khalidchawtany So the application is running, but any <C-(Key)> combination doesn't work?

Can you check if <C-(Num)> e.g. <C-2> works? For example if you
nnoremap <C-2> :echo 'hello'<CR>
And then press , does it print helllo?

@rohit-px2 <c-2> does not work either.

@khalidchawtany Are you using the Cmd key when trying to use the c-keys? I think this is a problem where nvui is only looking for the Ctrl key to be pressed, but on Mac the key is the Cmd key instead of the Ctrl key.

A little update: the macOS artifact does seem to be building on #38, but I have no way to test it out. Also, the executable isn't statically linked so you would have to install the dependencies (fmt, qt@5, msgpack-cxx, catch2, boost) on your system, which isn't ideal.

A little update: the macOS artifact does seem to be building on #38, but I have no way to test it out. Also, the executable isn't statically linked so you would have to install the dependencies (fmt, qt@5, msgpack-cxx, catch2, boost) on your system, which isn't ideal.

I was able to run it on my M1 mac.

Screen Shot 2021-09-06 at 7 12 10 PM

Nice! Did you need to install the dependencies?

Nice! Did you need to install the dependencies?

I didn't, it worked without needing to install dependencies.

Huh, the total build is 1MB so it couldn't be containing the required dependencies. I know on Windows that the DLLs are necessary to run the program and they make up most of the build size, which is over 50MB.

On Linux (Ubuntu) when I run from the most recent build on #38, I get this error:
image, so the Qt library isn't being linked statically.

Huh, the total build is 1MB so it couldn't be containing the required dependencies. I know on Windows that the DLLs are necessary to run the program and they make up most of the build size, which is over 50MB.

On Linux (Ubuntu) when I run from the most recent build on #38, I get this error:
image, so the Qt library isn't being linked statically.

I faced same issue while building on OSX, turns out I didn't link QT5, I used brew to install it so I ran brew install qt5 for it to work

Update: It looks like macOS builds are building now on #38! I'll merge it in now.

I gave it a try with master merged in, but it seems that the Wiki's instructions might be out of date now?

% cmake -B build . -DCMAKE_BUILD_TYPE=Release                                                                                                                                                                      
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:39 (find_package):
  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" (requested
  version 5.15.2) with any of the following names:

    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "/Users/bmulholland/sources/nvui/build/CMakeFiles/CMakeOutput.log".
See also "/Users/bmulholland/sources/nvui/build/CMakeFiles/CMakeError.log".

I got a bit further by doing export Qt5_DIR=/usr/local/opt/qt5/lib/cmake/Qt5 - that should be added to the instructions.

But now I get:

(main) % cmake --build build --target nvui --config Release                                                                                                                                                                  
[  7%] Automatic MOC and UIC for target nvui
[  7%] Built target nvui_autogen
[ 15%] Building CXX object CMakeFiles/nvui.dir/nvui_autogen/mocs_compilation.cpp.o
[ 23%] Building CXX object CMakeFiles/nvui.dir/src/cmdline.cpp.o
[ 30%] Building CXX object CMakeFiles/nvui.dir/src/cursor.cpp.o
[ 38%] Building CXX object CMakeFiles/nvui.dir/src/editor.cpp.o
[ 46%] Building CXX object CMakeFiles/nvui.dir/src/grid.cpp.o
[ 53%] Building CXX object CMakeFiles/nvui.dir/src/hlstate.cpp.o
[ 61%] Building CXX object CMakeFiles/nvui.dir/src/nvim.cpp.o
[ 69%] Building CXX object CMakeFiles/nvui.dir/src/popupmenu.cpp.o
[ 76%] Building CXX object CMakeFiles/nvui.dir/src/titlebar.cpp.o
[ 84%] Building CXX object CMakeFiles/nvui.dir/src/window.cpp.o
[ 92%] Building CXX object CMakeFiles/nvui.dir/src/main.cpp.o
[100%] Linking CXX executable nvui
ld: library not found for -lmsgpackc-cxx
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [nvui] Error 1
make[2]: *** [CMakeFiles/nvui.dir/all] Error 2
make[1]: *** [CMakeFiles/nvui.dir/rule] Error 2
make: *** [nvui] Error 2

Yeah sorry about that, I just merged in a branch with a lot of build changes.
I think I was getting that linker error when I had installed neovim from brew because it finds the C library of msgpack that comes with neovim, but nvui needs the C++ library.
I haven't tried this, but could you define msgpack_DIR to point to your msgpack-cxx installation?

I totally understand - I'm right on the bleeding edge here :)

Which folder of the installation specifically? I've tried a few variants, such as export msgpack_DIR=/usr/local/Cellar/msgpack-cxx/4.0.2/lib/cmake/msgpackc-cxx/ and export msgpack_DIR=/usr/local/Cellar/msgpack-cxx/4.0.2/. None of those changed the error I'm getting.

Could you go into the CMakeLists.txt file and remove this line and see if it builds?

target_link_libraries(nvui PRIVATE msgpackc-cxx)

Yes, with that change it builds and runs :)

Cool, I'll just makes sure it builds on the actions and then I'll merge it in. On macOS there are still a couple problems I'm trying to fix, like with keyboard input #69. It's a slow process since I don't have a Mac on hand to test, so let me know of any problems you find!

Potentially related: on the built version, if I try to open a new split with CTRL-W + v/n, I get an error:
Screen Shot 2021-09-22 at 16 03 26

Potentially related: on the built version, if I try to open a new split with CTRL-W + v/n, I get an error:
Screen Shot 2021-09-22 at 16 03 26

That was happening because the macOS version wasn't registering any key presses that have the Control key as a modifier (Qt quirk, getting the text for the key press was returning an empty string on macOS). I think this should be fixed in #68 now.