Netbeans 项目从 Mac 到 Windows

发布于 2024-12-12 02:34:38 字数 392 浏览 0 评论 0原文

我在 Mac 中创建了一个 Netbeans CPP 项目并将其上传到 git 中。该项目有使用 Windows 的合作者。

当我将我的项目推送到 github 时,我也推送了 makefile 信息(整个项目)。现在,协作者遇到构建错误,因为引用包含我的 Mac 文件路径。

Windows 机器安装了 cygwin。

  1. 我该如何解决?
  2. 我如何使其平台独立?
  3. 我(和合作者)应该怎样做才能不影响其他工人?

答案:Netbeans 有一个选项(在 c++ 下的项目属性中),可以将文件路径设置为绝对路径或相对路径。所以我所要做的就是设置相对选项并推送更改。该项目开始为每个人工作!瞧!!!!!!!

I created a Netbeans CPP Project in my Mac and uploaded it into git. The project has collaborators who use Windows.

When I pushed my project into github , I pushed the makefile information too (the whole project). Now the collaborators are getting build errors because the reference contains my Mac filepaths.

The Windows machine have cygwin installed.

  1. How do I resolve it ?
  2. How I do make it platform independent ?
  3. What should I (and collaborators ) do to not affect the other workers ?

ANSWER : Netbeans has an option (in the project properties under c++), to have the file path as absolute or relative. So I all had to do was, set the relative option and push the changes . The project started working for everyone ! VOILA !!!!!!!!

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

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

发布评论

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

评论(3

不即不离 2024-12-19 02:34:38

Netbeans 有一个选项(在 c++ 下的项目属性中),可以将文件路径设置为绝对路径或相对路径。所以我所要做的就是设置相对选项并推送更改。该项目开始为每个人工作!瞧!!!!!!!

Netbeans has an option (in the project properties under c++), to have the file path as absolute or relative. So I all had to do was, set the relative option and push the changes . The project started working for everyone ! VOILA !!!!!!!!

飘落散花 2024-12-19 02:34:38

我发现 NetBeans 为 C++ 生成的项目文件相当笨拙,并且不太易于人类维护。虽然它们确实倾向于从项目的根目录相对引用路径(便于将项目复制到不同的目录),但需要维护的项目文件太多了。如果它们不起作用,你就没事了。

我不知道 NetBeans 是否允许您在项目设置对话框中指定路径的环境变量。据我所知,宏/变量的内容基本上没有记录。但是,如果您知道如何执行此操作,则可以通过环境变量而不是项目设置窗口中的硬编码路径来定义所有文件路径依赖项。远程开发人员只需在其计算机上重新定义环境变量即可。

但我认为更好的解决方案是不使用 NetBeans 从项目设置自动生成的 Makefile。相反,声明您自己的 Makefile 并从“现有 Makefile”创建 NetBeans 项目类型。我发现这非常有效。

然后,您可以在 Makefile 顶部添加一行,如下所示:

include common.inc

其中“common.inc”包含所有与机器相关的硬编码库路径。这是我的一个例子:

BOOST_INCLUDE := -I/home/jselbie/lib/boost_1_46_1
OPENSSL_INCLUDE := -I/home/jselbie/lib/openssl

然后我的 Makefile 仅通过变量名引用这些目录。因此,当我在具有不同配置的不同机器上移动项目时,我只需要更新 common.inc。

然后,如果其他人想要使用 NetBeans 编译我的项目,他们只需从“现有 Makefile”选项创建一个 NetBeans 项目即可。

I've found that the project files generated by NetBeans for C++ are rather unweildy and aren't very maintainable by humans. And while they do tend to reference paths relatively from the root of the project (facilititating copying the project to different directories), there's just too many project files to maintain. And you're sol if they don't work.

I don't know if NetBeans allows you to specify environment variables for paths in the project settings dialogs. The macro/variable stuff is largely undocumented as far as I can tell. But if you know how to do that, then define all your file path dependencies by an environment variable instead of a hardcoded path in the project settings window. Remote developers need only redefine the environment vars on their machine.

But I think a better solution is to not use the NetBeans auto-generated Makefile from Project Settings. Instead, declare your own Makefile and create a NetBeans project type from "an existing Makefile". I've found that works really well.

Then you can have a line at the top of you Makefile as follows:

include common.inc

Where "common.inc" includes all the hardcoded library paths that are machine dependent. Here's an example of mine:

BOOST_INCLUDE := -I/home/jselbie/lib/boost_1_46_1
OPENSSL_INCLUDE := -I/home/jselbie/lib/openssl

And then my Makefile only references these directories by variable name. And so when I move the project around different machines with different configs, I just need to update common.inc.

And then if anyone else wants to use NetBeans to compile my project, they just need to create a NetBeans project from "an existing Makefile" option.

风吹短裙飘 2024-12-19 02:34:38

相对文件路径的选项实际上不在项目属性中!相反,它位于顶部菜单栏中。选择“工具”,然后选择“选项”,然后单击“C/C++”选项卡,下面的第二个框是“文件路径模式”,选择“始终相对”

The option for relative file paths is actually NOT in the project properties! Instead, it's in the top menu bar.. choose "Tools" then "options" then click the "C/C++" tab, and the second box down is "File path mode" select "always relative"

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