JuliaInterop / Cxx.jl

The Julia C++ Interface
Other
755 stars 107 forks source link

failed precompile 1.4.0 Win64 #469

Open cmcaine opened 4 years ago

cmcaine commented 4 years ago

I get different errors to #464, so I thought I'd make a new issue.

The first exception is:

LoadError: could not load library "C:\Users\Colin\.julia\packages\Cxx\bZSeY\src\..\deps\usr\bin\libcxxffi"

Tested on Cxx.jl 0.4.0 and master

julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)       
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
  WORD_SIZE: 64    
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, ivybridge)
Environment:
  JULIA_EDITOR = "C:\Program Files\VSCodium\VSCodium.exe"
  JULIA_NUM_THREADS =

(@v1.4) pkg> activate slb
 Activating new environment at `C:\Users\Colin\slb\Project.toml`

(slb) pkg> add Cxx
   Updating registry at `C:\Users\Colin\.julia\registries\General`
   Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Resolving package versions...
   Updating `C:\Users\Colin\slb\Project.toml`
  [a0b5b9ef] + Cxx v0.4.0
   Updating `C:\Users\Colin\slb\Manifest.toml`
  [b99e7846] + BinaryProvider v0.5.9
  [a0b5b9ef] + Cxx v0.4.0
  [2a0f44e3] + Base64 
  [b77e0a4c] + InteractiveUtils 
  [8f399da3] + Libdl 
  [56ddb016] + Logging 
  [d6f4376e] + Markdown 
  [3fa0cd96] + REPL 
  [ea8e919c] + SHA 
  [6462fe0b] + Sockets

(slb) pkg> status
Status `C:\Users\Colin\slb\Project.toml`
  [a0b5b9ef] Cxx v0.4.0

(slb) pkg> test Cxx
    Testing Cxx
Status `C:\Users\Colin\AppData\Local\Temp\jl_TeTbuq\Manifest.toml`
  [b99e7846] BinaryProvider v0.5.9
  [a0b5b9ef] Cxx v0.4.0
  [2a0f44e3] Base64
  [8ba89e20] Distributed
  [b77e0a4c] InteractiveUtils
  [8f399da3] Libdl
  [56ddb016] Logging
  [d6f4376e] Markdown
  [3fa0cd96] REPL
  [9a3f8284] Random
  [ea8e919c] SHA
  [9e88b42a] Serialization
  [6462fe0b] Sockets
  [8dfed614] Test
ERROR: LoadError: LoadError: could not load library "C:\Users\Colin\.julia\packages\Cxx\1RaOv\src\..\deps\usr\bin\libcxxffi"
The specified procedure could not be found. 
Stacktrace:
 [1] dlopen(::String, ::UInt32; throw_error::Bool) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Libdl\src\Libdl.jl:109
 [2] dlopen at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Libdl\src\Libdl.jl:109 [inlined]
 [3] init_libcxxffi() at C:\Users\Colin\.julia\packages\Cxx\1RaOv\src\initialization.jl:23
 [4] top-level scope at C:\Users\Colin\.julia\packages\Cxx\1RaOv\src\initialization.jl:25
 [5] include(::Module, ::String) at .\Base.jl:377
 [6] include(::String) at C:\Users\Colin\.julia\packages\Cxx\1RaOv\src\Cxx.jl:144
 [7] top-level scope at C:\Users\Colin\.julia\packages\Cxx\1RaOv\src\Cxx.jl:170
 [8] include(::Module, ::String) at .\Base.jl:377
 [9] top-level scope at none:2
 [10] eval at .\boot.jl:331 [inlined]
 [11] eval(::Expr) at .\client.jl:449
 [12] top-level scope at .\none:3
in expression starting at C:\Users\Colin\.julia\packages\Cxx\1RaOv\src\initialization.jl:25
in expression starting at C:\Users\Colin\.julia\packages\Cxx\1RaOv\src\Cxx.jl:170
ERROR: LoadError: Failed to precompile Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2] to C:\Users\Colin\.julia\compiled\v1.4\Cxx\ESGkI_Lqf6M.ji.
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at .\loading.jl:1272
 [3] _require(::Base.PkgId) at .\loading.jl:1029
 [4] require(::Base.PkgId) at .\loading.jl:927
 [5] require(::Module, ::Symbol) at .\loading.jl:922
 [6] include(::String) at .\client.jl:439
 [7] top-level scope at none:6
