iwlib.h: No such file or directory - c++

This is the first time for me to use Linux and its development tools. When I was trying to build the project I have to read, I had an error:
/home/charlie/AODV/llf.c:36: error: iwlib.h: No such file or directory
I was building the project with Qt. Beforehand, I installed libnl by make and make install, but the problem was not resolved. I am wondering if I did not install libel correctly or there are something more I have to do.

Welcome to Linux development.
You need to install libiw and it's development header(s).
How to do this is distribution dependant. On my Debian (should be more or less the same on any Debian based distro like Ubuntu):
jbm#sumo:~$ apt-cache search libiw
libiw-dev - Wireless tools - development files
libiw30 - Wireless tools - library
libiw30 is the binary lib, and the *-dev package is for it's header file(s), plus sometimes some docs (man pages etc). So:
jbm#sumo:~$ sudo apt-get install libiw-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
[...]
The following additional packages will be installed:
libiw30
The following NEW packages will be installed:
libiw-dev libiw30
Note how installing the header(s) for a lib rightfully install the library as well.
After install:
jbm#sumo:~$ find /usr/include/ -name iwlib.h
/usr/include/iwlib.h
jbm#sumo:~$ find /usr/lib -name "libiw*"
/usr/lib/x86_64-linux-gnu/libiw.so
/usr/lib/x86_64-linux-gnu/libiw.a
Note that:
/usr/include is part of the standard search path for headers of your
gcc toolchain, so you don't need to add a peculiar -I (for "include")
option.
/usr/lib is the same for lib binaries, so no need any -l or
-L (for "link") option.

You need to say to the compiler where to look for the header file. Use the -Idir option with dir the directory where the header file is.

Related

How do I install OpenXLSX on Linux?

