Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ cpprestsdk:体系结构x86_64的未定义符号_C++_Xcode_Boost_Openssl_Libiconv - Fatal编程技术网

C++ cpprestsdk:体系结构x86_64的未定义符号

C++ cpprestsdk:体系结构x86_64的未定义符号,c++,xcode,boost,openssl,libiconv,C++,Xcode,Boost,Openssl,Libiconv,我已经访问了所有其他问题,但从我看到没有一个是我的问题 在MacBook Pro 16GB内存Intel Core I7上运行OS X El Capitan 10.11.6 我也运行过brew doctor,但没有发现任何会导致此问题的问题。下面是我的CMakeLists.txt文件: cmake_minimum_required(VERSION 3.0.0) project(WebClient VERSION 0.0.0) include(CheckCXXCompilerFlag) CHEC

我已经访问了所有其他问题,但从我看到没有一个是我的问题

在MacBook Pro 16GB内存Intel Core I7上运行OS X El Capitan 10.11.6

我也运行过brew doctor,但没有发现任何会导致此问题的问题。下面是我的CMakeLists.txt文件:

cmake_minimum_required(VERSION 3.0.0)
project(WebClient VERSION 0.0.0)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPLIER_SUPPORTS_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPLIER_SUPPORTS_CXX0X)
if(COMPLIER_SUPPORTS_CXX14)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
    message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support.
                    Please use a different C++ compiler.")
endif()

FIND_PACKAGE( Boost 1.62 COMPONENTS program_options REQUIRED )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )

set(OPT_CPPFLAGS "-I/usr/local/opt/openssl/include -I/usr/local/opt/libiconv/include")
set(OPT_LDFLAGS "-v -lcpprest -lboost_system -L/usr/local/opt/openssl/lib -L/usr/local/opt/libiconv/lib -lcrypto -lssl")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPT_CPPFLAGS} -v -g -O3 -fno-common -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPT_LDFLAGS}")

add_executable(anyExecutable webclient.cpp)

TARGET_LINK_LIBRARIES( anyExecutable ${Boost_LIBRARIES} )

include(CPack)
我使用brew安装了cpprestsdk/2.8.0,其中还包括boost/1.62.0、openssl/1.0.2j和libiconv/1.14。我的代码来自wiki cpprestsdk的教程

#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <atomic>

using namespace utility;                    // Common utilities like string conversions
using namespace web;                        // Common features like URIs.
using namespace web::http;                  // Common HTTP functionality
using namespace web::http::client;          // HTTP client features
using namespace concurrency::streams;       // Asynchronous streams

