简体   繁体   English

将dlib添加到C ++ Eclipse

[英]Adding dlib to C++ eclipse

I am trying to add dlib library to eclipse. 我试图将dlib库添加到eclipse中。 I downloaded dlib from http://dlib.net/ and copied the dlib folder into my project folder. 我从http://dlib.net/下载了dlib,并将dlib文件夹复制到了我的项目文件夹中。

Then I do the following: 然后,我执行以下操作:

(1) Project -> C/C++ General -> Paths and Symbols (2) Choose GNU C++ (3) Choose Add (4) Choose Variables (5) Type "ProjDirPath" (1)项目-> C / C ++常规->路径和符号(2)选择GNU C ++(3)选择添加(4)选择变量(5)键入“ ProjDirPath”

I copy the code from http://dlib.net/optimization_ex.cpp.html into a source file. 我将代码从http://dlib.net/optimization_ex.cpp.html复制到源文件中。 Everything seems okay (ie nothing underlined in red). 一切似乎都很好(即,红色下划线都没有)。

I try build the file and I get: 我尝试构建文件,然后得到:

Info: Internal Builder is used for build g++ "-IC:/Users/..." -O0 -g3 -Wall -c -fmessage-length=0 -o main.o "..\\main.cpp" In file included from c:... ... ... " Is there something I am doing wrong? Why cannot I not run the code on their website? 信息:Internal Builder用于构建g ++“ -IC:/ Users / ...” -O0 -g3 -Wall -c -fmessage-length = 0 -o main.o“ .. \\ main.cpp”在包含的文件中来自c:…………“我做错了什么?为什么我不能在他们的网站上运行代码?

I have also tried adding the dlib library as follows (same as here How to add a library to an Eclipse project ) 我还尝试了如下添加dlib库(与此处的如何向Eclipse项目添加库相同)

(1) Project -> Properties -> C/C++ Build -> Settings -> MinGW C++ Linker -> Libraries (1)项目->属性-> C / C ++构建->设置-> MinGW C ++链接器->库

(2) I add dlib to the top (Libraries(-l)) and the location of the dlib folder library at the bottom (Libraries(-L)). (2)我将dlib添加到顶部(Libraries(-l)),并将dlib文件夹库的位置添加到底部(Libraries(-L))。

I then get the error 然后我得到错误

Info: Internal Builder is used for build g++ "-LC:\\Users..." -o myfile.exe main.o -ldlib c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ldlib collect2.exe: error: ld returned 1 exit status 信息:Internal Builder用于构建g ++“ -LC:\\ Users ...” -o myfile.exe main.o -ldlib c:/ mingw / bin /../ lib / gcc / x86_64-w64-mingw32 / 7.1 .0 /../../../../ x86_64-w64-mingw32 / bin / ld.exe:找不到-ldlib collect2.exe:错误:ld返回1退出状态

Finally, I'll mention that I'm new to C++. 最后,我会提到我是C ++的新手。

Since you are new to C++ you should use cmake to generate your project. 由于您不熟悉C ++,因此应使用cmake生成项目。 If you type something like this: 如果键入以下内容:

cd dlib/examples
mkdir build
cd build
cmake -G "Eclipse CDT4 - Unix Makefiles" ..

cmake will create an Eclipse project for you that will be correctly configured. cmake将为您创建一个将正确配置的Eclipse项目。 CMake can generate a lot of different project types. CMake可以生成许多不同的项目类型。 If you type cmake -h you will see a list of "generators" supported by cmake like visual studio, sublime text, etc. 如果键入cmake -h您将看到cmake支持的“生成器”列表,例如Visual Studio,崇高文本等。

Writing CMake configure files is also very easy. 编写CMake配置文件也非常容易。 The one for the dlib examples serves double purpose as a simple cmake tutorial and is worth looking at: http://dlib.net/examples/CMakeLists.txt.html dlib示例的一个作为简单的cmake教程有双重目的,值得一看: http ://dlib.net/examples/CMakeLists.txt.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM