clang linker problem

前端 未结 4 752
北荒
北荒 2021-01-04 20:18

I just tried out the latest llvm and clang trunk versions. They compiled without a single warning out of the box but I\'m having trouble linking a hello world example. My Co

4条回答
  •  礼貌的吻别
    2021-01-04 21:10

    On the most recent (3.5) release this sort of problem has cropped up again for anyone who does a build using the --with-gcc-toolchain configure option on a system with a pre-gcc 4.7 libstdc++ library installed.

    You'll see it in two flavors:

    echo '#include ' | clang++ -xc++ -
    :1:10: fatal error: 'string' file not found
    #include 
              ^
    1 error generated.
    

    ... as well as not being about to find the various crt files.

    In both cases, the following allows you to work around the problem until it gets fixed:

    printf '#include \nint main( int argc, char *argv[] ) { return 0; }' > /tmp/blah.cc
    # Fixes issue not finding C++ headers; note that it must be gcc >= 4.7
    clang++ --gcc-toolchain=/path/to/gcc/install -c -o /tmp/blah.o /tmp/blah.cc
    # Fixes the link error
    clang++ --gcc-toolchain=/path/to/gcc/install /tmp/blah.o /tmp/blah
    

提交回复
热议问题