c vs c++关于solaris 9平台的问题
我有一个正在与第三方共享的程序。我将为他们提供一个 bin 可执行文件。它是用 C++ 编写的,但也使用了一些 C。他们建议只需要 c 即可。你们认为这会是一个问题吗,因为我将在一个 sparc 站上编译和构建它,该站将在某种程度上匹配他们的系统规格,例如Solaris 9和芯片组(32或64),具体取决于他们使用的是什么?
Solaris 9 是否能够编译我使用的 C++ 代码,或者它们是否需要在其末尾添加 C++ 运行时库。我正在使用 C++ std 类。无论如何,如果我把这一切都建立在我的头上,为什么还要担心他们拥有什么?它不是我分享的静态/动态库,我认为这会发挥作用。
只是好奇,因为他们说它需要是 ac 编译。我怀疑如果他们期待一个库,那么也许我需要解决这个问题,但如果它只是一个可执行文件,那么操作系统和芯片组等系统规格才是最重要的?
如果我的这个假设错了,请告诉我哪里错了。
I have a program that I am sharing with a third party. I will be providing a bin executable to them. It is written in c++ but uses some c as well. they are suggesting that it needs to be c only. Do you guys think this will be a problem since I will be compiling and building it on a sparc station that will somewhat match their system specs like solaris 9 and the chipset (32 or 64) depending on what they use?
is solaris 9 able to compile the c++ code that i used or do they need to add c++ runtime libraries on their end. I am using c++ std classes. in any event if i am building it all on my end why worry about what they have? its not a static/dynamic lib that i am sharing where i think that would come into play.
just curious since they are saying it needs to be a c compilation. I suspect if they are expecting a lib then perhaps I need to address that but if its just a executable then the system specs like os and chipset is all that matters?
if i am wrong in this assumption please let know where.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最坏的情况是您始终可以在 C++ 运行时库中静态链接。
如果您只向他们发送可执行文件,我不明白为什么该语言有任何区别。当然,如果您还共享代码,那就完全不同了。
Worst case you can always statically link in the C++ runtime library.
If you are only sending them an executable, I don't see why the language makes any difference whatsoever. If you're also sharing code, of course, that's an entirely different story.
由于您只向他们提供可执行文件(没有共享库),因此您应该不会遇到太多麻烦。
只需在二进制文件上运行 ldd 命令并查看它链接到哪些 C++ 库(例如,如果您使用 g++,您可能会看到 libstdc++);您应该将它们与可执行文件一起包含在内。不要依赖用户拥有它们,它们可能会丢失或可能不兼容。您将需要使用 -rpath (链接器开关)来确保您的二进制文件将使用您提供的库,而不是系统中找到的任何库。
另外,最好在较旧的 Solaris 上进行编译以提供兼容性,即不要在 Solaris 10 上为 Solaris 7 进行编译,而是在 7 上为 10 进行编译。您明白了...
Since you're providing them with only an executable (no shared libraries), you shouldn't have too much trouble.
Just run a ldd command on your binary and see which C++ libraries it links against (you might see libstdc++ for instance, if you use g++); you should include those along with your executable. Don't rely on the user having them, they might be missing or might be incompatible. You will want to use the -rpath (linker switch) to make sure your binary will use the libraries you provide and not any library found in the system.
Also, it's better to compile on an older Solaris to provide compatibility, i.e. don't compile on Solaris 10 for Solaris 7, but on 7 for 10. You get the ideea...