2014-03-27 45 views
2

我试图开始premake但我无法让我的测试项目与它正确链接。如果我把它链接起来手动它虽然工作正常。无法链接我的解决方案中的其他项目与预制

我在OS X 10.9上使用premake 4.3(也用premake 4.4测试过),并且使用了clang 3.4。

我通过创建 “premake4 gmake命令” 生成文件,并尝试编译后,我得到一个错误这样的:

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 

我很简单的项目设置:

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

子项目/包括/ 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 

子项目/源/ 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; 
} 

谢谢您的时间。

+0

[此Google搜索](https://www.google.com/#q=internal+error%3A+atom+not+found+in+symbolIndex)似乎指向Clang中与死代码相关的错误剥离。虽然我还没有能够找出让它工作所需的魔法构建标志。 – starkos

回答

1

这是一个已知的预制bug。它被报道并修复,但该程序的固定版本尚未发布。请参阅讨论here

此错误是由-Wl,-x预制将链接器标志默认添加到project.make生成文件引起的。到目前为止,有两种可能的解决方案,下载已修复的更新的预制源,编译并安装新版本,或者在每次运行premake后手动更改生成的project.makeLDFLAGS的值。

我也试过了他们在上面设置premake.tools.gcc.ldflags.flags._Symbolsnil的链接中给出的建议,但是它对我的系统没有影响。

相关问题