向公众分发应用程序,以便他们可以编译,而无需透露源代码

发布于 2024-07-26 22:18:25 字数 223 浏览 9 评论 0原文

我有一个专有的应用程序,我想分发给一些人进行测试,但我们不想向他们透露来源。 该应用程序是用 C++ 为 Linux 编写的。 它链接到 Fedora/Ubuntu 存储库上现成的软件包。

有没有什么方法可以将源代码处理为中间代码...然后分发它,并让用户进行最终编译,该编译实际上将中间代码编译并链接到他们的本机平台。

我想看看是否有其他方法可以分发预编译的二进制文件。 谢谢。

I have a proprietary application I would like to hand out to a few people for testing, except we do not want to reveal the source to them. The application is written in C++ for Linux. It links against readily available packages on the Fedora/Ubuntu repos.

Is there any way to process the source to something intermediate... then distribute it, and have the users do a final compile which actually compiles and links the intermediate code to their native platform.

I am trying to see if there is any alternative to distributing precompiled binaries. Thanks.

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

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

发布评论

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

评论(8

魄砕の薆 2024-08-02 22:18:25

只需将其编译为汇编程序即可。 可以使用 -S 选项来完成。

helloworld.cpp:

#include <iostream>

using namespace std;

int main(void)
{
    cout << "Hello World" << endl;
    return 0;
}

然后执行以下操作:

emil@lanfear /home/emil/dev/assemblertest $ g++ -S -o helloworld.s helloworld.cpp
emil@lanfear /home/emil/dev/assemblertest $ g++ -o helloworld helloworld.s
emil@lanfear /home/emil/dev/assemblertest $ ./helloworld
Hello World

使用此方法,您可以仅分发包含非常难以阅读的汇编程序的 .s 文件。

Just compile it to assembler. Can be done using the -S option.

helloworld.cpp:

#include <iostream>

using namespace std;

int main(void)
{
    cout << "Hello World" << endl;
    return 0;
}

And then do:

emil@lanfear /home/emil/dev/assemblertest $ g++ -S -o helloworld.s helloworld.cpp
emil@lanfear /home/emil/dev/assemblertest $ g++ -o helloworld helloworld.s
emil@lanfear /home/emil/dev/assemblertest $ ./helloworld
Hello World

Using this method you can distribute only the .s-files which will contain very hard to read assembler.

瘫痪情歌 2024-08-02 22:18:25

这不是一个技术答案,但您是否足够信任他们,只要求签署保密协议?

It's not a technical answer, but do you trust them enough to just ask for a signed NDA?

远昼 2024-08-02 22:18:25

您可以处理现有的源代码以“破坏”它; 基本上,这包括删除所有注释,将变量名称更改为最小,并删除所有源代码格式。 问题是,他们可以相对轻松地改回变量名称并添加格式和注释; 虽然他们在生成的源代码中不会拥有与您相同级别的信息,但他们将拥有功能齐全的源代码(因为这就是您分发给他们的内容)。 这是做这种事情的唯一方法。

You can process the existing source code to "mangle" it; basically this consists of stripping out all comments, and changing variable names to be minimal and stripping out all source code formatting. The problem is, they can relatively easily change the variable names back and add formatting and comments; while they won't have the same level of information in the resultant source code as you do, they WILL have completely functional source code (because that's what you distributed to them). This is about the only way to do this sort of thing.

流殇 2024-08-02 22:18:25

简而言之,不。 根据定义,如果他们可以编译它,那么他们就有了你的源代码。 你能做的最好的事情就是增加他们试图理解它的痛苦。

我同意约翰的观点。 如果您的客户数量较少并且信任他们,保密协议将是更好的途径。

我刚刚想到的另一件事......只运行预处理器和编译器,而不运行汇编器和链接器怎么样? 您将需要每个特定体系结构的汇编语言的副本,但我认为这足以阻止编辑,同时又很容易编译。

In short, no. By definition if they can compile it then they have your source. The best you can do is increase the pain of them trying to understand it.

I agree with John. If you have a small number of clients and trust them, an NDA would be a better route.

Another thing I just thought about... what about just running the preprocessor and compiler, but not the assembler and the linker? You would need a copy for each specific architecture's assembly language, but I assume that would be painful enough to dissuade editing while easy enough to compile.

剑心龙吟 2024-08-02 22:18:25

您可以将应用程序分为两部分:第一部分将包含具有操作系统独立功能的预编译库,第二部分将包含用户将编译的一小部分源代码。 NVIDIA 以这种方式分发他们的驱动程序。

You could divide your application in two parts: first part will contain precompiled libraries with the OS independent functionality, and the second one will contain a little parts of sources that users would compile. In such way NVIDIA distributes their drivers.

一抹苦笑 2024-08-02 22:18:25

您可以混淆您的 C/C++ 代码。 请参阅我的问题 C/C++ 混淆工具

You could obfuscate your C/C++ code. See my question for C/C++ obfuscation tools

喜你已久 2024-08-02 22:18:25

我能想到的最佳解决方案是限制您支持的平台数量并进行自己的编译,或者编译为难以从中提取信息的二进制格式,但用户可以将其编译为其本机格式。

我个人会选择选项 1。

The best solution I can come up with is to either limit the number of platforms you support and do your own compilations, or compile to a binary format that is hard to extract information from, but the user can compile this to their native format.

Personally I would go with option 1.

很酷又爱笑 2024-08-02 22:18:25

如果是 C,您可以使用 clang 编译器,然后转储 LLVM 中间表示。 如果是C++,你可能需要等待一段时间,直到clang的C++支持成熟。

If it's C, you can use the clang compiler, then dump the LLVM intermediate representation. If it's C++, you might need to wait a while until clang's C++ support matures.

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