2

我正在尝试开始使用 premake,但我无法让我的测试项目与它正确链接。如果我手动链接它,它可以正常工作。

我在带有 clang 3.4 的 OS X 10.9 上使用 premake 4.3(也使用 premake 4.4 对其进行了测试)。

在我通过“premake4 gmake”创建一个 makefile 并尝试编译它后,我收到如下错误:

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

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

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

感谢您的时间。

4

1 回答 1

1

这是一个已知的预制错误。已报告并已修复,但该程序的修复版本尚未发布。请参阅此处的讨论。

这个错误是由-Wl,-xpremake 默认添加到project.makemakefile 的链接器标志引起的。到目前为止,有两种可能的解决方案,下载带有修复程序的更新的 premake 源,编译并安装新版本,或者,在每次运行 premake 后手动更改LDFLAGS生成的值。project.make

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

于 2014-07-22T20:16:36.740 回答