Tuesday, February 17, 2015

Boost Library Compilation Error (using CMake): undefined reference to `boost::iostreams::detail::

While using CMake to compile a simple c++ code containing boost library utilization, I encountered the following linkage problem:

main.cpp:(.text._ZN5boost9iostreams6detail9close_allINS0_21basic_gzip_compressorISaIcEEENS1_16linked_streambufIcSt11char_traitsIcEEEEEvRT_RT0_[void boost::iostreams::detail::close_all >, boost::iostreams::detail::linked_streambuf > >(boost::iostreams::basic_gzip_compressor >&, boost::iostreams::detail::linked_streambuf >&)]+0x18e): undefined reference to `boost::iostreams::detail::zlib_base::reset(bool, bool)'
collect2: ld returned 1 exit status
make[2]: *** [test.exe] Error 1
make[1]: *** [CMakeFiles/test.exe.dir/all] Error 2

make: *** [all] Error 2

For reference, the code I was trying to compile was the following ( a simple zipping and reading from a zipped file).:

#include <fstream>
#include <iostream>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
using namespace std;
using namespace boost::iostreams;

int main()
{
   //The following code decompresses data from a file and writes it to standard output.
   ifstream file("hello.txt.gz", ios_base::in | ios_base::binary);
   filtering_streambuf<input> in;
   in.push(gzip_decompressor());
   in.push(file);
   boost::iostreams::copy(in, cout);

   boost::iostreams::filtering_ostream geometry;
   geometry.push(boost::iostreams::gzip_compressor(boost::iostreams::gzip::best_compression));

   // Generating a Zip file
   string filename = "example1.txt.gz";
   filtering_ostream out;
   unsigned int compressionLevel = boost::iostreams::gzip::best_compression;
   out.push(gzip_compressor(compressionLevel));

   out.push(file_sink(filename.c_str(), std::ios::binary));
   out << "This is a gz file\n";
   out << "This is the second line\n";
}


How I solved this problem is as follows: 
1)  I already had the following setting in the CMakeList.txt file:
SET(BOOST_DIR /usr/intel/pkgs/boost/1.54.0-gcc-4.7.2 CACHE PATH "Boost directory")

2)  Then, I added the bold and red lines below to have it compile without linkage error (the black lines already existed)
SET(BOOST_LIBDIR ${BOOST_DIR}/lib64)
SET(BOOST_LIB -L${BOOST_LIBDIR} boost_thread.a pthread.a  )
SET(BOOST_INCLUDE_DIR ${BOOST_DIR}/include )
LINK_DIRECTORIES(${BOOST_LIBDIR})
INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIR}  )
find_package(Boost COMPONENTS system filesystem iostreams regex  REQUIRED)
set (EXE test.exe)
add_executable(${EXE} main.cpp )
TARGET_LINK_LIBRARIES(${EXE} ${Boost_LIBRARIES} )


This made the trick and it worked without problems

Wednesday, January 28, 2015

Mansa Musa's Hajj Route (circa 1324)


--- will be updated later ---

References: 
1) P.J. Oliver, Mansa Musa and the Empire of Mali, CreateSpace Independent Publishing Platform (March 26, 2013) amazon

Map of Ibn Battuta's Africa trip including Mali circa 1337



Tuesday, September 30, 2014

FDTD simulations - Why Smooth Turn-on of Source is Needed?



In Finite-Difference Time-Domain (FDTD) simulations, source injection needs to be smoothly done in order to suppress the undesired high frequency components excited during turn on. To visualize this problem, we provide two cases with and without turn-on source injection. On the right simulation, total field/scattered field injection is done using the cosine excitation without any smooth turn-on which effectively mimics the step function operation. This results in the injection of high frequency components creating the ripples and fluctuations in the signal propagating in the domain. On the contrary, the left simulation has a smooth turn of by using a half Hanning window ramp-up which effectively acts as low pass filter for the injected source. As a result, the signal propagating in the domain is free of high frequency components, hence no ripples and fluctuations.


Sunday, September 28, 2014

