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

Could not find C++ standard library #315

Closed
wbhart opened this issue Jan 10, 2017 · 6 comments
Closed

Could not find C++ standard library #315

wbhart opened this issue Jan 10, 2017 · 6 comments

Comments

@wbhart
Copy link

wbhart commented Jan 10, 2017

We are getting the following error when trying to use Cxx on a Gentoo system (with a Julia source tree built at a commit that is known to work elsewhere with Cxx).

I am not at all able to guess what is going on. Do you have any idea what might be causing this issue?

while loading /home2/hannes/.julia/v0.6/Cxx/src/utils.jl, in expression starting on line 51
ERROR: LoadError: LoadError: InitError: Could not find C++ standard library
 in AddLinuxHeaderPaths(::Cxx.ClangCompiler) at /home2/hannes/.julia/v0.6/Cxx/src/initialization.jl:298
 in addStdHeaders at /home2/hannes/.julia/v0.6/Cxx/src/initialization.jl:322 [inlined]
 in #initialize_instance!#33(::Bool, ::Function, ::Cxx.ClangCompiler) at /home2/hannes/.julia/v0.6/Cxx/src/initialization.jl:354
 in __init__() at /home2/hannes/.julia/v0.6/Cxx/src/initialization.jl:370
 in include_from_node1(::String) at ./loading.jl:532
 in eval(::Module, ::Any) at ./boot.jl:236
 in require(::Symbol) at ./loading.jl:446
 in include_from_node1(::String) at ./loading.jl:532
 in eval(::Module, ::Any) at ./boot.jl:236
 in require(::Symbol) at ./loading.jl:446
during initialization of module Cxx
while loading /home2/hannes/.julia/v0.6/Cxx/src/Cxx.jl, in expression starting on line 166
while loading /home2/hannes/.julia/v0.6/Singular/src/Singular.jl, in expression starting on line 4
@wbhart
Copy link
Author

wbhart commented Jan 10, 2017

It looks like the C++ includes it is looking for on Gentoo are in:

/usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/include/g++-v4

@wbhart
Copy link
Author

wbhart commented Jan 12, 2017

In fact we got Cxx working on our particular Gentoo machines (which have gcc 4.9.4) by overriding where the header files are set in initialization.jl, with:

addHeaderDir(C, "/usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/include/g++-v4", kind = C_System)
addHeaderDir(C, "/usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/include/g++-v4/x86_64-pc-linux-gnu", kind = C_System)

That probably gives enough information to come up with a solution for this issue, I think.

@JonathanAnderson
Copy link

I'm having an issue too with finding the C++ library on a centos system.

julia_release-0.6 git:release-0.6 ❯ ./julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0-rc3.0 (2017-06-07 11:53 UTC)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |  x86_64-redhat-linux

julia> using OhMyREPL

julia> using Cxx
String["/opt/rh/devtoolset-3/root"]
ERROR: LoadError: InitError: Could not find C++ standard library
Stacktrace:
 [1] AddLinuxHeaderPaths(::Cxx.ClangCompiler) at /home/janders/.julia/v0.6/Cxx/src/initialization.jl:299
 [2] addStdHeaders at /home/janders/.julia/v0.6/Cxx/src/initialization.jl:323 [inlined]
 [3] #initialize_instance!#33(::Bool, ::Function, ::Cxx.ClangCompiler) at /home/janders/.julia/v0.6/Cxx/src/initialization.jl:355
 [4] __init__() at /home/janders/.julia/v0.6/Cxx/src/initialization.jl:371
 [5] include_from_node1(::String) at ./loading.jl:569
 [6] eval(::Module, ::Any) at ./boot.jl:235
 [7] _require(::Symbol) at ./loading.jl:483
 [8] require(::Symbol) at ./loading.jl:398
during initialization of module Cxx
while loading /home/janders/.julia/v0.6/Cxx/src/Cxx.jl, in expression starting on line 169

I added a println to show me the Prefixes in initialization.jl and Its finding devtoolset-3 instead of devtoolset-6. I tried adding the correct directory to ./deps/src/clang-3.9.1/lib/Driver/ToolChains.cpp and rebuilding and this doesn't work.

If I patch the following diff then everything works just fine.

--- a/src/initialization.jl
+++ b/src/initialization.jl
@@ -271,7 +271,8 @@ function AddLinuxHeaderPaths(C)


     CXXJL_ROOTDIR = get(ENV, "CXXJL_ROOTDIR", "/usr")
-    const Prefixes = [ CXXJL_ROOTDIR ]
+    const Prefixes = [ CXXJL_ROOTDIR, "/opt/rh/devtoolset-6/root/usr" ]

     LibDirs = (Int === Int64 ? X86_64LibDirs : X86LibDirs)
     Triples = (Int === Int64 ? X86_64Triples : X86Triples) 

I'm leaving this here to help others and since I'm not sure how to fix this issue in a robust way.

@lyon-fnal
Copy link

Hi - I have the same problem too. My gcc comes from an unusual place, but I have an environment variable. Like @JonathanAnderson 's solution, I had to change

const Prefixes = [ CXXJL_ROOTDIR ] 
# To
const Prefixes = [ CXXJL_ROOTDIR, ENV["GCC_FQ_DIR"] ]

Any way somehow make this part of the build?

@VPetukhov
Copy link

@wbhart Thank you for your suggestion! It doesn't work for me, but it helped to fix the problem (dirty ugly fix). ~/.julia/v0.6/Cxx/src/initialization.jl has function ScanLibDirForGCCTriple(base,triple), which tries to find gcc headers and throws the error. So, I replaced its whole content to hardcoded paths:

function ScanLibDirForGCCTriple(base,triple)
    VersionString = "6.4.0"
    Version = VersionNumber(VersionString)
    GccPath = "/usr/lib64/gcc/x86_64-pc-linux-gnu/6.4.0/"
    return (Version, VersionString, GccPath)
end

After that, I specified include paths, relative to GccPath by changing incpath value and replacing all push!(headers, ...) in CollectLinuxHeaderPaths function with my include paths. Particularly, for me it was:

incpath = Path * "/include"

push!(headers, (incpath, C_System))
push!(headers, (incpath * "/g++-v6/", C_System))
push!(headers, (incpath * "/g++-v6/x86_64-pc-linux-gnu/", C_System))

@Gnimuc
Copy link
Member

Gnimuc commented Dec 29, 2019

Fixed in #448

@Gnimuc Gnimuc closed this as completed Dec 29, 2019
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

5 participants