开发者

Compiling dlib examples on Windows?

开发者 https://www.devze.com 2023-01-09 07:14 出处:网络
I\'m fairly new to C++ (a long time Lisp programmer) and am trying to compile some of the examples for dlib开发者_如何学Python on Windows using MinGW.I added dlib into the PATH.I then call g++ timer_e

I'm fairly new to C++ (a long time Lisp programmer) and am trying to compile some of the examples for dlib开发者_如何学Python 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.

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


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

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.

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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号