将Makefile转换为Visual Studio术语问题(第一次使用VS)

发布于 2024-08-30 11:30:45 字数 610 浏览 3 评论 0原文

我是一个 Unix 老手,正在将一个基于 makefile 的项目转换到 Microsoft Visual Studio,我接受这个任务是因为我了解 Makefile,它会阻塞 VS 的自动导入工具。我确信有比我正在做的更好的方法,但我们正在使事情适合客户的环境,这推动了我的选择。所以 gmake 不是一个有效的答案,即使它是正确的;-)

我只是有几个关于术语的问题,我认为有经验的(或初级)用户很容易回答这些问题。

目前,make all 将生成多个可执行文件和一个共享库。我应该如何构建这个?它是多个项目的一个“解决方案”吗?如果重要的话,不在正式库中的各个可执行目标之间共享一组通用代码(例如 50%)。

我以为我可以只设置第一个可执行文件,然后为其他可执行文件添加目标,但这似乎不起作用。我知道我正在对抗该工具,那么正确的方法是什么?

我还使用 Visual C++ 2010 Express 来尝试执行此操作,因此如果不使用 Visual C++ 2010(插入最高级)则不支持多个目标,这也可能是一个问题。

谢谢,这确实是应该通过与饮水机旁的常驻 Windows 开发人员快速交谈来回答的问题之一。所以,我在虚拟饮水机上询问,下班后我也会喝一杯虚拟的冰镇饮料。

I am an old Unix guy who is converting a makefile based project over to Microsoft Visual Studio, I got tasked with this because I understand the Makefile which chokes VS's automatic import tools. I am sure there is a better way than what I am doing but we are making things fit into the customer's environment and that is driving my choices. So gmake is not a valid answer, even if it is the right one ;-)

I just have a couple of questions on terminology that I think will be easy for an experienced (or junior) user to answer.

Presently, a make all will generate several executables and a shared library. How should I structure this? Is it one "solution" with multiple projects? There is a body of common code (say 50%) that is shared between the various executable targets that is not in a formal library, if that matters.

I thought I could just set up the first executable and then add targets for the others, but that does not seem to work. I know I am working against the tool, so what is the right way?

I am also using Visual C++ 2010 Express to try and do this so that may also be a problem if support for multiple targets is not supported without using Visual C++ 2010 (insert superlative).

Thanks, this is really one of those questions that should be answerable by a quick chat with the resident Windows Developer at the water cooler. So, I am asking at the virtual water cooler, I'll also spring for a virtual frosty beverage after work.

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

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

发布评论

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

评论(1

回眸一笑 2024-09-06 11:30:45

Visual Studio 在很多方面都与输出有关。一般来说,它期望项目和二进制输出(DLL、EXE、共享库等)之间存在 1-1 映射。因此,格式化解决方案结构的最佳方法是为每个输出创建一个项目。

因此,

  • 共享库的一个项目
  • 每个可执行文件的一个项目

假设可执行文件链接到共享库,您需要将构建顺序配置为首先构建共享库,然后构建可执行文件。这可以通过右键单击解决方案文件并选择“构建配置”来完成。也可以在构建菜单下使用。

Visual Studio is in many ways concerned with outputs. In general it expects for a 1-1 mapping between projects and binary outputs (DLL's, EXE's, shared libs, etc ...). Hence the best way to format your solution structure is to create one project per output.

So

  • One project for the shared lib
  • One project for each of the executables

Assuming the executables link against the shared lib, you'll want to configure the build order to have the shared lib build first and the executables afterwards. This can be done by right clicking on the solution file and selecting "Build Configuration". Also available under the build menu.

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