简体   繁体   English

premake c ++“ hello world”错误

[英]premake c++ “hello world” error

I'm trying to get a premake4 helloworld c++ working but get an error when invoking make with release config after the makefile is created with premake. 我正在尝试使premake4 helloworld c ++正常工作,但是在使用premake创建makefile之后调用带有release config的make时出现错误。 (I'm using clang on osx 10.9.4) Calling make config=release produces: (我在osx 10.9.4上使用clang)调用make config=release会产生:

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

If I add the "Symbols" flag to the release flags everything works fine. 如果我将“ Symbols”标志添加到release标志,则一切正常。 But this of course creates debug symbols. 但这当然会创建调试符号。

premake4.lua: 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: main.cpp:

#include <iostream>

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

Any idea why it does not work like in the standard example? 知道为什么它不能像标准示例中那样工作吗? http://industriousone.com/post/typical-c-project-0 http://industriousone.com/post/typical-c-project-0

complete output using make config=release verbose=1 : 使用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

I was able to reproduce the error on my mac, OS X 10.10.2, using Premake4. 我可以使用Premake4在Mac OS X 10.10.2上重现该错误。 The problem is with your project name, which shouldn't have a .out extension. 问题出在您的项目名称上,该名称不应带有.out扩展名。 Try renaming project to "cpp_hello_world" in your premake4.lua file instead. 尝试在premake4.lua文件中将项目重命名为“ cpp_hello_world”。

ie line 4 should read: 即第4行应显示为:

    project "cpp_hello_world"

I can test and troubleshoot on a VM on 10.9.4 if you continue to encounter problems after making this change - let me know! 如果您在进行此更改后仍然遇到问题,则可以在10.9.4上的VM上进行测试和故障排除-让我知道!

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

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