【问题标题】:premake c++ "hello world" error预制 C++“你好世界”错误
【发布时间】:2014-07-27 10:21:55
【问题描述】:

我正在尝试让 premake4 helloworld c++ 工作 但是在使用 premake 创建 makefile 后使用 release config 调用 make 时会出错。 (我在 osx 10.9.4 上使用 clang) 调用make config=release 会产生:

ld: internal error: atom not found in symbolIndex(...

如果我将“符号”标志添加到发布标志,一切正常。 但这当然会创建调试符号。

premake4.lua:

solution "cpp_hello_world"
configurations { "Debug", "Release"}

project "cpp_hello_world.out"
kind "ConsoleApp"
language "C++"
files { "**.cpp" }

buildoptions { "-std=c++1y" } 

configuration "Debug"
defines { "DEBUG" }
flags { "Symbols" }

configuration "Release"
defines { "NDEBUG" }
flags { "Optimize" }

main.cpp:

#include <iostream>

int main(){
    std::cout << "hello world" << std::endl;
    return 0;
}

知道为什么它不像标准示例中那样工作吗? http://industriousone.com/post/typical-c-project-0

使用make config=release verbose=1完成输出:

==== Building cpp_hello_world.out (release) ====
Creating obj/Release
mkdir -p obj/Release
main.cpp
c++ -MMD -MP -DNDEBUG   -O2 -std=c++1y  -o "obj/Release/main.o" -c "main.cpp"
Linking cpp_hello_world.out
c++ -o ./cpp_hello_world.out obj/Release/main.o  -Wl,-x
ld: internal error: atom not found in symbolIndex(__ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cpp_hello_world.out] Error 1
make: *** [cpp_hello_world.out] Error 2

【问题讨论】:

  • 在 buildoptions 中,c++1y 是什么意思?
  • clang.llvm.org/cxx_status.html "C++1y 实现状态 Clang 3.4 及更高版本实现了即将到来的 C++ 语言标准的所有国际标准草案(参见最新公开的草案)......"
  • 如果我删除标志,它不会改变任何关于构建错误的内容
  • 它在带有 MinGW 的 Windows 上工作...您能否提供make config=release verbose=1 的输出以获取更多信息。
  • 你可以试试命令c++ -o ./cpp_hello_world.out obj/Release/main.o(没有-Wl,-x)吗?可能与x-link-flag-causing-link-errors-on-mac-osx-10-9-bug 有关

标签: c++ premake


【解决方案1】:

我能够使用 Premake4 在我的 Mac OS X 10.10.2 上重现该错误。问题在于您的项目名称,它不应该有 .out 扩展名。尝试在 premake4.lua 文件中将项目重命名为“cpp_hello_world”。

即第 4 行应为:

    project "cpp_hello_world"

如果您在进行此更改后仍然遇到问题,我可以在 10.9.4 上的 VM 上进行测试和故障排除 - 请告诉我!

【讨论】:

  • 您是否尝试在发布模式下构建?将项目名称更改为 project "cpp_hello_world" 并没有改变任何东西。我收到与我在问题中发布的相同的错误消息。
猜你喜欢
  • 1970-01-01
  • 2016-06-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-19
  • 1970-01-01
相关资源
最近更新 更多