ACE在MAC OS X 10.9(及更高版本)中的链接器失败

时间:2014-11-18 09:23:50

标签: c++ macos linker clang++ ace

我正在尝试使用CLANG ++编译并在MAC OS X 10.9中运行以下简单代码:

#include "ACE_wrappers/ace/MEM_Stream.h"
#include <iostream>

int main()
{
        std::cout << "Hello World" << std::endl;
        ACE_MEM_Stream m(3);
        m.close_reader();
        return 0;
}

但是我收到以下错误:

QAs-MacBook:aceTestLinking Moamen$ clang++ myTest.cpp 
Undefined symbols for architecture x86_64:
  "ace_os_main_i(int, char**)", referenced from:
       _main in moamen-511a28.o
  "ACE_SOCK::ACE_SOCK()", referenced from:
       ACE_MEM_IO::ACE_MEM_IO() in moamen-511a28.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

编译行:

clang++ myTest.cpp

我正在使用的CLANG编译器版本:

QAs-MacBook:aceTestLinking Moamen$ clang++ --version
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

注意 - 我还尝试使用&#34; -std = c ++ 11&#34;,&#34; -stdlib = libstdc ++&#34;进行编译,如以下主题所示: C++ linking error after upgrading to Mac OS X 10.9 / Xcode 5.0.1   但没有解决问题。

谢谢,

Moamen

1 个答案:

答案 0 :(得分:0)

感谢回复,经过对Linux Ubuntu的一些调查后,我成功使用以下命令编译代码:g ++ -o m.out myTest.cpp ACE_wrappers / lib / libACE.a -I ACE_wrappers / -lpthread -ldl。似乎缺少一些默认的库!