GVKun编程网logo

ios – 为什么我的应用程序突然没有构建并抱怨这些“ld”和“clang”错误?

1

对于ios–为什么我的应用程序突然没有构建并抱怨这些“ld”和“clang”错误?感兴趣的读者,本文将会是一篇不错的选择,并为您提供关于/opt/rh/llvm-toolset-7/root/usr/

对于ios – 为什么我的应用程序突然没有构建并抱怨这些“ld”和“clang”错误?感兴趣的读者,本文将会是一篇不错的选择,并为您提供关于/opt/rh/llvm-toolset-7/root/usr/bin/clang: Command not found、brew install php55 报错 clang: error、C 11代码用`clang`编译,但不用`clang -x c`编译、C++ Clang 发出有关未使用模板变量的警告 C++ Clang 发出有关未使用模板变量的警告的有用信息。

本文目录一览:

ios – 为什么我的应用程序突然没有构建并抱怨这些“ld”和“clang”错误?

ios – 为什么我的应用程序突然没有构建并抱怨这些“ld”和“clang”错误?

这些错误让我很困惑,我不知道我做了什么来触发它们:
ld: warning: directory not found for option '-F/"..."'
ld: warning: ignoring file "..."/iOS 7/Crashlytics.framework/Crashlytics,file was built for unsupported file format ( 0x56 0x65 0x72 0x73 0x69 0x6F 0x6E 0x73 0x2F 0x43 0x75 0x72 0x72 0x65 0x6E 0x74 ) which is not the architecture being linked (i386): /"..."/Crashlytics.framework/Crashlytics
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_Crashlytics",referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command Failed with exit code 1 (use -v to see invocation)

我不知道它在说什么.我如何解决它?

解决方法

您链接到项目的框架版本仅适用于Device.使用fabric桌面应用程序将正确的框架链接到项目.

/opt/rh/llvm-toolset-7/root/usr/bin/clang: Command not found

/opt/rh/llvm-toolset-7/root/usr/bin/clang: Command not found

# yum -y install centos-release-scl centos-release-scl-rh;
#yum -y install scl-utils scl-utils-build;
#yum -y install llvm-toolset-7;

# scl --list
devtoolset-7
llvm-toolset-7

# scl enable llvm-toolset-7 bash

# source /opt/rh/llvm-toolset-7/enable 

# lldb -version
lldb version 5.0.1

# which clang
/opt/rh/llvm-toolset-7/root/usr/bin/clang

# clang --version                   
clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rh/llvm-toolset-7/root/usr/bin

clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rh/llvm-toolset-7/root/usr/bin

brew install php55 报错 clang: error

brew install php55 报错 clang: error

clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: symbol(s) not found for architecture x86_64
make: *** [sapi/fpm/php-fpm] Error 1
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libs/libphp5.bundle] Error 1

解决办法:

brew install libxml2
brew link libxml2 --force

C 11代码用`clang`编译,但不用`clang -x c`编译

C 11代码用`clang`编译,但不用`clang -x c`编译

基本问题

我有以下代码

#include <iostream>
#include <cstdint>
using namespace std;
int main ()
{
  int32_t spam;
  spam=5;
  cout << "Hello World! We like " << spam << endl;
  return 0;
}

当我做clang -stdlib = libc cpptest.cpp时,这很好地编译.但是,Sublime Text 2的优秀SublimeClang解析器似乎并不理解它.我想这可能是因为它使用了clang -xc而不是clang,并尝试使用clang -xc -std = c 11 -stdlib = libc cpptest.cpp(或其中的各种排列)来编译我的代码段,但是失败了可怕的是,抱怨链接器.

所以我的问题是,clang与clang -x c有什么不同?是否有可能使用clang -x c而不是clang来编译上述代码片段?

我的机器是2012款运行Mountain Lion的MacBook Air.

调试东西

现在回到工作中,我已经玩了更多,并比较了不同版本的详细输出.

叫clang -x c

当我运行clang -v -x c -stdlib = libc cpptest.cpp时,我得到了

Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.1
Thread model: posix
 "/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name cpptest.cpp -pic-level 1 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 134.9 -v -resource-dir /usr/bin/../lib/clang/4.1 -fmodule-cache-path /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/clang-module-cache -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/me/Desktop -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/cpptest-1eOyZn.o -x c++ cpptest.cpp
clang -cc1 version 4.1 based upon LLVM 3.1svn default target x86_64-apple-darwin12.2.1
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/c++/v1
 /usr/local/include
 /usr/bin/../lib/clang/4.1/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o a.out /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/cpptest-1eOyZn.o -lSystem /usr/bin/../lib/clang/4.1/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
[snip]
ld: symbol(s) not found for architecture x86_64
clang: error: linker command Failed with exit code 1 (use -v to see invocation)

打电话给铿锵声

当我调用clang -v -stdlib = libc cpptest.cpp时,我得到以下内容.