Nehalem Bay from the Neahkahnie Mountain [1,680' (512 m)]

Finally, we had an opportunity to have a family hike this summer. My son, Omer and my daughter, Meryem were with us as well. Omer was walking by himself and Meryem was comfortably carried in my back. After a pleasant  hour of walking starting from the south trailhead, we reached to the top of Neahkahnie Mountain. The view of the Nehalem Bay and the Pacific Ocean was stunning. Omer was happy to be at the top and couldn't help but took his selfie.

Friday, September 19, 2014

Mt. Hood Walk Up to 2915 m (9563 ft)

Seems so simple in the GPS track log. But in reality, it poses both physical and mental challenges to walk up to Mt. Hood. And definitely, it requires well studied planning from what to have in your backpack to what to eat before the start etc. After the attempt, I now realize that I wasn't well prepared for the challenge. My crampons were not fitting very well and at every step my mind was preoccupied whether they would get out of my shoes or not. The glasses I brought and started using after 2500 m where not fog proof. So, with the influence of sweat and breath warmth, the glasses became foggy making me half blind. After 2500 m, the wind was strong and the weather got really cold. I didn't have anything to cover my face and it got really cold. Eventually, I started to have headache which grew only bigger. I started to feel so sleepy and they told me that I was going through altitude sickness. Hence I needed to get down as quick as possible. I had to abort the climb. I was ~100 m away from the Hog's Back. Hopefully, next time with better preparation I can do better than this one.

Here are some photos from that day:
Mt. Hood right before the sunset as seen from Timberline Lodge. Getting ready for the midnight walk-up.



The walk-up starts around 1 am and the trail is already full of fellow hikers lighting up the trail.

Sun is rising behind the Mt. Hood. Since we are in the south-west side, we are left in the shade. Mt. Jefferson is seen at the background.


At 2915 m (9563 ft), altitude sickness kicks in. I have a very bad headache and drowsiness. Cannot continue further, need to turn back. This is the last point I was able to reach close to the Hog's Back.

Canyon right on the south of Hog's back.


Mt. Hood



Monday, September 08, 2014

McNeil Point Hike at the Mt. Hood National Forest (2118 m ~ 6900 ft)


Here is the video of the last 100 meters of hike past the McNeil point towards Mt Hood from the Cathedral Ridge.



Photos:
Mt Hood from the North side. Glisan Glacier is on the left and Cathedral Ridge to Mt Hood is just in front of us. 

 Looking northwards. On the horizon, Mt. Adams can be seen.

 The valley on the south side of McNeil Point.

GPS log of our hike:

Thursday, July 31, 2014

South Sister Mountain Ascent (3,157 m - 10,358 ft)



Our camping location for the night.


South Sister

Middle and North Sister from the South Sister Peak


Middle and North Sisters zoomed


Moraine Lake as seen from the South Sister peak

Monday, May 26, 2014

Beamforming by Phased Array Antennas




In this second video of the series on beamforming, we show the time domain wave propagation for two phased array antennas at different phase differences. Thanks to the constructive and destructive interferences, the main beam of the wave is steered towards angle of interest.

See also:
Phased Array Antenna Beam Steering Animation (Beamforming)
Beamforming by Phased Array Antennas 



Antenas en fase, Antenne réseau à commande de phase, フェーズドアレイレーダー, Фазированная антенная решётка, Фазована антенна решітка, 相位陣列, Szyki fazowane, Fázisvezérelt antennarács, מערך מופע, آرایه فازی

Saturday, May 17, 2014

Selectively Removing the Polar Axis Labels in Matlab

In Matlab polar plots, the default is to show the whole 360 degrees of the whole graph and also include the polar labels up to 360. If some of the labels are desired not the displayed selectively, one remedy is to replace the corresponding strings with empty string. The procedure is pretty simple and I am showing it below.

First assume that we have such a code that plots the polar plot of a radiation pattern of an antenna array.

set(0,'defaultFigureColor',[1 1 1]) 

clear all; clc;

freq=1e9;
c=3e8;
lambda=c/freq;
T= 1/freq;
omega=2*pi*freq;
k=2*pi/lambda;

Ns=20;
ds=lambda/Ns;

Nt=25;
dt=T/Nt;
t=0:dt:(1*T);

R=(0*lambda):ds:(8*lambda);
Ntheta=240;
dtheta=2*pi/Ntheta;

theta=0:dtheta:(2*pi);


x=R.'*cos(theta);
y=R.'*sin(theta);

delta=(pi/3);

figure (10); clf; 
d = lambda/2;
A = [1 1 1 1 1 1 1]; % Amplitude of each array antenna
Fa=zeros(1,length(theta));
for i=0:(7-1)
    temp =  (A(i+1) * exp(-1i*i*delta + 1i*k*(i*d-3*d)*cos(theta)));
    Fa = Fa + temp;
end
Fa=abs(Fa);
kk=polar(theta,-Fa/max(Fa));   hold on; axis off;
 
The resulting plot is shown below where polar labels up to 330 degrees are shown.

Assume that we do not want to display the labels larger than 180 degrees, the remedy is simply to find the corresponding handle to that string and then replace it with empty string as shown below.
set(findall(gca,'String','210'),'String',' ') set(findall(gca,'String','240'),'String',' ') set(findall(gca,'String','270'),'String',' ') set(findall(gca,'String','300'),'String',' ') set(findall(gca,'String','330'),'String',' ')