Adding POCO C++ Library Netbeans on Linux - c++

I am trying to use POCO C++ Library with Netbeans IDE on Ubuntu Linux 13.04. I have downloaded, build and installed the POCO C++ Library. The library can be found in the directory "/usr/local/include/Poco". I would like to know how to add the POCO C++ Library to the Netbeans IDE and be able to work with it. Please answer with details.
Thank You

To link an external libraries you need in general three things:
To add the header files as an include directory -I flag
To add the library path to your POCO C++ *.so files -L flag
To add the library name to your compiler without the lib prefix, for example with poco would be poco-Foundation and the name of your file in your system would be libpoco-Foundation.so
Now for Netbeans specific
For the header files
File -> Project Properties -> Build -> C++ Compiler -> General -> Include Directories which is step one
For the library directories
Project -> properties -> Linker -> Additional Library Directories which is step two
For the library
Project -> properties -> Linker ->Libraries -> Add option -> Other is only for the library file, which is step three.
In the case of the Poco Libraries they are usually handled like the Boost Libraries, for example
#include "Poco/AutoPtr.h"
This means the Include Directory has to be one level up from the Poco folder. For example if your Poco folder is on "/usr/local/include/Poco" then you need to add the "/usr/local/include" to your Include Directories (from step one).
As for the -L/usr/local/include/Poco This is not how it is done. This path is the path to your specific library, in the case of poco there is Foundation, XML, Net, and Util along with the test projects. You need to find the files that are named libPoco-*.so where "*" means something. This is most likely in your the directory usr/local/lib if those files are not there then they are most likely in usr/local/lib/Poco
If there are no files named libPoco-*.so you have to build your Poco libraries separately.

Related

How to use a library created using Bazel

I'm relatively new to Cpp and I was trying to build a simple app for a quant project. I've managed to use Bazel to convert a chunk of my code to a library residing in the bazel-bin directory in my repository as a .lib file.
However, I'm not able to figure out how to use this library in my main.cpp which is outside the library I created. Could anyone help with this? Thanks!
I'm not sure if I understood your question correctly, but I think, there is a .lib file that you want to use it (technically speaking, you need to link that .lib file to another app, or accessing in the main.cpp).
Ok, it depends on what build-system you use.
for MSVC:
Add the full path of the .lib file to Project Property Page -> Linker -> Input -> Additional Dependencies.
and don't forget to add the path to .h files (include path) to Project Property Page -> C/C++ -> General -> Additional Include Directories
It's the same for other build systems, you have to link it to the final built item.
for gcc there is a -L flag for the lib and a -h flag to point to the include directories.
in CMake:
include_directories(
path/to/include/directory
)
link_directories(
path/to/directory/that/lib/lives
)
add_executable(main main.cpp)
target_link_libraries(main lib_file_name)
if the lib file name is lib_file_name.lib you should not include .lib (just for cmake)

How to correctly include Dlib in Eclipse project?

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)

C++ Eclipse use libraries

I am currently encountering a few errors with Eclipse c++. I am a complete newbie to c++ and because I knew Eclipse from java I thought it might be ok. Now to the issue:
I want to use the curl library, but I have no idea how to include it correct. Everywhere around the internet I found that I have to go to the compiler settings, include the library there, go to the linker settings and include it there as well. Now the linker has 2 different panels, one for Libraries (-l) and one for Library paths (-L).
I have downloaded the curl library to this directory:
C:\Users\Hannes\Desktop\eclipseC\curl-7.45.0
How do I have to include the Library correctly now?
Here is the error:
g++ "-LC:\Users\Hannes\Desktop\eclipseC\curl-7.45.0\include\curl" -o HelloWorld.exe HelloWorld.o -lcurl
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lcurl
In the editor the automatic completion for curl methods does work.
EDIT: Removing \include\curl from the Library path (-L) didn't work as well.
You have included what looks to be an include path not the library path. Is there a /lib directory under the curl path?
The c/c++ includes should be the path to the header files for curl, the linker path should be to the libraries not the headers, so .a and .dll files normally (normally under a /lib directory).

Libxml2 for c++ project configuration issue windows

I am using eclipse Version: Luna Release (4.4.0), MingW 32 bit compiler, window 64 bits along with libxml2-2.7.8.win32. I successfully compiled and build the project with no error but while i tried to run there is no output nor any error message.
I have specified path of 'lib' folder of libxml2 in eclipse as project-> Properties -> c/c++ build -> setting -> toolsetting -> mingW c++ linker -> libraries (-l) and Library search path (-L). In library i have used full name "libxml2" and search path i have placed "${workspace_loc:/${ProjName}/libxml2-2.7.8.win32/lib}"
there is a dll file "libxml2.dll" in the bin folder and have doubt whether i should place it some where or set reference path somewhere.
or should i use any c++ wrapper to execute the libxml2

fatal error: boost/chrono.hpp: No such file or directory

This question has been asked many times in different ways, but none of the solutions have solved my problem.
Environment : Ubuntu 12.04, Eclipse-cdt
Boost library 1.55.0 (thread, chrono, date_time and system) is at /boost
Included the same path in Project Properties -> C/C++ General -> Paths and Symbols -> Includes -> Include directories
Included /boost/stage/lib in Project Properties -> C/C++ General -> Paths and Symbols -> Includes -> Library Paths
Linked all libraries e.g. /boost/stage/lib/libboost_chrono.a in _LDADDS
Used -I in _CPPFLAGS to give /boost header files
Am I missing something?