TL; DR:构建于OS X 10.8上的基于文本的C++ 11/Boost/Openssl应用程序。这个编译后的二进制文件是否应该在10.9和10.10时保持不变?还是我必须为每个版本编译它?在OS X 10.8上编译的C++文本应用程序是否可以在10.9和10.10上运行?
详细:
C++ 11的应用程序和静态库,使用OpenSSL的,和boost ::正则表达式,提高:: ASIO,和boost ::系统。我使用的是cmake(因为这是Linux + Windows的一个端口),所有东西都可以在10.8.2 [Mountain Lion]上正常运行。
但是,当安装在新 OS X应用程序,如10.9,我们看到这样的错误:
dyld: Symbol not found: __ZTISt16invalid_argument
Referenced from: /usr/bin/myapp
Expected in: /usr/local/lib/libboost_regex-mt.dylib
in /usr/bin/myapp
Trace/BPT trap: 5
libboost_regex-mt.dylib没有找到__ZTISt16invalid_argument
。我猜std::invalid_argument
应该在libC++中,所以出了点问题。 (是这部分的libstdC++与的libC++的问题,我不断听到?)
我这是怎么找到我的函数库的依赖在cmake的:
SET (Boost_DEBUG 0)
SET (Boost_USE_STATIC_LIBS OFF)
SET (Boost_USE_MULTITHREADED ON)
SET (Boost_USE_STATIC_RUNTIME OFF) # also tried "ON"
FIND_PACKAGE (Boost REQUIRED COMPONENTS regex system date_time)
FIND_PACKAGE (OpenSSL REQUIRED)
FIND_PACKAGE (Threads REQUIRED)
这些都是我全力打造集标志:
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic -std=c++11 -stdlib=libc++ -DMAC_OS_X_VERSION_MIN_REQUIRED=1000")
当我第一运行cmake
它显示以下内容:
-- The C compiler identification is AppleClang 5.1.0.5030040
-- The CXX compiler identification is AppleClang 5.1.0.5030040
...
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features - done
这似乎是一个链接错误,你必须照顾与'link_directories'和'target_link_libraries'命令的东西(见CMake的文档) – Antonio 2015-04-01 12:20:13