2

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
0ax1
  • 475
  • 3
  • 11
  • in buildoptions, what does `c++1y` mean? – kobigurk Jul 27 '14 at 10:24
  • http://clang.llvm.org/cxx_status.html "C++1y implementation status Clang 3.4 and later implement all of the Draft International Standard (see most recent publicly available draft) of the upcoming C++ language standard..." – 0ax1 Jul 27 '14 at 10:26
  • it does not change anything about the build error if I remove the flag – 0ax1 Jul 27 '14 at 10:29
  • It works here on windows with MinGW... Can you provide the output of `make config=release verbose=1` to have extra information. – Jarod42 Jul 27 '14 at 10:47
  • 2
    Can you try the command `c++ -o ./cpp_hello_world.out obj/Release/main.o` (without the `-Wl,-x`) ? maybe related to [x-link-flag-causing-link-errors-on-mac-osx-10-9-bug](http://stackoverflow.com/questions/24921221/x-link-flag-causing-link-errors-on-mac-osx-10-9-bug) – Jarod42 Jul 27 '14 at 11:22
  • that seems to be the problem! if I remove `-Wl,-x` it compiles succesfully. but how can I fix this in premake? – 0ax1 Jul 27 '14 at 11:33
  • I suggest to look directly on there forum. [how-remove-flags-ldflags](http://industriousone.com/topic/how-remove-flags-ldflags) – Jarod42 Jul 27 '14 at 11:37
  • thanks a lot! I'll do that. – 0ax1 Jul 27 '14 at 11:41

1 Answers1

0

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.

i.e. 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!

tnbeatty
  • 315
  • 1
  • 2
  • 9
  • Did you try to build in release mode? Changing the project name to `project "cpp_hello_world"` didn't change anything. I get the same error message as the one I posted in the question. – 0ax1 Apr 08 '15 at 18:46