I'm trying to get started with premake but I can't get my test project to link properly with it. If I link it manual it works fine though.
I'm using premake 4.3 (also tested it with premake 4.4) on OS X 10.9 with clang 3.4.
After I create a makefile via "premake4 gmake" and try to compile it I get an error like this:
Linking subproject
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]: *** [libsubproject.dylib] Error 1
make: *** [subproject] Error 2
My pretty simple project setup:
project/
src/
test.cpp
subproject/
include/
Library.hpp
source/
Library.cpp
premake4.lua
premake4.lua
solution "testa"
configurations {"debug"}
language "C++"
includedirs {"subproject/include"}
project "subproject"
kind "SharedLib"
files {"subproject/source/*.cpp"}
project "main"
kind "ConsoleApp"
files {"src/*.cpp"}
links {"subproject"}
src/test.cpp
#include <iostream>
#include <Library.hpp>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
Library lib(13, 3);
lib.do_stuff(7);
return 0;
}
subproject/include/Library.hpp
#ifndef __LIBRARY_HPP__
#define __LIBRARY_HPP__
#include <iostream>
using namespace std;
class Library {
public:
Library(int, int);
void do_stuff(int) const;
private:
int x;
int y;
};
#endif
subproject/source/Library.cpp
#include <Library.hpp>
Library::Library(int x, int y) {
this->x = x;
this->y = y;
}
void Library::do_stuff(int z) const {
cout << "X: " << x << "Y: " << y << "Z: " << z << endl;
}
Thank you for your time.
This is a known premake bug. It was reported and fixed, but a fixed version of the program has not been released yet. See the discussion here.
This bug is caused by -Wl,-x
linker flags that premake will add by default to the project.make
makefile. As of now, there are two possible solutions, download the updated premake source with the fix, compile it and install the new version, or, manually change the value of LDFLAGS
in the generated project.make
after each run of premake.
I have also tried the suggestion they give in the link above of setting premake.tools.gcc.ldflags.flags._Symbols
to nil
, but it had no effect on my system.