在 Windows 上编译 dlib 示例? [英] Compiling dlib examples on Windows?

查看:39
本文介绍了在 Windows 上编译 dlib 示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 C++ 相当陌生(很长时间的 Lisp 程序员),我正在尝试为 dlib 在 Windows 上使用 MinGW.我将 dlib 添加到 PATH 中.然后我从示例目录中调用 g++ timer_ex.cpp.但是我收到了很多错误消息.

I'm fairly new to C++ (a long time Lisp programmer) and am trying to compile some of the examples for dlib on Windows using MinGW. I added dlib into the PATH. I then call g++ timer_ex.cpp from the examples directory. But I get a lot of error messages.

如果不使用 Visual Studio,在 Windows 上编译 dlib 示例的最佳方法是什么?

Short of using Visual Studio, what's the best way of compiling dlib examples on Windows?

推荐答案

将文件夹添加到 PATH 通常对我来说效果不佳.相反,请尝试此命令.我刚刚用它编译了这个例子,没有错误:

Adding the folder to PATH usually doesn't work out well for me. Instead, try this command. I just compiled the example with it without error:

g++ timer_ex.cpp ..\dlib\all\source.cpp -I.. -luser32 -lws2_32 -lgdi32 -lcomctl32 -limm32

有点神秘的 -I.. 将文件夹添加到包含搜索路径的上一级.假设您没有更改文件夹布局,这是正确的做法.但总的来说,这是向编译器的包含搜索路径添加内容的最简单方法.

The somewhat cryptic -I.. adds the folder one level up to the include search path. This is the right thing to do assuming your haven't changed the folder layout. But in general this is the easiest way to add something to the compiler's include search path.

您可能还想添加 -O3 选项,它会告诉 gcc 生成优化的可执行文件.通常,这会使生成的应用程序更快,尤其是在您进行繁重的数值工作时.

You also probably want to add the -O3 option which will tell gcc to produce optimized executables. Generally this makes the resulting application a lot faster, especially if you are doing heavy numerical work.

顺便说一句,您应该考虑安装 CMake.这是一个方便的工具,可以为您设置这样的项目.它适用于 Windows、Linux、Mac OS 和许多其他平台.要使用它来编译 dlib 示例程序,您只需在示例文件夹中输入 cmake .,然后输入 make.还有一个免费版本的 visual studio 非常好,作为奖励 cmake可以自动为您创建项目文件.

As an aside, you should consider installing CMake. It's a convenient tool which sets up a project like this for you. It works on Windows, Linux, Mac OS and many other platforms. To use it to compile the dlib example programs you would just have to say cmake . from within the example folder and then make. There is also a free version of visual studio which is quite nice, and as a bonus cmake can automatically create the project files for you.

这篇关于在 Windows 上编译 dlib 示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