Friday, October 03, 2014

Been to a lunch seminar about Internet of Things

Went to Sogeti Internet of Things seminar on Wednesday lunch.
I made some notes:

Presenter was: @dagpetersson  

Devices:
  • Electric IMP. Computer, WiFi, inputs for sensors. Very small.
  • iBecon. Localication, triangulation, water resistant.
  • LightBlue Bean. Test card, Temperature sensor, Accelerometer, iBecon. In and output.

IBM MessageSight, uses MQTT protocol. Can support up to 1 miljon devices.

We where also able to test Google glass, very interesting experience.  

Thursday, October 02, 2014

Qt and collect2 ld returned exit status 1

Got this error when building a unit test project:
collect2 ld returned exit status 1

The linker complained on my newly added class in the implementation project.

It took a while to figure it out, but the problem was that the old *.so file was left in Build folder when I tried to compile the lib file that was used by the unit test project.

The solution to the problem was to remove all files in the implementation project build folder. Followed by a rebuild of the implementation project and unit tests project could be built without any linker errors.

Sunday, September 21, 2014

Use Pomodoro Technique and instrumental music to get into the zone quickly

Was listening to Mark Seeman on .Net Rocks, talking about Getting into the zone.

Got some good advice's, Instrumental music tends to be better to listen to than lyrics or someone is talking when trying to get "into the zone" or flow.
I usually had a podcast or a radio station on while working. But I get it now, listening and processing when someone is talking and in the same time as I'm working with my brain is reducing the mental performance. After changing to classical or instrumental music in my playlist at work, I can feel that it's faster to get into coding quicker when interrupted.

I also picked up the Pomodoro technique mentioned in the show, after reading up on the technique developed by Francesco Cirillo and setting a timer on 25 minutes when working and 5 minutes of rest between every "pomodoro"/work session, I can say it works for me, getting more done every day.

Saturday, September 06, 2014

Solved: error: C2248: 'QObject::QObject' : cannot access private member declared in class 'QObject'

Added two classes A and B both inheriting QObject.

#include <QObject>
#include "b.h"

class A : public QObject
{
    Q_OBJECT
public:
    explicit A(QObject *parent = 0);

    QList<B> doStuff();

signals:

public slots:


};





#include <QObject>

class B : public QObject
{
    Q_OBJECT
public:
    explicit B(QObject *parent = 0);


signals:

public slots:

};

But when adding implementation for A:

QList<GUIContainer> A::doStuff()
{
    QList<B> list;
    return list;

}


The compiler started complaining:
error: C2248: 'QObject::QObject' : cannot access private member declared in class 'QObject'


It complains because:
"The values stored in the various containers can be of any assignable data type. To qualify, a type must provide a default constructor, a copy constructor, and an assignment operator."
http://qt-project.org/doc/qt-4.8/containers.html


Solved the error by changing the QList to be a list of QSharedPointer:
QList<QSharedPointer<B> > doStuff();


Sunday, August 31, 2014

How to find out if a shared library has Debug symbols

We had some problems with debugging on a remote system and did some searching on the Internet to find out how to ensure that the library indeed has debug information. 

This is the command that can be used:
objdump --syms ... | grep debug

http://stackoverflow.com/questions/3284112/how-to-check-if-program-was-compiled-with-debug-symbols

Tuesday, August 26, 2014

Solved: Failed to start program. Path or permissions wrong?

Got this error in Qt: "Failed to start program. Path or permissions wrong?" after adding a new drive in our linux developer image in VM-Ware and moving our trunk to it. According to a lot of resources on the Internet the cause should be that the user don't have execute permission. But the user did and there were no difference when using root.

Found out that it was possible to check if mount was set to: noexec by using mount command and it was noexec although according to the GUI in mountmanager it was exec.
http://forum.softpedia.com/topic/980864-probleme-cu-permisiuni-folder/

Found out that this issue could be solved by doing a remount:
sudo mount -o remount,exec /tmp
http://askubuntu.com/questions/311438/how-to-make-tmp-executable

After the remount the error disappeared.

Thursday, August 21, 2014

SIGSEGV horror in the Qt project.

Had some problems in our project the application kept crashing with SIGSEGV error. We did not get a chance to catch the problem in the debugger making it hard to find. Found a neat trick on the internet, it's possible to add a handler for signals that catch the SIGSEGV and can print the stacktrace:
http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes

#include <stdio.h>
#include <execinfo.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>


void handler(int sig) {
  void *array[10];
  size_t size;

  // get void*'s for all entries on the stack
  size = backtrace(array, 10);

  // print out all the frames to stderr
  fprintf(stderr, "Error: signal %d:\n", sig);
  backtrace_symbols_fd(array, size, STDERR_FILENO);
  exit(1);
}

void baz() {
 int *foo = (int*)-1; // make a bad pointer
  printf("%d\n", *foo);       // causes segfault
}

void bar() { baz(); }
void foo() { bar(); }


int main(int argc, char **argv) {
  signal(SIGSEGV, handler);   // install our handler
  foo(); // this will call foo, bar, and baz.  baz segfaults.
}

It's also possible to catch other signals:
http://qt-project.org/doc/qt-4.8/unix-signals.html