in expression starting at C:\Users\Colin\.julia\packages\Cxx\1RaOv\test\runtests.jl:5
ERROR: Package Cxx errored during testing
(slb) pkg> add Cxx#master
    Cloning git-repo `https://github.com/JuliaInterop/Cxx.jl.git`
   Updating git-repo `https://github.com/JuliaInterop/Cxx.jl.git`
  Resolving package versions...
   Updating `C:\Users\Colin\slb\Project.toml`
  [a0b5b9ef] ~ Cxx v0.4.0 ⇒ v0.4.0 #master (https://github.com/JuliaInterop/Cxx.jl.git)
   Updating `C:\Users\Colin\slb\Manifest.toml`
  [a0b5b9ef] ~ Cxx v0.4.0 ⇒ v0.4.0 #master (https://github.com/JuliaInterop/Cxx.jl.git)
   Building Cxx → `C:\Users\Colin\.julia\packages\Cxx\bZSeY\deps\build.log`

(slb) pkg> test Cxx
    Testing Cxx
Status `C:\Users\Colin\AppData\Local\Temp\jl_v04Fg0\Manifest.toml`
  [b99e7846] BinaryProvider v0.5.9
  [a0b5b9ef] Cxx v0.4.0 #master (https://github.com/JuliaInterop/Cxx.jl.git)
  [2a0f44e3] Base64
  [8ba89e20] Distributed
  [b77e0a4c] InteractiveUtils
  [8f399da3] Libdl
  [56ddb016] Logging 
  [d6f4376e] Markdown
  [3fa0cd96] REPL
  [9a3f8284] Random
  [ea8e919c] SHA
  [9e88b42a] Serialization
  [6462fe0b] Sockets
  [8dfed614] Test
ERROR: LoadError: LoadError: could not load library "C:\Users\Colin\.julia\packages\Cxx\bZSeY\src\..\deps\usr\bin\libcxxffi"
The specified procedure could not be found. 
Stacktrace:
 [1] dlopen(::String, ::UInt32; throw_error::Bool) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Libdl\src\Libdl.jl:109
 [2] dlopen at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Libdl\src\Libdl.jl:109 [inlined]
 [3] init_libcxxffi() at C:\Users\Colin\.julia\packages\Cxx\bZSeY\src\initialization.jl:23
 [4] top-level scope at C:\Users\Colin\.julia\packages\Cxx\bZSeY\src\initialization.jl:25
 [5] include(::Module, ::String) at .\Base.jl:377
 [6] include(::String) at C:\Users\Colin\.julia\packages\Cxx\bZSeY\src\Cxx.jl:144
 [7] top-level scope at C:\Users\Colin\.julia\packages\Cxx\bZSeY\src\Cxx.jl:170
 [8] include(::Module, ::String) at .\Base.jl:377
 [9] top-level scope at none:2
 [10] eval at .\boot.jl:331 [inlined]
 [11] eval(::Expr) at .\client.jl:449
 [12] top-level scope at .\none:3
in expression starting at C:\Users\Colin\.julia\packages\Cxx\bZSeY\src\initialization.jl:25
in expression starting at C:\Users\Colin\.julia\packages\Cxx\bZSeY\src\Cxx.jl:170
ERROR: LoadError: Failed to precompile Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2] to C:\Users\Colin\.julia\compiled\v1.4\Cxx\ESGkI_wWksE.ji.
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at .\loading.jl:1272
 [3] _require(::Base.PkgId) at .\loading.jl:1029
 [4] require(::Base.PkgId) at .\loading.jl:927
 [5] require(::Module, ::Symbol) at .\loading.jl:922
 [6] include(::String) at .\client.jl:439
 [7] top-level scope at none:6
in expression starting at C:\Users\Colin\.julia\packages\Cxx\bZSeY\test\runtests.jl:5
ERROR: Package Cxx errored during testing
yuan20200101 commented 4 years ago

So, is it solved? I encounter the same problem in MacOs

storopoli commented 4 years ago

Have the same problem in MacOS catalina with LLVM installed using homebrew (version stable 10.0.0 (bottled), HEAD [keg-only])

Here is the full error:

julia> using Cxx
[ Info: Precompiling Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2]
ERROR: LoadError: LoadError: could not load library "/Users/storopoli/.julia/packages/Cxx/1RaOv/src/../deps/usr/lib/libcxxffi"
dlopen(/Users/storopoli/.julia/packages/Cxx/1RaOv/src/../deps/usr/lib/libcxxffi.dylib, 9): Symbol not found: __ZN4llvm11raw_ostream6handleEv
  Referenced from: /Users/storopoli/.julia/packages/Cxx/1RaOv/src/../deps/usr/lib/libcxxffi.dylib
  Expected in: /Applications/Julia-1.4.app/Contents/Resources/julia/lib/julia/libLLVM.dylib
 in /Users/storopoli/.julia/packages/Cxx/1RaOv/src/../deps/usr/lib/libcxxffi.dylib
