Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failed on Windows #122

Open
AlejandroSuero opened this issue Mar 4, 2024 · 15 comments
Open

Build failed on Windows #122

AlejandroSuero opened this issue Mar 4, 2024 · 15 comments

Comments

@AlejandroSuero
Copy link

I tried using fzf plugin in Windows but failed at the building step, in Linux and Mac seems to be working just fine.

Windows version
11

Nvim version
9.5

fzf version
0.46.1 (3c0a630)

Note: downloaded from winget

Error message
from lazy ui:

mkdir -p build
cc -O3 -Wall -Werror -fpic -std=gnu99 -shared src/fzf.c -o build/libfzf.so
process_begin: CreateProcess(NULL, cc -O3 -Wall -Werror -fpic -std=gnu99 -shared src/fzf.c -o build/libfzf.so, ...) failed.

make: *** [Makefile:24: build/libfzf.so] Error 2
@AlejandroSuero
Copy link
Author

I changed the build key to:

{
  build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build",
}

and got this error messages when building.

        Import-PowerShellDataFile : The term 'Import-PowerShellDataFile' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
        At C:\userpath\scoop\modules\Terminal-Icons\Terminal-Icons.psm1:210 char:33
        +         $hash.Add($_.Basename, (Import-PowerShellDataFile $_.FullName ...
        +                                 ~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : ObjectNotFound: (Import-PowerShellDataFile:String) [], CommandNotFoundException
            + FullyQualifiedErrorId : CommandNotFoundException

        Import-PowerShellDataFile : The term 'Import-PowerShellDataFile' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
        At C:\userpath\scoop\modules\Terminal-Icons\Terminal-Icons.psm1:196 char:22
        +         $colorData = Import-PowerShellDataFile $_.FullName
        +                      ~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : ObjectNotFound: (Import-PowerShellDataFile:String) [], CommandNotFoundException
            + FullyQualifiedErrorId : CommandNotFoundException

        Index operation failed; the array index evaluated to null.
        At C:\userpath\scoop\modules\Terminal-Icons\Terminal-Icons.psm1:197 char:9
        +         $hash[$colorData.Name] = $colorData
        +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
            + FullyQualifiedErrorId : NullArrayIndex

        Index operation failed; the array index evaluated to null.
        At C:\userpath\scoop\modules\Terminal-Icons\Terminal-Icons.psm1:198 char:9
        +         $hash[$colorData.Name].Types.Directories[''] = $colorReset
        +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
            + FullyQualifiedErrorId : NullArrayIndex

        Index operation failed; the array index evaluated to null.
        At C:\Users\imBLZ\scoop\modules\Terminal-Icons\Terminal-Icons.psm1:199 char:9
        +         $hash[$colorData.Name].Types.Files['']       = $colorReset
        +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
            + FullyQualifiedErrorId : NullArrayIndex

        Import-PowerShellDataFile : The term 'Import-PowerShellDataFile' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
        At C:\userpath\scoop\modules\Terminal-Icons\Terminal-Icons.psm1:196 char:22
        +         $colorData = Import-PowerShellDataFile $_.FullName
        +                      ~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : ObjectNotFound: (Import-PowerShellDataFile:String) [], CommandNotFoundException
            + FullyQualifiedErrorId : CommandNotFoundException

        Index operation failed; the array index evaluated to null.
        At C:\userpath\scoop\modules\Terminal-Icons\Terminal-Icons.psm1:197 char:9
        +         $hash[$colorData.Name] = $colorData
        +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
            + FullyQualifiedErrorId : NullArrayIndex

        Index operation failed; the array index evaluated to null.
        At C:\userpath\scoop\modules\Terminal-Icons\Terminal-Icons.psm1:198 char:9
        +         $hash[$colorData.Name].Types.Directories[''] = $colorReset
        +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
            + FullyQualifiedErrorId : NullArrayIndex

        Index operation failed; the array index evaluated to null.
        At C:\userpath\scoop\modules\Terminal-Icons\Terminal-Icons.psm1:199 char:9
        +         $hash[$colorData.Name].Types.Files['']       = $colorReset
        +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
            + FullyQualifiedErrorId : NullArrayIndex

        At line:1 char:46
        + cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build - ...
        +                                              ~~
        The token '&&' is not a valid statement separator in this version.
        At line:1 char:86
        + ... BUILD_TYPE=Release && cmake --build build --config Release && cmake - ...
        +                                                                ~~
        The token '&&' is not a valid statement separator in this version.
            + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
            + FullyQualifiedErrorId : InvalidEndOfLine

@Luladjiev
Copy link

Luladjiev commented May 7, 2024

The way I made it work is install Zig language, and execute, from plugin's folder

zig cc -O3 -Wall -Werror -fpic -std=gnu99 -shared src/fzf.c -o build/libfzf.dll

basically the same command but with zig cc instead of gcc

@ilyassBZ
Copy link

The way I made it work is install Zig language, and execute, from plugin's folder

zig cc -O3 -Wall -Werror -fpic -std=gnu99 -shared src/fzf.c -o build/libfzf.dll

basically the same command but with zig cc instead of gcc

its worked for me thaanks maan soo much i tried everything but this one is from heaven lol

@ayush-porwal
Copy link

The way I made it work is install Zig language, and execute, from plugin's folder

zig cc -O3 -Wall -Werror -fpic -std=gnu99 -shared src/fzf.c -o build/libfzf.dll

basically the same command but with zig cc instead of gcc

Thanks for this! It worked for me too. I tried using make and cmake options on Windows (downloaded via msys64, pacman thingy, so it is possible that some Microsoft toolchain C++ binaries might be missing and hence this error could have been happening, more than this, I don't know), but they didn’t work. However, everything worked smoothly on macOS.

For context, I was following this guide to set up my Neovim. During installation, I encountered issues with telescope-fzf-native.nvim and luasnip (though I'm not sure if the latter is related). I was getting a sourcing error because of these.

Here's the Neovim config repository for anyone interested.

@OrdoFlammae
Copy link

The original error is not exactly like what I was observing myself on Windows, but can you check to see if #133 fixes your issue? If so, I can add this issue to the fixed list on the PR.

@GitMurf
Copy link

GitMurf commented Oct 15, 2024

zig cc -O3 -Wall -Werror -fpic -std=gnu99 -shared src/fzf.c -o build/libfzf.dll

Thanks alot @Luladjiev ... that worked for me as well. Do you have to manually run it directly in powershell in the directory of fzf? or were you able to add the zig command to your telescope lua plugin file for the build property? I was not able to get it to work in the plugin config build property but would love to figure it out (if possible) for future.

@Luladjiev
Copy link

@GitMurf I had to do it manually in powershell.

@GitMurf
Copy link

GitMurf commented Oct 15, 2024

@GitMurf I had to do it manually in powershell.

Thanks for the response and for the solution!

@kirill-d-lappo
Copy link

doesn't work for me when executed by Lazy

I had to navigate manually to ~/AppData/Local/nvim-data/lazy/telescope-fzf-native.nvim

and execute the build command:

cd ~/AppData/Local/nvim-data/lazy/telescope-fzf-native.nvim

# in powershell replace && with ;
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release ; cmake --build build --config Release

output is:

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22631.
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/kiril/AppData/Local/nvim-data/lazy/telescope-fzf-native.nvim/build
MSBuild version 17.11.9+a69bbaaf5 for .NET Framework

  1>Checking Build System
  Building Custom Rule C:/Users/kiril/AppData/Local/nvim-data/lazy/telescope-fzf-native.nvim/CMakeLists.txt
  Auto build dll exports
  fzf.vcxproj -> C:\Users\kiril\AppData\Local\nvim-data\lazy\telescope-fzf-native.nvim\build\Release\libfzf.dll
  Building Custom Rule C:/Users/kiril/AppData/Local/nvim-data/lazy/telescope-fzf-native.nvim/CMakeLists.txt

additionaly I had to copy libfzf.dll to build folder because plugin searches for it there

cd ~/AppData/Local/nvim-data/lazy/telescope-fzf-native.nvim
cp ./build/Release/libfzf.dll ./build/libfzf.dll

after that it started to work

@Or1g3n
Copy link

Or1g3n commented Oct 28, 2024

I had the same exact issue where it places the dll in the ...build/release folder as opposed to in the ...build dir where telescope expects to find it.

I first spent a couple hours trying to get the build to work correctly and the solution was to install CMake, the SDK for my OS (in my case windows 10), then make sure to add the path to cmake.exe in my env variables. Finally I manually moved the files in the ...build/release dir to ...build and it finally worked. I hope the maintainers read this so they can make appropriate mods to resolve.

@surirawat
Copy link

there are 2 options to resolve it

  1. MSYS2
  • use MYSY2 and choose UCRT64 environment or any one then in the UCRT64 shell install pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain (for gcc and other command)
  • then install pacman -S mingw-w64-ucrt-x86_64-cmake (for cmake)
  • update the environment path by adding C:\msys64\ucrt64\bin and C:\msys64\usr\bin (optional) but needed in other things like yazi file manager in windows for file preview
  1. Microsoft build tools
  • Microsoft build tools install by visual studio insider install c++ development but then you need to install cmake for that , can install it with winget install --id=Kitware.CMake -e
  • but the problem is with this approach is it install the libfzf.dll in build/release folder that's the problem and now you have to manually move the libfzf.dll file to build folder as the plugin search the file there.
  1. the make command in windows doesn't work well as it will not generate the build folder in which the file libfzf.dll reside and generate the error make: *** [Makefile:24: build/libfzf.so] Error 2 , so avoid using it and use CMake
  2. use { 'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release' } (lazy setup)

@GitMurf
Copy link

GitMurf commented Dec 13, 2024

there are 2 options to resolve it

I am a bit confused. You listed 4 options fyi. I don't disagree with some of your findings, but wasn't clear what you were proposing? Thanks!

@GitMurf
Copy link

GitMurf commented Dec 13, 2024

FYI with presumably the changes recently from here: #136

I am able to build fine now using Windows Terminal with the following build command:

build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build'

Note this still requires a tweak of what is in the README:

# currently in README
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release'
# what works for me now (from above)
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build'

I am not sure whether the README needs to be updated or whether there is still an issue and it just happens to work ok on my machine now given everything I have tried in the past.

But I no longer have to do anything other than use the build command listed above in my plugin config. Previously I had to do the manual zig process as described here: #122 (comment) which seems to no longer be required for me.

cc @Conni2461 in case this is helpful and/or if we think the README should be updated for Windows with the additional && cmake --install build --prefix build added to the end 🤷‍♂️

@kvietcong
Copy link

kvietcong commented Dec 26, 2024

Was able to make this work on Windows w/o any manual step (outside installing zig) with a lazy plugin spec like this:
{ "nvim-telescope/telescope-fzf-native.nvim", build = "mkdir build; zig cc -O3 -Wall -Werror -fpic -std=gnu99 -shared src/fzf.c -o build/libfzf.dll" }

This way you don't have to mess around with trying to get make/cmake working on windows. You can install zig on Windows w/ winget install zig.zig or if you use another Windows package manager, take a look here

Theoretically, it should also be cross-platform as mkdir should be the same in this scenario across Windows/Linux/Mac and as long as zig is in your PATH, it should be good to go

@ilyassBZ
Copy link

ilyassBZ commented Dec 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants