Friday 31 July 2015

Ubuntu Eclipse CDT with C11 & pthread

1. Create a C++ project

2. Enable C++11

2.1 Once created, right-click the project and go to "Properties"

2.2 C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Miscellaneous -> Other Flags


3. Update content assist (to avoid error: Type "thread" cannot be resolved)

3.1  Go to Project -> Properties -> C/C++ General -> Preprocessor include paths, etc -> Providers -> CDT GCC Builtin Compiler Settings

3.2 Disable the Share flag and append -std=c++11 to the compiler specs.

4. Test program

#include
#include

using namespace std;

void threadFunc()
{
    cout << "Welcome to Multithreading" << endl;

}

int main(int argc, char **argv) {
    //pass a function to thread
    thread funcTest1(threadFunc);

    funcTest1.join();
}


5. for Window + MinGW
http://scrupulousabstractions.tumblr.com/post/36441490955/eclipse-mingw-builds

Sunday 19 July 2015

ubuntu openvpn connect

1. Install openvpn

$ sudo apt-get install openvpn

2. Connect by configuration file

$ sudo openvpn --config elendh2.ovpn

3. check ip

$ ifconfig -a

4. To disconnect press: Ctrl+C

It can shutdown by command line.

5. Detect the virtual network interface:


tap0      Link encap:Ethernet  HWaddr 32:28:a4:04:34:cc  
          inet addr:172.22.18.14  Bcast:172.22.18.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
 
 

5. Shutdown this interface:

$ sudo ifconfig tap0 down