设置跨平台 C++带有跨平台库的 Eclipse 项目
我正在与其他 8 个人一起开发一个跨平台 C++ 项目,该项目使用以下库:
- OpenCV 库
- Boost C++ 库
该项目旨在跨平台,因此所有用户都同意不使用特定于平台的代码,并且,让事情尽可能简单,所有用户都将使用 Eclipse 作为他们的 IDE。但是,有些将使用适用于 Windows 的 Eclipse,而另一些将使用适用于 Linux 的 Eclipse。
由于项目将托管在 SVN 上,我们希望避免与共享的不同配置文件(如 make 文件、eclipse 项目文件等)发生冲突。我们还希望通过 SVN 共享尽可能多的配置文件,以使配置尽可能简单。
假设所有用户都已正确配置系统变量并安装了所需的构建工具(例如 make、cmake 等),并且已正确配置其 Eclipse 设置(但不是特定于项目的设置)。
如何一次性配置项目以及在存储库上共享哪些配置文件,以便 Windows 和 Linux 用户都可以编译它,而无需修改从 SVN 存储库检索的配置文件?
(我并不是在寻找专门适用于我提到的这两个库的完整解决方案,因此我希望有一个通用的逐步说明,这将使我能够轻松添加另一个库。)
I am working on a cross-platform C++ project with 8 other people which uses the following libraries:
- OpenCV Library
- Boost C++ Library
The project is inteded to be cross-platform so all users have agreed not to use platform-specific code, and, to keep things as simple as possible, all users will be using Eclipse as their IDE. However, some will be using Eclipse for Windows while other will be using Eclipse for Linux.
Since the project will be hosted on SVN, we would like to avoid conflicts with different configuration files (like make files, eclipse project files etc..) which are shared. We would also like to share as much of the configuration files as possible through SVN, to keep the configuration as simple as possible.
Let's assume that all users have properly configured system variables and installed the required build tools (such as make, cmake etc.), and have configured their Eclipse settings configured properly (but not the project-specific settings).
How to configure the project once and what of the configuration files to share on the repository, so that both Windows and Linux users can compile it without modifying configuration files retrieved from the SVN repository?
(I am not looking for the complete solution which would specifically work for those 2 libraries I mentioned, so I would appreciate a general how-to step-by-step explanations which would enable me to easily add another library.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般讨论:
您需要安装 Cygwin 或类似的东西,以使 GNU Autotools 工具链可用于 Windows 上的 Eclipse:
如何处理 Eclipse CDT+Cygwin?
一旦你的工具链 Eclipse 有了CDT 和 SVN 连接器已在您的开发计算机上准备就绪,请执行以下步骤。
添加一些代码:
包含
包含
包括
int main(int argc, char *argv[]) {
断言(argc>1);
CvMat* img = cvLoadImageM(argv1);
cvNamedWindow("图片", CV_WINDOW_AUTOSIZE);
cvShowImage("图片", img);
cvWaitKey(0);
返回0;
}
双击:Project Explorer->viewer->configure.ac,在AC_PROG_CXX下面输入以下代码。
<块引用>
AC_CHECK_LIB([opencv_core],[cvSetZero],[],[])
AC_CHECK_LIB([opencv_highgui],[cvShowImage],[],[])
AC_CHECK_LIB([boost_regex-mt],[regexecA],[BOOST_LIB_SUFFIX="-mt"],[BOOST_LIB_SUFFIX=""])
AC_SUBST(BOOST_LIB_SUFFIX)
>
<块引用>
bin_PROGRAMS=查看器
viewer_SOURCES=openCvFocusIssue.cpp
viewer_LDFLAGS = -lboost_regex@BOOST_LIB_SUFFIX@ -lopencv_core -lopencv_highgui
General discussion:
You will need to install Cygwin or something similar to it to make GNU Autotools toolchain available to Eclipse on Windows:
How to deal with Eclipse CDT+Cygwin?
Once your toolchain, Eclipse, with CDT and SVN connectors are ready on your development machines, go through the following steps.
Add some code:
include <opencv/cv.h>
include <opencv/highgui.h>
include <cassert>
int main(int argc, char *argv[]) {
assert(argc > 1);
CvMat* img = cvLoadImageM(argv1);
cvNamedWindow("Picture", CV_WINDOW_AUTOSIZE);
cvShowImage("Picture", img);
cvWaitKey(0);
return 0;
}
Double-click: Project Explorer->viewer->configure.ac and enter the following code below AC_PROG_CXX.
>
两个建议:
如果你做对了,所有项目将包含 cmake 文件
当一个人第一次检查它时,他们运行 cmake 来生成
他们的 makefile(或 VC++ 项目文件等)具有针对 linux 或 windows 的所有不同规则
可能需要。
或者
Two suggestions:
if you get it right all the project will include is the cmake files
and when a person first checks it out they run cmake to generate
their makefiles (or VC++ project files, etc) with all the different rules for linux or windows one
might need.
or