Strange issue in gcc windows

Last week I came across a strange situation in gcc for windows. I have written some c++ codes in linux where some of the function bodies i kept in header files only.

like this

class temp

{

string m;

public:

void setm(string param){ m = param;}

string getm(){ return m;}

}

 

This is working fine when compiled and used in linux. But when I use same gcc version in windos 64 , it compiles but crashes at run time as it couldn’t locate function bodies. Will look into this farther .

imraw

 

imraw

 

 

 

 

 

 

 

 

 

This is a small utility to convert raw files to jpeg. I have been searching for some tool which can quickly transform raw file to jpeg quickly.  As a photographer i needed something like this for sending picture or sharing immediately.

Technology :  C++ ,qt,magick++

Features :

  1. drag and drop support.
  2. Options to specify specify jpeg compression, output name  and jpeg compression ratio.
  3. One click conversion to high quality jpeg.

Drawbacks :

  1.     Plenty 🙂  .  I just spent half day on this  and most of it is spent on learning and compiling imagemagick . Presently it is in pre alpha stage , you are welcome to modify it. Most things are in place , just a bit debugging is required.

Download Link :   https://github.com/rwik/imraw

Commit to Github

Here are simple steps (only commands) to install ,setup a repo and commit to github . I assume that you are having root access(These instructions are from linux only. ) and a github account .

  1. Go to the folder containing code , which you want to commit.
  2.  sudo apt-get install git   # install git
  3. Next step is to setup github with your detailsmonai@monai:~/imraw$ git config –global user.name “Your name”
    $ git config –global user.email ” your mail ”
    $ git config –global credential.helper cache   # to remember password
  4. Next step is to add files to repo
    git add *
  5. Now we are ready to commmit changes
    git commit *
  6. In case you get any fatal error regarding creation of index.lock , userm -f ./.git/index.lock
  7. Now we are ready to push our changes to github.com
    $ git remote add origin https://github.com/yourname/projectname.git
    $ git push origin master
  8. That’s it. Remember you can always use force , in case you encounter some error and you know the system is wrong 🙂

Reducing size of executable in mingw/gcc

I was compiling some basic codes in qt. I observed that even for a hello world project , it is taking close to 1 mb , even in release mode. So did a google search on that. Found that main culprits are

  • Included debuging info.
  • included standard libraries.
  • RTTI , EXCEPTION handling, usage of templates.

In my case, usage of templates is the main reason. Seems like compiler loves to generate different codes for each template instances. Eg. vector<int> and vector<string> will have different implementation.

Solution is to disable the above mentioned features using some compiler options

-fno-rtti
-fno-exceptions

For complete list of options check this. You may also consider packing your executable using UPX.

Qdebug Error in qt 5.1 on ubuntu

On my ubuntu machine, i received this error while starting debugging in qt 5.1 .

 

Could not attach to the process. Make sure no other debugger traces this process.

Check the settings of

/proc/sys/kernel/yama/ptrace_scope

For more details, see /etc/sysctl.d/10-ptrace.conf

 

This has been reported as a bug in qt project site .

Temporary solution from bug forum

Temporary workaround (note that this introduces security risk to your system, see Ubuntu wiki page linked above for details):
In /etc/sysctl.d/10-ptrace.conf change value of kernel.yama.ptrace_scope to 0. This file is read at startup time so you will need to reboot to apply change.
You can also set ptrace_scope to 0 for current session only (it will revert back to 1 after rebooting) like this:

 echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

 

Debug error in qtcreator

I generally use eclipse in my ubuntu box. This afternoon i decided to use qtcreator for a change. Found a annoying bug in qdebug for console application , which is due to some security changes in ubuntu .

Here is the error….

ptrace: Operation not permitted.

Could not attach to the process. Make sure no other debugger traces this process.
Check the settings of
/proc/sys/kernel/yama/ptrace_scope
For more details, see /etc/sysctl.d/10-ptrace.conf

Solution :

1. Open command line and move to this folder

cd /etc/sysctl.d/
2. Edit this file

sudo nano 10-ptrace.conf
3. change the value of
kernel.yama.ptrace_scope = 0

Thats it 🙂