gpt4 book ai didi

c++ - 无法将我的解决方案中的其他项目与 premake 链接起来

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:23:23 26 4
gpt4 key购买 nike

我正在尝试开始使用 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"}

源代码/测试.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;
}

感谢您的宝贵时间。

最佳答案

这是一个已知的预制错误。它已被报告并修复,但该程序的修复版本尚未发布。查看讨论 here .

此错误是由 -Wl,-x 链接器标志引起的,premake 默认将其添加到 project.make 生成文件中。截至目前,有两种可能的解决方案,下载带有修复程序的更新的 premake 源代码,编译并安装新版本,或者在生成的 项目中手动更改 LDFLAGS 的值。在每次运行 premake 之后制作

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

关于c++ - 无法将我的解决方案中的其他项目与 premake 链接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22689492/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com