clang++ -v -stdlib=libc++ cpptest.cpp 
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.1
Thread model: posix
 "/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name cpptest.cpp -pic-level 1 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 134.9 -v -resource-dir /usr/bin/../lib/clang/4.1 -fmodule-cache-path /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/clang-module-cache -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/me/Desktop -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/cpptest-E7FTDV.o -x c++ cpptest.cpp
clang -cc1 version 4.1 based upon LLVM 3.1svn default target x86_64-apple-darwin12.2.1
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/c++/v1
 /usr/local/include
 /usr/bin/../lib/clang/4.1/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o a.out /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/cpptest-E7FTDV.o -lc++ -lSystem /usr/bin/../lib/clang/4.1/lib/darwin/libclang_rt.osx.a

差异和解决方案?

我能找到的唯一主要区别是,当我使用-x c标志运行clang时,-c标志不会在以“/usr/bin/lb”开头的行的末尾添加.当我用clang -v -lc -x c -stdlib = libc cpptest.cpp进行编译时,一切正常.我仍然不明白clang和clang -x c命令究竟是如何区别的,但这似乎使我的示例程序至少编译,并且似乎表明这些命令与链接器做了不同的事情.

解决我的Sublime Text 2问题

这整个小虫狩猎开始于我试图弄清楚如何让Sublime Text 2停止抱怨我实际上有效的代码,现在我想我已经得到了它.所需要的只是按照指令here并将包含设置为

/usr/lib/c++/v1
/usr/include/c++/4.2.1
/usr/include/c++/4.2.1/ext

在SublimeClang.sublime-settings文件中.

解决方法

你是对的.只有连接阶段才有区别.您可以运行clang只是为了使用-c标志进行编译,您将获得相同的结果.

然后你添加-lc标志,两个样本都是一样的.

C++ Clang 发出有关未使用模板变量的警告 C++ Clang 发出有关未使用模板变量的警告

C++ Clang 发出有关未使用模板变量的警告 C++ Clang 发出有关未使用模板变量的警告

如何解决C++ Clang 发出有关未使用模板变量的警告 C++ Clang 发出有关未使用模板变量的警告

C++ Clang 发出有关未使用模板变量的警告

考虑一个未使用的模板变量定义,例如这个:

template <typename T,typename = void>
struct is_complete : std::false_type {};
template <typename T>
struct is_complete<T,std::void_t<decltype(sizeof(T))>>
    : std::true_type {};
template <typename T>
constexpr static inline auto is_complete_v = is_complete<T>::value;

在这里,Clang 发出有关未使用的 is_complete_v 变量的警告,这在我看来是错误的。
如果未使用,为什么会完全实例化此类变量符号?也许我错过了一点。

warning: unused variable ''is_complete_v'' [-Wunused-const-variable]
    static inline constexpr auto is_complete_v = is_complete_v<T>::value;
           

情况是,其他编译器如 GCC 不会发出任何警告。
哪个 IMOO 有意义,因为符号未解析。

我可以使用以下任一方法修复我正在使用的所有代码库:

template <typename T>
#if __clang__
[[maybe_unused]]
#endif
constexpr static inline auto is_complete_v = is_complete<T>::value;

或者禁用-Wunused-const-variable

但我想知道:

  • 是否有更简洁的方法来实现这一目标?
  • 这是正常行为吗?

解决方法

Clang“未使用”类诊断的启发式方法似乎根本不检查每个实例,而是检查未实例化的模板本身。

我自己也遇到过类似的问题,特别是在依赖模板函数中的构造函数来产生副作用(对于 RAII 等)时。当 Clang 需要知道传递的模板参数以确定使用的构造函数时,它天真地将构造函数视为纯构造函数并将构造的变量标记为未使用(<template> <breeze-authenticated-layout> <template #header> <h2> Foto Hotel </h2> </template> <div> <img :src="this.data" /> </div> </breeze-authenticated-layout> </template> <script> import BreezeAuthenticatedLayout from ''@/Layouts/Authenticated'' export default { components: { BreezeAuthenticatedLayout,},props: [''data'',''test''],data () { return { image: this.data } },} </script> ),但如果可以在不实例化的情况下确定构造函数模板,那么它不会标记未使用的变量,因为它可以确定构造函数产生了可观察到的副作用。

在您的情况下,因为您的模板很可能在头文件中,所以它是否标记为 Wunused-variable 没有区别。使用 type traits 库“可能的实现”作为指导,避免将这些模板值标记为 static 以避免诊断。

关于ios – 为什么我的应用程序突然没有构建并抱怨这些“ld”和“clang”错误?的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于/opt/rh/llvm-toolset-7/root/usr/bin/clang: Command not found、brew install php55 报错 clang: error、C 11代码用`clang`编译,但不用`clang -x c`编译、C++ Clang 发出有关未使用模板变量的警告 C++ Clang 发出有关未使用模板变量的警告等相关内容,可以在本站寻找。

本文标签: