简体   繁体   中英

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. (I'm using clang on osx 10.9.4) Calling make config=release produces:

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

If I add the "Symbols" flag to the release flags everything works fine. But this of course creates debug symbols.

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;
}

Any idea why it does not work like in the standard example? http://industriousone.com/post/typical-c-project-0

complete output using 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. The problem is with your project name, which shouldn't have a .out extension. Try renaming project to "cpp_hello_world" in your premake4.lua file instead.

ie line 4 should read:

    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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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