Allowing a local WiFi router to connect to the Internet through a wire LAN

I recently need to set up a WiFi router in my room where I have a computer that connects to a wired network with 802.1x authentication. The network is connected to the internet. Since the WiFi router cannot directly connect to a network with 802.1x authentication, the router is connected to the computer (running Ubuntu 16.04.1 LTS) instead. The following is the code, allowing the traffic from the WiFi router through my computer connect to the network with Internet capability.

#
# Perform NAT so that the WiFi route can connect to the Internet
# eth0 connect to a network which can connect to the Internet
# eth1 connect to LAN through WiFi router
#
# code taken from http://www.revsys.com/writings/quicktips/nat.html
#
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

“symbol(s) not found for architecture x86_64 error” when compiling OpenCV example program in Mac OS X 10.12

I just completed the installation of OpenCV 3 in my Mac (running OS X 10.12) after a long search of various installation methods.  However, when I tried to compile a sample C++ program, the following error was resulted:

Undefined symbols for architecture x86_64:
  "cv::imread(cv::String const&, int)", referenced from:
      _main in DisplayImage-6f69a1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [DisplayImage] Error 1

So, once again, the search is on. After searching for the entire morning for solutions, I came across many “solution posts” that did not work!

Finally, I reached a post that mentioned “imread has been moved in the opencv_imgcodecs library.” and should “Try to add -lopencv_imgcodecs to your linker flags.” This solved my problem.

This case made me wonder how many people who posted “incorrect solution” had actually tried to replicate the error and actually solved the problem? Or did they just “think” what may be the problem and provide “guesses” about the possible solutions?

I am not saying that try ones best to provide information to the other is a bad thing. But providing too many “unproven” information in the web not only not able to help, it also makes the searching for true solution more difficult!

Using cmake-gui to Create MinGW lib for OpenCV 2.4.13

Recently, I have tried to learn how to use OpenCV. Of course, the first thing is to install OpenCV. The version I tried to install is 2.4.13. The development tools I used is MinGW g++. After download and install all the tools (including cmake), I soon found out that there is no library for MinGW g++ in the distribution. This means I need to build my own if I want to use g++. The search is on…

There is not much information I can find for my environment which is Windows 10 and using g++ as my main c++ compiler. After putting the pieces together, I eventually hit the right path, the following is my procedure for building the MinGW lib for OpenCV 2.4.13:

  1. run cmake-gui as follows:
    cmake-gui -G "MinGW Makefiles"

    Setup the location for source (in my case is D:/WinApps/opencv/sources) and the binaries (D:/WinApps/opencv/build/x86/mingw). Add the following two entries as well:

    CMAKE_CXX_COMPILER <em>path_to_g++</em>
    CMAKE_C_COMPILER <em>path_to_gcc</em>
  2. Click Configure then with the default selection of components click Generate
  3. In cmd, change directory to D:/WinApps/opencv/build/x86/mingw and execute the command
    make all

    I encountered two errors during the make process:

    • A compile error for the file window_w32.cpp where the symbols ‘BTNS_AUTOSIZE‘ and ‘BTNS_BUTTON‘ were not declared. I fixed it by change them to 16 and 0 (where I found in one of the header file of g++).
    • Another error from the files in ‘nonfree’ module, for which I just deselect the ‘BUILD_opencv_nonfree’ from cmake and reclick Generate again, then make all again. This time, it went all the way to finish without serious error.
  4. Done!

I test drive the system by creating a c++ program loadimg.cpp which I copied from here.

g++ -I"D:\WinApps\opencv\build\include" -L"D:\WinApps\opencv\build\x86\mingw\lib" loadimg.cpp -lopencv_core2413 -lopencv_highgui2413 -o loadimg

The program compiled and run!