Linux 从 Visual Studio 解决方案生成 Make 文件(用于 GCC)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12875013/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Generate Make Files (for GCC) from Visual Studio Solution
提问by Sijo
I want to compile my Visual Studio Solution, with three projects, in Linux using GCC. The solution contains two DLL projectsand one application(.EXE) projectwhich uses these DLLs. The source code doesn't contain any Windows dependency.
我想在 Linux 中使用 GCC编译我的Visual Studio 解决方案,包含三个项目。该解决方案包含两个DLL 项目和一个使用这些 DLL 的应用程序 (.EXE) 项目。源代码不包含任何 Windows 依赖项。
How do I convert the solution (with 3 projects) to make files which can be compiled in Linux using GCC.
如何将解决方案(包含 3 个项目)转换为可以使用GCC在 Linux 中编译的文件。
Is there is any tool for converting the Visual Studio Solution (Project) to make file/s.
是否有任何工具可以将 Visual Studio 解决方案(项目)转换为文件/s。
The Visual Studio version is Visual Studio 2008
Visual Studio 版本是Visual Studio 2008
回答by Basile Starynkevitch
First, Linux don't have DLLs, it has shared objects which can be dynamically linked, with a different semantics. Read Levine's Linkers & Loadersbook for more, and the Program Library Howtoand Drepper's How to write shared libraries. For C++, be aware of name manglingand see also the C++ dlopen mini-howto.
首先,Linux 没有 DLL,它具有可以动态链接的共享对象,具有不同的语义。阅读 Levine 的Linkers & Loaders一书了解更多信息,以及Program Library Howto和 Drepper 的How to write shared libraries。对于 C++,请注意名称修改,另请参阅C++ dlopen mini-howto。
Then, I think that you should not try to convert your VS project into a Makefile
, you should code a good Makefile
by yourself.
然后,我认为你不应该试图将你的VS项目转换成一个Makefile
,你应该Makefile
自己编码一个好的。
Don't forget to setup your Makefile
so that -Wall
is passed to GCC (and perhaps also -std=gnu99
, and -g
if you want debugging information, probably thruCFLAGS
or CXXFLAGS
).
不要忘记设置您的Makefile
以便-Wall
传递给 GCC(也许还有-std=gnu99
,-g
如果您想要调试信息,可能通过CFLAGS
或CXXFLAGS
)。
Unless your program is a million line of code application, you won't have much trouble in writing your own Makefile
. I strongly suggest to learn to use GNU makeand to read its documentation, which seems to me well written (with some tutorial part). You might glance at the output of make -p
which gives the "builtin knowledge" of GNU make
.
除非您的程序是一百万行代码的应用程序,否则您在编写自己的Makefile
. 我强烈建议学习使用GNU make并阅读它的文档,在我看来它写得很好(有一些教程部分)。您可能会看一眼其输出,make -p
其中提供了 GNU 的“内置知识” make
。
You could also look inside existing free software Linux applications and study their Makefile
.
您还可以查看现有的自由软件 Linux 应用程序并研究它们的Makefile
.
BTW, if you have hard time debugging your makefiles, use remake.
顺便说一句,如果您很难调试 makefile,请使用remake。
Don't think in terms of "converting my app to Linux" but more in terms of "coding a Linux app".
不要考虑“将我的应用程序转换为 Linux”,而是更多地考虑“编写 Linux 应用程序”。
Notice that some frameworks (notably Qt) exist to develop software portably to Linux and Windows and MacOS. You might even use them for non-GUI applications.
请注意,存在一些框架(特别是 Qt)来开发可移植到 Linux、Windows 和 MacOS 的软件。您甚至可以将它们用于非 GUI 应用程序。
Don't forget to read material like advanced linux programmingand advanced unix programming
不要忘记阅读诸如高级 linux 编程和高级 unix 编程之类的材料
回答by Carlos Due?as
Maybe this can help you, but you need to handle whit you outputs in the original code
也许这可以帮助您,但是您需要处理原始代码中的输出
Make-It-so
做到这一点
http://code.google.com/p/make-it-so/
http://code.google.com/p/make-it-so/
or sln2mak
或 sln2mak
http://www.codeproject.com/Articles/28908/Tool-for-Converting-VC-2005-Project-to-Linux-Makef
http://www.codeproject.com/Articles/28908/Tool-for-Converting-VC-2005-Project-to-Linux-Makef
i hope this can help you
我希望这可以帮助你
回答by Gr3yh0und
You can use i.e. vcproj2cmakeor vcxproj2cmake. Further tools are already listed here: How to support both vcxproj to cmake on a project?
您可以使用即vcproj2cmake或vcxproj2cmake。此处已列出更多工具: 如何在项目上同时支持 vcxproj 和 cmake?