简体   繁体   English

从命令行使用clang编译:兼容性问题mac os X.

[英]compile with clang from the command line: compatibility issues mac os X

I am compiling a c++14 project on MacOsX10.10 using cmake, clang++, boost and openCV (static linkage - compilation flags: -Wall -std=c++14 -O3). 我正在使用cmake,clang ++,boost和openCV(静态链接 - 编译标志:-Wall -std = c ++ 14 -O3)在MacOsX10.10上编译c ++ 14项目。 How can I make sure the program runs out-of-the-box in older MacOsX versions? 如何确保程序在较旧的MacOsX版本中开箱即用? (and in other mac computers as well?) I've tested the binary on an older macbook running os X 10.7 and it failed. (还有其他的mac计算机?)我在运行os X 10.7的旧版macbook上测试了二进制文件,但它失败了。 With xcode it's possible to build a program against some particular SDK, can I do something similar from the command line? 使用xcode可以针对某个特定的SDK构建程序,我可以从命令行执行类似的操作吗?

PS This is a more general question, but the source code for this particular project can be found here: https://github.com/MarinosK/oiko-nomic-threads PS这是一个更普遍的问题,但这个特定项目的源代码可以在这里找到: https//github.com/MarinosK/oiko-nomic-threads

You need to make sure that all dependencies are linked statically into your executable. 您需要确保所有依赖项都静态链接到您的可执行文件中。 So this not only includes the .a (static libraries or object archives) but also the C++ (and possibly C) standard libraries. 因此,这不仅包括.a(静态库或对象存档),还包括C ++(可能还有C)标准库。

For example: 例如:

clang --std=c++14 -stdlib=libstdc++ main.cpp -o main thirdparty.a -static -lstdc++

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM