How to correctly include Dlib in Eclipse project? - c++

I'm currently trying to use the Dlib c++ library in my own project. So I included the main folder of dlib to my project. I also added the dlib/all/source.cpp to my project. When I try to compile the code of the svm_c_ex.cpp example in my own test.cpp file, I only get:
fatal error: dlib/svm.h: No such file or directory
The section Dlib: How to compile didn't help me and I couldn't find further information online. Any help is appreciated!

You need to compile the DLib library first, using the instructions from the website.
cd examples
mkdir build
cd build
cmake ..
cmake --build . --config Release
cmake is a famous tool to build software on multiple platforms. It generates required files first and then you can compile the library using those generated files later.
You need to add the "include" directories (the folders where the headers exist) in your project configuration. I'm quite not sure of where exactly to add in Eclipse CDT.
After that, your program gives linker error because the the header files only contain skeletons of your library code. Actual implementation need to be linked with "linker options" in project properties. You need to add your library's .lib/.a files with your program. I don't exactly remember where is linker options in CDT (I'm talking in Visual Studio context)
Basically for any library you want to use in any C++ project:
You need to include HEADERS in your project properties
You need to link to actual implementation of the library. You can read about
static and dynamic libraries (Someone on SO must have given an
awesome explanation)

Related

Custom build cmake using standard library also for project with lower gcc version

I have a custom build cmake v3.10.0 which was compiled with a gcc_4.8.3. I am using this custom build cmake to compile a cmake project that must use gcc _4.1.2 because of legacy code.
Executing cmake promted me with an error because it needs to use the libstdc++-IFX.so.6 provided by gcc_4.8.3 which I fixed by adding the path to the correct library in my LD_LIBRARY_PATH before the path to the libraries provided by gcc_4.1.2.
Compiling my project and linking an executable (which is done by c++) results in the linker taking the gcc_4.8.3 stdlibs over the gcc_4.1.2 libs. Is there any way to tell cmake to not use the libraries it needs for himself for my cmake project preferably without touching LD_LIBRARY_PATH?
Edits:
#squareskittles comment: I did read and try everything this post suggest but without any changes. The libstdc++-IFX.so.6 is still taken from gcc_4.8.3

Using libtensorflow_cc.so in an existing C++ cmake project

I have an existing C++ cmake project and I want to use tensorflow in it as a third party library. I searched extensively but all the solutions involve installing tensorflow at the end or copying the files to /usr/local directory.
My problem is I don't want to make any changes to the system directories and everything should happen within my project directory.
So, I compiled libtensorflow_cc.so and libtensorflow_framework.so from tensorflow source code and copied into my project directory. I added below code in my CMake to link these libraries.
find_library(tensorflowlibfwk libtensorflow_framework.so
PATHS ${PROJECT_SOURCE_DIR}/thirdparty/lib)
find_library(tensorflowlibcc libtensorflow_cc.so
PATHS ${PROJECT_SOURCE_DIR}/thirdparty/lib)
target_link_libraries(tensorflowtest ${tensorflowlibfwk} ${tensorflowlibcc})
I have no idea about which headers should I include to use the tensorflow in my project ??
Any kind of help please

wxWidgets include files all in same folder?

I'm on a Xubuntu machine. I've downloaded and compiled the source, did the make install.
I'm trying to create a simple wxFrame class, but when I include <wx-3.0/wx/frame.h>, it says Can't resolve type wxFrame. When I look inside frame.h, it includes a reference to <wx/toplevel.h>. Both frame.h and toplevel.h are in the same folder. Why does the compilation place the include files all in the same folder, but the paths to the files are different?
I am using CLion IDE and the include/lib paths are set by cmake's FIND_PACKAGE().
#ShrimpCrackers,
It is generally advisable to start you project by copying one of the sample code into you project and then set you project properties to the output of wx-config --cxxflags and wx-config --libs.
So what you should do is to copy the wxWidgets/samples/minimal/minimal.cpp over to the directory where you project is, fix the project properties and recompile.
BTW, you don't have to do make install. You might want to compile debug and release versions of the library on one machine which defeats the purpose of installing. You just use the compiled version of the library

How to use FFTW with cmake on windows?

I am building my project for Visual Studio with CMake. I used this lines in my CMakeList.txt to include FFTW3.
find_library(FFTW_LIBRARY
NAMES fftw3 fftw)
set(FFTW_LIBRARIES "${FFTW_LIBRARY}")
I got this error from CMake:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
FFTW_LIBRARY
linked by target "windows_SHT" in directory C:/...
I think I did not install fftw properly. I got .dll .lib and .h files in a folder but I don't know how to explain to CMake where is the library.
Specify additional paths for find_library to use.
See: http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_library
You will need to include the path to your custom FFTW installation.
A similar technique will need to be used when you use find_file to locate the headers
http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_file

BOOST Version 1.46.1 with Visual Studio 2010 P.E

I'm trying to run some simple examples with Boost and I'm continuously running into this error and I have tried to compile this but I haven't been able to create "libboost_system-vc100-mt-gd-1_46_1.lib".
I keep ending up with this issue:
error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_46_1.lib'
Anyone encounter this error before? How do you compile this properly with NMAKE because it keeps telling me it's bulding "boost.regex without ICU / Unicode Support" which is giving it a "fatal error U1073 and tells me it doesn't know how to make "../src/c_regex_traits.cpp".
Sorry if this is a jumble it's just a lot of information that's getting more and more confusing to me.
Your boost is not properly built or installed. Please follow the instruction on how to install boost.
You need to build the boost libraries first.
To do this, open command line & go to boost root eg C:\dev\boost\1_46_1.
Depending on whether you want to build for 64bit or 32bit applications, type
(x64):bjam toolset=msvc address-model=64 variant=debug,release link=static threading=multi runtime-link=static,shared stage
(x86): bjam toolset=msvc variant=debug,release link=static threading=multi runtime-link=static,shared stage
to start compiling. Be patience while boost is building, it takes a lot of time. When building is complete you can find the library files in "stage\lib" folder.
Also note that you can delete the folder "bin.v2" once building is complete.
Now you need to point your VS2010 project to those libraries. Modifying part of mlimber's answer:
In VS2010, right-click on your project, select Properties and then go to Configuration Properties -> Linker -> General. Look for "Additional Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Another way to do this is the following
In VS2010, right-click on your project, select Properties and then go to Configuration Properties -> VC++ Directories. Look for "Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Apart from the above, one could also download from
http://sourceforge.net/projects/boost/files/boost-binaries/1.46.1/
the necessary libraries (including the file missing).
While trying to build Pion network library, I ran into a very similar problem since Pion has dependency on Boost library.
My Boost build was built using boostrap and bjam, and not BoostPro.
The error I got was this: LINK : fatal error LNK1104: cannot open file 'boost_thread-vc100-mt-gd-1_46_1.lib'
When I looked at C:\OpenSource\boost_1_46_1\stage\lib directory, I saw every file name started with libboost_ and not boost_. The file boost_thread-vc100-mt-gd-1_46_1.lib was clearly missing. That made me suspicious that not all boost libraries were built by bjam. After a little research, I reran bjam with the option --build-type=complete
Now I noticed that it started creating lib file names starting with boost_. Not to mention, Pion library could now compile successfully.
Hope this adds some clarity to this thread.
Or alternatively to ybungalobill's suggestion use the installer from www.boostpro.com.
In the installer you must just select the boost versions for msvc 10 and after installation update your visual studio include and lib directories in the VS2010 property sheets to point to the boost include and lib directory.
I take it that you used the BoostPro installer, but which library types did you install -- header only, static linking, DLLs, everything?
Assuming you did everything, then the problem is probably that you don't have the path to boost in your library paths. The problematic file name starts with "libboost" which tells me you're trying to use the statically linked version, which is fine. You should add the library path to your Makefile or project settings for all build configurations. It's probably something like C:\Program Files\Boost\boost_1_46_1 (for the newest version on a 32-bit version of Windows).
In VS2010, right-click on your project, select "All Configurations" at the top, then go to Configuration Properties | Linker [or Librarian if you're making a library] | General. Look for "Additional Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Do that for each project in the solution that uses Boost libraries that are not header-only.
For a Makefile, you'll have to locate the library paths and add Boost to it similarly but by hand.