Stacktrace:
 [1] dlopen(::String, ::UInt32; throw_error::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Libdl/src/Libdl.jl:109
 [2] dlopen at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Libdl/src/Libdl.jl:109 [inlined]
 [3] init_libcxxffi() at /Users/storopoli/.julia/packages/Cxx/1RaOv/src/initialization.jl:23
 [4] top-level scope at /Users/storopoli/.julia/packages/Cxx/1RaOv/src/initialization.jl:25
 [5] include(::Module, ::String) at ./Base.jl:377
 [6] include(::String) at /Users/storopoli/.julia/packages/Cxx/1RaOv/src/Cxx.jl:144
 [7] top-level scope at /Users/storopoli/.julia/packages/Cxx/1RaOv/src/Cxx.jl:170
 [8] include(::Module, ::String) at ./Base.jl:377
 [9] top-level scope at none:2
 [10] eval at ./boot.jl:331 [inlined]
 [11] eval(::Expr) at ./client.jl:449
 [12] top-level scope at ./none:3
in expression starting at /Users/storopoli/.julia/packages/Cxx/1RaOv/src/initialization.jl:25
in expression starting at /Users/storopoli/.julia/packages/Cxx/1RaOv/src/Cxx.jl:170
ERROR: Failed to precompile Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2] to /Users/storopoli/.julia/compiled/v1.4/Cxx/ESGkI_rPtlm.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
 [3] _require(::Base.PkgId) at ./loading.jl:1029
 [4] require(::Base.PkgId) at ./loading.jl:927
 [5] require(::Module, ::Symbol) at ./loading.jl:922
Sinansi commented 4 years ago

julia> using Cxx [ Info: Precompiling Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2] ERROR: LoadError: LoadError: could not load library "C:\Users\Sannan.julia\packages\Cxx\1RaOv\src..\deps\usr\bin\libcxxffi" The specified procedure could not be found. Stacktrace: [1] dlopen(::String, ::UInt32; throw_error::Bool) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Libdl\src\Libdl.jl:109 [2] dlopen at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Libdl\src\Libdl.jl:109 [inlined] [3] init_libcxxffi() at C:\Users\Sannan.julia\packages\Cxx\1RaOv\src\initialization.jl:23 [4] top-level scope at C:\Users\Sannan.julia\packages\Cxx\1RaOv\src\initialization.jl:25 [5] include(::Function, ::Module, ::String) at .\Base.jl:380 [6] include at .\Base.jl:368 [inlined] [7] include(::String) at C:\Users\Sannan.julia\packages\Cxx\1RaOv\src\Cxx.jl:144 [8] top-level scope at C:\Users\Sannan.julia\packages\Cxx\1RaOv\src\Cxx.jl:170 [9] include(::Function, ::Module, ::String) at .\Base.jl:380 [10] include(::Module, ::String) at .\Base.jl:368 [11] top-level scope at none:2 [12] eval at .\boot.jl:331 [inlined] [13] eval(::Expr) at .\client.jl:467 [14] top-level scope at .\none:3 in expression starting at C:\Users\Sannan.julia\packages\Cxx\1RaOv\src\initialization.jl:25 in expression starting at C:\Users\Sannan.julia\packages\Cxx\1RaOv\src\Cxx.jl:170 ERROR: Failed to precompile Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2] to C:\Users\Sannan.julia\compiled\v1.5\Cxx\ESGkI_JHcjR.ji. Stacktrace: [1] error(::String) at .\error.jl:33 [2] compilecache(::Base.PkgId, ::String) at .\loading.jl:1290 [3] _require(::Base.PkgId) at .\loading.jl:1030 [4] require(::Base.PkgId) at .\loading.jl:928 [5] require(::Module, ::Symbol) at .\loading.jl:923

Sinansi commented 4 years ago

I use Julia 1.50 64-bit on Windows 10 64-bit

JacobPersi commented 3 years ago

I am also experiencing this issue on Window 10 (Julia v1.5.1 running on a jupyter notebook).

It seems that the path to libcxxffi is being incorrectly calculated within initialization.jl (see below).

@static if Sys.iswindows()
    const libcxxffi = joinpath(@__DIR__, "..", "deps", "usr", "bin", "libcxxffi"*lib_suffix)