int main(int argc, char* argv[]) {
  auto fileStream = std::make_shared<ostream>();

  // Open stream to output file.
  pplx::task<void> requestTask = fstream::open_ostream( U("results.xml") ).then(
    [=](ostream outFile) {
        *fileStream = outFile;

        // Create http_client to send the request.
        http_client client(U("http://www.dictionaryapi.com/api/v1/references/"));

        // Build request URI and start the request.
        uri_builder builder(U("thesaurus/xml/"));
        builder.append_path(U("ranking"),true);
        builder.append_query(U("?key"), U("--------------------"));
        return client.request(methods::GET, builder.to_string());
  })

  // Handle response headers arriving.
  .then( [=](http_response response ) {
    printf("Received response status code:%u\n", response.status_code());

    // Write response body into the file.
    return response.body().read_to_end(fileStream->streambuf());
  })

  // Close the file stream.
  .then( [=](size_t ) {
    return fileStream->close();
  });

  // Wait for all the outstanding I/O to complete and handle any exceptions
  try {
    requestTask.wait();
  } catch (const std::exception &e) {
    printf("Error exception:%s\n", e.what());
  }//try-catch BLOCK

  return 0;
}//Main
#包括
#包括
#包括
使用命名空间实用程序;//常见的实用程序,如字符串转换
使用命名空间web;//常见的功能,如URI。
使用命名空间web::http;//通用HTTP功能
使用命名空间web::http::client;//HTTP客户端功能
使用命名空间并发::streams;//异步流
int main(int argc,char*argv[]){
auto fileStream=std::make_shared();
//打开流以输出文件。
pplx::task requestTask=fstream::open_ostream(U(“results.xml”))。然后(
[=](ostream输出文件){
*fileStream=outFile;
//创建http_客户端以发送请求。
http_客户端(U)http://www.dictionaryapi.com/api/v1/references/"));
//生成请求URI并启动请求。
uri_生成器(U(“同义词库/xml/”);
生成器。附加路径(U(“排名”),true);
builder.append_查询(U(“?key”)、U(“------------------”);
返回client.request(方法::GET,builder.to_string());
})
//处理到达的响应头。
。然后([=](http_响应){
printf(“收到的响应状态代码:%u\n”,response.status_code());
//将响应主体写入文件。
返回response.body();
})
//关闭文件流。
。然后([=](大小){
返回fileStream->close();
});
//等待所有未完成的I/O完成并处理任何异常
试一试{
requestTask.wait();
}捕获(const std::exception&e){
printf(“错误异常:%s\n”,例如what());
}//试挡
返回0;
}//主要
要节省一些空间,请仅打印一些错误,但找不到这些错误:

    [vscode] Executing cmake command: cmake --build /Users/gumpy/git-repos/webapi/build --target all --config Debug -- -j 10
[ 50%] Building CXX object CMakeFiles/anyExecutable.dir/webclient.cpp.o
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name webclient.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.1 -v -dwarf-column-info -debug-info-kind=standalone -dwarf-version=2 -debugger-tuning=lldb -coverage-file /Users/gumpy/git-repos/webapi/build/CMakeFiles/anyExecutable.dir/webclient.cpp.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0 -I /usr/local/include -I /usr/local/opt/openssl/include -I /usr/local/opt/libiconv/include -stdlib=libc++ -O3 -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /Users/gumpy/git-repos/webapi/build -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o CMakeFiles/anyExecutable.dir/webclient.cpp.o -x c++ /Users/gumpy/git-repos/webapi/webclient.cpp
clang -cc1 version 8.0.0 (clang-800.0.38) default target x86_64-apple-darwin15.6.0
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring duplicate directory "/usr/local/include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/opt/openssl/include
 /usr/local/opt/libiconv/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
[100%] Linking CXX executable anyExecutable
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o anyExecutable -L/usr/local/opt/openssl/lib -L/usr/local/opt/libiconv/lib -search_paths_first -headerpad_max_install_names -lcpprest -lboost_system -lcrypto -lssl CMakeFiles/anyExecutable.dir/webclient.cpp.o /usr/local/lib/libboost_program_options-mt.dylib -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "boost::this_thread::interruption_point()", referenced from:
      boost::condition_variable::wait(boost::unique_lock<boost::mutex>&) in webclient.cpp.o
      boost::condition_variable::do_wait_until(boost::unique_lock<boost::mutex>&, timespec const&) in webclient.cpp.o
  "boost::chrono::steady_clock::now()", referenced from:
      pplx::details::event_impl::wait(unsigned int) in webclient.cpp.o
  "boost::chrono::system_clock::now()", referenced from:
      pplx::details::event_impl::wait(unsigned int) in webclient.cpp.o
  "boost::detail::get_current_thread_data()", referenced from:
      boost::detail::interruption_checker::interruption_checker(_opaque_pthread_mutex_t*, _opaque_pthread_cond_t*) in webclient.cpp.o
ld: symbol(s) not found for architecture x86_64
[vscode]执行cmake命令:cmake--build/Users/gumpy/git repos/webapi/build--target all--config Debug--j 10
[50%]构建CXX对象cmakfiles/anyExecutable.dir/webclient.cpp.o
苹果LLVM 8.0.0版(clang-800.0.38)
目标:x86_64-apple-darwin15.6.0
线程模型:posix
InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/xcodefault.xctoolchain/usr/bin
“/Applications/Xcode.app/Contents/Developer/toolschains/xcodefault.xctoolschain/usr/bin/clang”-cc1-三重x86_64-apple-macosx10.11.0-Wdeprecated objc isa用法-Werror=不推荐的objc isa用法-emit obj-禁用自由-禁用llvm验证器-丢弃值名称-主文件名webclient.cpp-mrelocation model pic-pic level 2-多线程模型posix-MDISabled fp elim-masm verbose-munwind tables-目标cpu core2-目标链接器版本274.1-v-dwarf column info-debug info kind=standalone-dwarf version=2-debugger tuning=lldb-coverage file/Users/gumpy/git repos/webapi/build/CMakeFiles/anyExecutable.dir/webclient.cpp.o-resource dir/Applications/Xcode.app/Contents/Developer/toolschains/XcodeDefault.xcodefault.xtoolchain/lib/clang/8.0-I/usr/local/include-I/usr/local/opt/openssl/include-I/usr/local/opt/libiconv/include-stdlib=libc++-O3-std=c++14-fdeprecated宏-fdebug编译目录/Users/gumpy/git repos/webapi/build-feror limit 19-fmessage length 0-stack protector 1-fblock-fobjc runtime=macosx-10.11.0-fencode扩展块签名-fcxx异常-feexceptions- FMAX类型ALIGN=16 -FNO通用FC++诊断选项-矢量化循环-矢量化SLP -O cMaMeCase/AyExcRetuabd.DR/WebCopy.CPP.O-XC++/Ups/GUMYP/GIT-RePoS/WebAPI/Webclit.CPP
clang-cc1版本8.0.0(clang-800.0.38)默认目标x86_64-apple-darwin15.6.0
忽略不存在的目录“/usr/include/c++/v1”
忽略重复目录“/usr/local/include”
因为它是与系统目录重复的非系统目录
#包括“…”搜索从这里开始:
#包括搜索从这里开始:
/usr/local/opt/openssl/include
/usr/local/opt/libiconv/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/./include/c++/v1
/usr/本地/包括
/Applications/Xcode.app/Contents/Developer/toolschains/XcodeDefault.xctoolschain/usr/bin/./lib/clang/8.0.0/include
/Applications/Xcode.app/Contents/Developer/toolschains/xcodefault.xctoolschain/usr/include
/usr/包括
/系统/库/框架(框架目录)
/库/框架(框架目录)
搜索列表结束。
[100%]将CXX可执行文件链接到任何可执行文件
苹果LLVM 8.0.0版(clang-800.0.38)
目标:x86_64-apple-darwin15.6.0
线程模型:posix
InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/xcodefault.xctoolchain/usr/bin
“/Applications/Xcode.app/Contents/Developer/toolschains/xcodefault.xctoolschain/usr/bin/ld”-demangle-dynamic-arch x86\u 64-macosx\u version\u min 10.11.0-o anyExecutable-L/usr/local/opt/openssl/lib-L/usr/local/opt/libiconv/lib-search\u paths\u first-headerpad\u max\u install\u name-lcpprest-lboost\u系统-lcrypto-lsl cmakfiles/anyExecutable.dir/webclient.cpp.o/usr/local/lib/libboost\u程序\u options-mt.dylib-lc++-lSystem/Applications/Xcode.app/Contents/Developer/toolschains/XcodeDefault.xctoolchain/usr/bin/./lib/clang/8.0.0/lib/darwin/libclang\u rt.osx.a
架构x86_64的未定义符号:
“boost::this_thread::interruption_point()”,引用自:
webclient.cpp.o中的boost::condition_变量::wait(boost::unique_lock&)
boost::condition_variable::do_wait_until(boost::unique_lock&,timespec const&)在webclient.cpp.o中
“boost::chrono::Standy_clock::now()”,引用自:
pplx::详细信息::事件执行::等待
-lboost_system -lssl -lcpprest -lboost_chrono
  "web::uri_builder::append_path(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:
      std::__1::__function::__func<main::$_0, std::__1::allocator<main::$_0>, pplx::task<web::http::http_response> (Concurrency::streams::basic_ostream<unsigned char>)>::operator()(Concurrency::streams::basic_ostream<unsigned char>&&) in webclient.cpp.o
  "web::uri_builder::append_query(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:
      web::uri_builder& web::uri_builder::append_query<char [37]>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [37], bool) in webclient.cpp.o
  "web::uri_builder::to_string()", referenced from:
      std::__1::__function::__func<main::$_0, std::__1::allocator<main::$_0>, pplx::task<web::http::http_response> (Concurrency::streams::basic_ostream<unsigned char>)>::operator()(Concurrency::streams::basic_ostream<unsigned char>&&) in webclient.cpp.o
  "web::uri::encode_impl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::function<bool (int)> const&)", referenced from:
      web::uri_builder& web::uri_builder::append_query<char [37]>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [37], bool) in webclient.cpp.o
  ...
Undefined symbols for architecture x86_64:
  "boost::this_thread::interruption_point()", referenced from:
      boost::condition_variable::wait(boost::unique_lock<boost::mutex>&) in webclient.cpp.o
      boost::condition_variable::do_wait_until(boost::unique_lock<boost::mutex>&, timespec const&) in webclient.cpp.o
  "boost::chrono::steady_clock::now()", referenced from:
      pplx::details::event_impl::wait(unsigned int) in webclient.cpp.o
  "boost::chrono::system_clock::now()", referenced from:
      pplx::details::event_impl::wait(unsigned int) in webclient.cpp.o
  "boost::detail::get_current_thread_data()", referenced from:
      boost::detail::interruption_checker::interruption_checker(_opaque_pthread_mutex_t*, _opaque_pthread_cond_t*) in webclient.cpp.o
ld: symbol(s) not found for architecture x86_64
set(OPT_CPPFLAGS "-I/usr/local/opt/openssl/include -I/usr/local/opt/libiconv/include")
CPPFLAGS = -stdlib=libc++
LDFLAGS = -lcpprest -lboost_system -lboost_thread-mt -lboost_chrono-mt -lssl -lcrypto