I want to use this library https://github.com/troldal/OpenXLSX on my linux machine. How do I install or use libraries found on Gitub?
Also how do I know what compiler flags to use?
The library you linked to is built using CMake (can be seen by the existence of a CMakeLists.txt file).
So you'd have to
download the source code (git clone https://github.com/troldal/OpenXLSX.git on Linux/Mac or using git bash on Windows)
generate the build system for your compiler (mkdir build; cd build; cmake .. on Linux/Mac)
build the library (make on Linux/Mac)
Once you have built the library, generally there is an include directory and a lib directory (sometimes also named bin). If you are compiling directly using g++ or clang++, you'll have to add the include directory with the -I flag and the built library file in lib or bin with the -l flag:
g++ -Ipath/to/include -l/path/to/lib/libOpenXLSX.so your_sources.cpp
If you are using CMake or an IDE with its own build system, you'll have to add those two paths according to the documentation of that build system (see target_link_libraries for CMake for example).
CMake sometimes also generates "install" commands for built library. When you install the libraries, the headers and library will be copied to your global include path, so you won't need to specify the paths in your compile command anymore: g++ -lOpenXLSX your_sources.cpp.
Use the git clone command to download the library these two questions already answered would probably help you the most:
And in regards to flags you would use the -I flag.
How to use Libraries
C++ Link external libraries

How to use FLANN installed from synaptic

I tried to compile FLANN with cmake, but the only result was a giant headache.
So I found here this solution through PCL repository and synaptic. The installation seems gone well, but now I don't know how to use the installed package.
Quoting FLANN's documentations :
An example of the compile command that must be used will look
something like this: g++ flann_example.cpp -I $FLANN_ROOT/include -o flann_example_cpp where $FLANN ROOT
is the library main directory.
But it's not clear to me where $FLANN_ROOT is.
The $FLANN_ROOT is a path where the library was installed. This is mostly relevant when you build and install manually (especially when installing to non-standard locations).
When installed by the packaging system (Synaptic - I guess Ubuntu?) the library headers will be most likely installed in '/usr/include' or '/usr/local/include'. Normally you do not have to use the -I then as those paths are examined by default.

How to add compiler include paths and linker library paths for newly installed Boost?

I have RHEL 5.2, with Boost 1.33 installed.
I downloaded boost_1_44_0.tar.bz2. and built it. On completion it showed:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/dfe/Archive/boost_1_44_0
The following directory should be added to linker library paths:
/home/dfe/Archive/boost_1_44_0/stage/lib
How do I add the above mentioned include paths?
When I do "rpm -q boost", it shows boost-1.33.1-10.el5. Why is that so, when I've installed version 1.44?
Is there a better way to install the latest version of Boost?
There are always three steps to install software on Linux systems:
configure — "check"
make — "build software in current directory"
make install — "copy files to the systems so the other software can use this software"
You likely did the equivalent of make but did not do the equivalent of make install. You need to run
sudo ./b2 install
after running ./b2
Just add the paths to your .bashrc or .profile (or whatever floats your boat) like this:
export LIBS="-L/home/dfe/Archive/boost_1_44_0/stage/lib"
export CPPFLAGS="-I/home/dfe/Archive/boost_1_44_0"
You have to include these directories into makefile which you would use to build your application
CC -I/home/dfe/Archive/boost_1_44_0 -L/home/dfe/Archive/boost_1_44_0/stage/lib yourprogram.cpp
-I option Adds dir to the list of directories that are searched for #include files.
-L option adds dir to the list of directories searched for libraries by linker
CC is sun compiler...
First, I removed the existing boost rpm using
rpm -e boost-1.33.1-10.el5
A message is displayed saying "error: "boost" specifies multiple packages"
Then tried:
rpm -e --allmatches boost
(I don't remember whether I typed 'boost' or 'boost-1.33.1-10.el5')
The packages with dependencies were shown.
I did:
rpm -e [packagename1]
rpm -e [packagename2]
and so on and then did:
rpm -e --allmatches
This erased boost completely from my system.
Then I extracted boost_1_44_0.tar.bz2 using tar -xvjf boost_1_44_0.tar.bz2 and ran bootstrap with:
./bootstrap.sh
Then ran bjam as:
./bjam install
That's it! Boost got installed on my system, and I didn't have to specify any of the linker options while compiling programs! Yay!
Now the 'rpm -q boost' command shows that there is no package installed.

Google protobuf in Linux

I'm working with protobuf and Linux. Where is its compiler protoc? I've downloaded the package from the main site, compiled and installed it successfully but I can't find protoc to build my own format file. Where is it?
UPDATE
Here is folder where I built protobuf:
aclocal.m4 depcomp Makefile.in
autogen.sh editors missing
CHANGES.txt examples protobuf-lite.pc
config.guess generate_descriptor_proto.sh protobuf-lite.pc.in
config.h gtest protobuf.pc
config.h.in install-sh protobuf.pc.in
config.log INSTALL.txt python
config.status java README.txt
config.sub libtool src
configure ltmain.sh stamp-h1
configure.ac m4 vsprojects
CONTRIBUTORS.txt Makefile
COPYING.txt Makefile.am
There isn't a binary file I need.
It's probably installed into /usr/local/bin
On Ubuntu at least, you can apt-get install protobuf-compiler instead.
From the INSTALL.txt:
Installation Names
By default, 'make install' will install the package's files in
'/usr/local/bin', '/usr/local/man', etc. You can specify an
installation prefix other than '/usr/local' by giving 'configure' the
option '--prefix=PATH'.
First, you need to compile you source code from protobuff (in the root folder):
./configure
make
make check
make install
Second:
echo "/usr/local/lib">>/etc/ld.so.conf
echo "/usr/lib">>/etc/ld.so.conf
ldconfig
Third:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
Read README.txt in root folder for more info.
Also, if you are in fact on Ubuntu, then you can also fetch the source package from Debian unstable and rebuild them locally if you want packages that are more current than the last cutoff (which for Ubuntu 9.10 was some time late last summer). That way you end up with .deb packages and you preserve a normal upgrade path (rather than littering /usr/local with one-off installs).
You can find protoc in the path which you set ./configure --prefix=you_path.
When you make install successful, it will general bin, include and lib in that path.
Actually you don't need to know it's place.
All you want is to open terminal where your proto file is located and write at terminal
protoc -I=. --cpp_out=. filename.proto
follow this link for documentation

Build Boost on Mac with Xcode

I've recently got acquainted with Boost library and I'd like to use it in my Xcode project. But sadly there is no HowTo or FAQ on how to do it :(
What's the sequence of actions to build and use Boost libraries in Xcode?
The easiest way I've found to do it is to install MacPorts, then you can install/build Boost via a single command:
sudo port install boost
Plus you get similar access to other open source software. The only downside I've found is that, like any other package management system, they are not always up to date with the latest version.
If you prefer Homebrew as your package manager, the command is:
brew install boost
I don't know how to use Boost from XCode (I'm not a Mac programmer), but building boost is usually done through their own build tool, bjam.
They have a guide to building boost here, and you can download the latest version of bjam here
Once it is built, you reference it from Xcode the same way you would any other library. The boost/include should be added to your include path, and the libraries in boost/lib can be referenced for the boost libs that require it.
To build boost on a mac, follow the unix variants getting started page (http://www.boost.org/doc/libs/1_39_0/more/getting_started/unix-variants.html). You won't use Xcode directly to perform the build, but once complete you can add the boost include paths and dylib's to your Xcode project.
I found that to build Boost 1.41.1 on MacOS, you need to do the following:
Download boost 1.46.1 from here: http://sourceforge.net/projects/boost/files/boost/1.46.1/
Unpack the file
Open terminal, cd to the install directory, and do the following:
chmod u+x configure.sh
cd tools/build/v2/engine/src
chmod u+x build.sh
Then go back to the install directory, and:
./configure.sh
If that runs successfully, it will tell you to run:
./bjam
That's it.. for whatever reason, I needed to set those permissions manually before it would work.
su - root
enter root password and then run below as root
/opt/local/bin/port install boost
If you have never logged in as root or forgotten your password, here are the steps to reset root password
http://support.apple.com/kb/HT1528?viewlocale=en_US&locale=en_US
For most of the boost libraries, there's nothing to build, it's all in header files.
The remainder of the instructions are here.
Currently I'm very happy with using Pete Goodliffe's script which builds a framework from the Boost source package for both iOS and Mac. Drag and drop it into a project and it works!
There are multiple versions of the script out there. Here's one:
https://gist.github.com/faithfracture/c629ae4c7168216a9856/61be257e1c0839c85743777d0687becad9913bf7
Elaboration of Ferrucio's answer:
Install Boost using MacPorts (sudo port install boost) or Homebrew (brew install boost).
Find the path to the Boost header files (it should be in /opt/homebrew/include if you're using Homebrew).
Add the path to System Header Search Paths in the Build Settings of your Xcode target.
IMPORTANT NOTE: If you add the path to User Header Search Paths instead of System Header Search Paths, as other users suggested, then your code will fail to build, since the Boost files use angled-includes (#include <boost/filename.hpp>) to include each other. Angled-includes are only for including system library headers, and thus they only work if Boost is in the System Header Search Paths.
You can read about the difference between angled-includes and quoted-includes here.