else
    const libcxxffi = joinpath(@__DIR__, "..", "deps", "usr", "lib", "libcxxffi"*lib_suffix)
end

For me, this results in the following path: C:\Users\Jacob\.julia\packages\Cxx\1RaOv\src\..\deps\usr\bin\libcxxffi. However, I have libcxxffi.dll located within C:\Users\Jacob\.julia\packages\Cxx\1RaOv\deps\usr\bin\. The difference being \src\..\. This leads me to believe that for some reason, the 'up-one-directory' symbol isn't being interpreted on Windows.

I wrote some hacky code to try to fix this path (see below), however eve with this corrected libcxxffi is still failing to load.

@static if Sys.iswindows()
    last_directory_index = findlast(isequal('\\'), @__DIR__) - 1
    rootpath = @__DIR__
    rootpath = rootpath[1 : last_directory_index]
    const libcxxffi = joinpath(rootpath, "deps", "usr", "bin", "libcxxffi"*lib_suffix)
else
    const libcxxffi = joinpath(@__DIR__, "..", "deps", "usr", "lib", "libcxxffi"*lib_suffix)
end

For clarity sake, I've also uploaded an image of the error, and the folder. I assume the file format isn't important, but this also fails when appending ".dll" to the path.

Failed to load libcxxffi

QuantumBits commented 3 years ago

No idea what could be going wrong, but I do wanna point out you can use normpath(...) to remove the .. in the path :) https://docs.julialang.org/en/v1/base/file/#Base.Filesystem.normpath

I tried the same thing you did (but with normpath()) in Windows 10 with Julia 1.6.0-beta1 but no luck:

julia> using Cxx
[ Info: Precompiling Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2]
ERROR: LoadError: LoadError: could not load library "C:\Users\QuantumBits\.julia\dev\Cxx\deps\usr\bin\libcxxffi"
The specified procedure could not be found.
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl .\libdl.jl:114
  [2] dlopen
    @ .\libdl.jl:114 [inlined]
  [3] init_libcxxffi()
    @ Cxx.CxxCore ~\.julia\dev\Cxx\src\initialization.jl:23
  [4] top-level scope
    @ ~\.julia\dev\Cxx\src\initialization.jl:25
  [5] include(mod::Module, _path::String)
    @ Base .\Base.jl:386
  [6] include(x::String)
    @ Cxx.CxxCore ~\.julia\dev\Cxx\src\Cxx.jl:144
  [7] top-level scope
    @ ~\.julia\dev\Cxx\src\Cxx.jl:170
  [8] include
    @ .\Base.jl:386 [inlined]
  [9] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base .\loading.jl:1209
 [10] top-level scope
    @ none:1
 [11] eval
    @ .\boot.jl:360 [inlined]
 [12] eval(x::Expr)
    @ Base.MainInclude .\client.jl:446
 [13] top-level scope
    @ none:1
in expression starting at C:\Users\QuantumBits\.julia\dev\Cxx\src\initialization.jl:25
in expression starting at C:\Users\QuantumBits\.julia\dev\Cxx\src\Cxx.jl:142
ERROR: Failed to precompile Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2] to C:\Users\QuantumBits\.julia\compiled\v1.6\Cxx\jl_7ED7.tmp.
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:33
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::Base.TTY, internal_stdout::Base.TTY)
   @ Base .\loading.jl:1356
 [3] compilecache(pkg::Base.PkgId, path::String)
   @ Base .\loading.jl:1302
 [4] _require(pkg::Base.PkgId)
   @ Base .\loading.jl:1017
 [5] require(uuidkey::Base.PkgId)
   @ Base .\loading.jl:910
 [6] require(into::Module, mod::Symbol)
   @ Base .\loading.jl:897
Marc-3d commented 5 months ago

I stumbled upon the same problem in my windows machine with julia versions 1.8.5 and 1.10.1.

Following up on trying to diagnose the problem with libcxxffi, I used "DLL Export Viewer" on libcxxffi.dll and got the following output: nothing. It seems like no functions are being exported.

screenshot ![grafik](https://github.com/JuliaInterop/Cxx.jl/assets/28485345/57d9829b-2cf5-4ef7-b033-c292601d66a9)

In contrast, running the "DLL Export viewer" on all other libraries in the same directory shows a list of exported functions. For instance, this is the output for libdl.dll

screenshot ![grafik](https://github.com/JuliaInterop/Cxx.jl/assets/28485345/f60e26ed-a547-42fb-a78f-c6884f6e7b6a)

Until this bug is fixed, you will have to install julia 1.3.1. As pointed out in the README, Cxx works out of the box in this julia version.