编译 c++ 应用程序,以便它们也可以在其他计算机上工作

发布于 2024-07-13 23:42:23 字数 487 浏览 4 评论 0原文

因此,我有一个非常简单的 SDL 应用程序,我希望能够将其传递给我的朋友,而无需让他下载一大堆 SDL 软件包。

我该怎么办? 我被告知使用这一行来编译: (请注意,我使用 ubuntu linux,我的朋友也是如此,并且该应用程序在没有“-Wl,-Bstatic”选项的情况下编译和运行就很好。)

    g++ test-sdl.cpp -o test-sdl -Wl,-Bstatic -lSDL_image -lSDL

但是然后我收到此错误:

    /usr/bin/ld: cannot find -lgcc_s  
    collect2: ld returned 1 exit status

为什么我收到此错误? 我如何解决它? 我什至必须以这种方式这样做吗? 有不同/更简单/替代的方法吗?

我是否要求如此之多,想让我的朋友免去下载他可能永远不会使用的软件包的麻烦?

谢谢。

So I have this very simply SDL application I want to be able to pass to my friend without having him download a whole bunch of SDL packages.

how can I go about this? I was told to use this line to compile:
(note that I use ubuntu linux and so does my friend, and that this application compiles and runs without the "-Wl,-Bstatic" options just fine.)

    g++ test-sdl.cpp -o test-sdl -Wl,-Bstatic -lSDL_image -lSDL

But then I get this error:

    /usr/bin/ld: cannot find -lgcc_s  
    collect2: ld returned 1 exit status

why am I getting this error? how do I fix it? do I even have to do this in this way? Is there a different/easier/alternative way?

Am I asking for so much by wanting to save my friend the hassle of downloading packages he will probably never use anyway?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩人痒 2024-07-20 23:42:23

从长远来看,您最好的选择是弄清楚如何构建 .debs,然后您朋友的系统的包管理可以负责安装所需的所有依赖项。 如果您想更广泛地分发软件包,按预期使用平台的本机打包系统将为您和您的用户省去很多麻烦。

查看 Ubuntu 的打包pbuilder

就我个人而言,我从 Martin Krafft Debian 书籍 中学习了如何为我自己的项目(在 Debian 上)执行此操作,并找到使用 yada 大大简化了流程。

In the long run your best bet would be to figure out how to build .debs and then your friend's system's package management can take care of installing all the dependencies needed. If you want to distribute the packages more widely, using the platform's native packaging system as intended will save you and your users a lot of headaches.

Take a look at Ubuntu's guide to packaging and pbuilder.

Personally, I learned how to do this for my own projects (on Debian) from the Martin Krafft Debian book, and find using yada streamlines the process considerably.

风柔一江水 2024-07-20 23:42:23

我认为你应该摆脱 -B (这会改变搜索路径,请参阅 man g++,因此你再也找不到你的库了)。

您所说的开关是 -static,没有 B。

编辑回应评论:抱歉,那是不完整的。 相反,将所有“-Wl,-Bstatic”替换为“-static”。

正如 codelogic 所写, -static 不是链接器的选项( -Wl 暗示)。

You should get rid of the -B, I think (this changes the search path, see man g++, and thus you can't find your libraries anymore).

The switch you meant is -static, without the B.

Edit in response to comments: sorry, that was incomplete. Instead, replace all of "-Wl,-Bstatic" with just "-static".

As codelogic wrote, -static is not an option to the linker (which -Wl implies).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文