Install .bin file on 32bit ubuntu

I got tired of not finding or having trouble with 32bit software on 64bit ersions of ubuntu.

I installed a new 32bit version, only to find out I get the same problem when installing QT.

If you saw my previous post on how to install .bin on 64 bit system then you’ll know what I’m talking about.

It turns out it happens on the 32 bit i.e x86 version as well, except this time the fix i found on the 64 bit version doesn’t apply anymore.

I ended up searching the forums again and found the following.

Go into the directory containing the program, then:

Type this command to make the program executable:

Code:
chmod +x file.bin

Then type this to execute it:

Code:
./file.bin

The irony, I spent all that time doing sudo sh ./file.bin and countless other ways
and the one method I didn't try (which happens to be the simplest) is the one that works.
If you run into hell ask for help in the comments I'll do my best. Original forums post is available on ubuntu.org
Posted in Operating Systems, Ubuntu | Tagged , , , , , , | Leave a comment

Setup visual studio with QT

I searched long and hard trying to get usual studio to work with QT.

QT creator is great but its nice to be in a familiar environment. I came across this doc

at http://portfolio.delinkx.com/files/Qt.pdf

Its slightly out dated but the instructions are almost the same. I’ve updated the links to the current locations.

The text with updated links from that doc is:

Qt Installation for Visual Studio
For Professional & Express Editions*
The steps for a successful integration of Qt in Visual Studio IDE are as follows:
PRE-REQUISITES:
• Make sure the platform SDK is installed if using Visual Studio Express.
• Visual Studio Express and the platform SDK can be downloaded freely from Microsoft
downloads.
STEP 1: DOWNLOAD LIBRARIES
• Download the Qt library from the site: http://www.qtsoftware.com/downloads
• Select “LGPL/Free Downloads”
• Download the file “Download Qt SDK for windows” – Note: They mention its based on
MinGW and does not support VS compiler. Just follow the steps below and Qt can be made
compatible with VS.
• Install the SDK completely.
STEP 2: SETTING ENVIRONMENT VARIABLES
• Add this 2 paths to the Environment Variables: “C:\Qt\2009.01\bin” and
“C:\Qt\2009.01\qt\bin”. Note: This path will depend where you install the Qt.
• To add to the path: Control Panel > System > Advanced > Environment Variables
• Select “PATH” under system variables. Click “EDIT” and Add this to the end of the line:
C:\Qt\2009.01\bin; C:\Qt\2009.01\qt\bin (Remember to separate two paths with a “;”)
STEP 3: CONFIGURE QT FOR YOUR MACHINE
• Run the Visual Studio Command prompt. Start > Program Files > Visual Studio > Visual
Studio Tools > Visual Studio Command Prompt
• Go to the path of your installed Qt e.g. cd C:\Qt\2009.01\qt
• At the prompt type the command configure. E.g. C:\Qt\2009.01\qt> configure
• This will configure Qt for your machine. In case you have multiple compilers installed, and
want to build the Qt library using a specific compiler, you must specify a qmake
specification. This is done by pasing -platform <spec> to configure. E.g. configure -platform
win32-msvc
USING QT WITH VISUAL STUDIO – Kabilen   1 STEP 4: BUILDING QT FOR VISUAL STUDIO
• Run nmake at the command prompt
• This takes lots of time. Will build all the demos, examples and libraries.
That’s it QT is now installed. You can follow the tutorials to use Qt.
OPTIONAL STEP: INSTALLING A VISUAL STUDIO ADD-IN
* For Express Editions (since this plugin doesn’t get installed on Express edition), follow the instructions
given at a later section. (Non‐plugin Step)
• This add-in facilitates the creation of a Qt project in Visual Studio.
• Download the patch at: ftp://ftp.qtsoftware.com/vsaddin/
• Download the latest one.
• Install (make sure Visual Studio is closed before installing).
• Once install is done. Open Visual Studio. Go to the “QT” menu as follows: Qt > Qt
Options
• Click on “ADD”.  Put a version number there and the path where Qt is. E.g.
C:\Qt\2009.01\qt
• Click ok.
• Done. Now Qt template is integrated inside VS.
USING QT WITH VISUAL STUDIO – Kabilen   2 CREATING A PROJECT IN VISUAL STUDIO
• Open Visual Studio
• Create new project. Select the following template:
• Select “Qt Application”, give a name to the project. Press Ok.
USING QT WITH VISUAL STUDIO – Kabilen   3 • Select Next.
• By default the Core and GUI library is included. In case more libraries are required, please
select them accordingly.
• Finish.
• This will create a plain project and main.cpp containing the following
#include <QtGui/QApplication>
#include “test_application.h”
int main(int argc, char *argv[])
}
QApplication a(argc, argv);
Test_application w;
w.show();
return a.exec();
{
• Press F7 to build the solution.
• And F5 to run it.
• You should get something like this running:
USING QT WITH VISUAL STUDIO – Kabilen   4 FOR VISUAL STUDIO EXPRESS USERS
* NON-PLUGIN STEP: CONFIGURING VISUAL STUDIO ENVIRONMENT
If not using the Visual Studio Add-In plugin (for Express Editions Users), then you need to follow the
steps here to create a project in Visual Studio.
• Follow step 1, 2, 3 and 4 as given above to build Qt.
• Now, to ease use of Qt in VS, run QtCreator. Create a new project there. File->New
• Select Either GUI or Console application. Here I am creating a GUI one.
USING QT WITH VISUAL STUDIO – Kabilen   5 • Give the project a name and save it in an empty folder.
• Once created, it will create the necessary files and a UI file. Here you can play with your UI
to create the desired GUI.
• We shall add a resource file to the project. File->New
• Select Resource File
• Rename it. Here since I used myApp as the name all over, my resource file is named as
myApp.qrc
• Now build the project in QtCreator itself. Build -> Build All
• This step create the Q_Object generated files which is required when we going to use in VS.
USING QT WITH VISUAL STUDIO – Kabilen   6 • Now we go to Visual Studio, create a new project.
• Create a Win 32 Project. I named the project as myVsApp
• Remember to create an EMPTY PROJECT
USING QT WITH VISUAL STUDIO – Kabilen   7 • Go to the folder where the project is created and add the following directories to it:
o GeneratedFiles
o Resources
• Now copy the following files from the QtCreator Project folder to the myVsApp
application folder:
o main.cpp
o myapp.cpp
o myapp.h
o myapp.ui
o myapp.qrc
USING QT WITH VISUAL STUDIO – Kabilen   8 • Now copy the following files from the debug folder of the QtCreator Project folder
to GeneratedFiles folder of the VS application folder
o moc_myapp.cpp
o qrc_myApp.cpp
• Now copy the file ui_myapp.h from the QtCreator Project folder to the
GeneratedFiles folder
• Ok now we go back to our empty project in VS and import those files to our project.
Create the necessary filters in the solution explorer window and add existing items.
After adding the files you should get something like this:
• Now we need to link the libraries to the project. Follow the steps below to link the necessary
files.
• Under Project->Properties, use Configuration: All Configurations.
• Under Configuration Properties -> Debugging -> Environment:
o PATH=$(QTDIR)\bin;$(PATH)
USING QT WITH VISUAL STUDIO – Kabilen   9 • Now under C/C++ -> General, Additional Include Directories:
o .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);;$(QT
DIR)\include\QtCore;$(QTDIR)\include\QtGui
• Under C/C++ -> Preprocessor, Preprocessor Definitions, replace all with:
o UNICODE,WIN32,QT_THREAD_SUPPORT,QT_CORE_LIB,QT_GUI_LIB
USING QT WITH VISUAL STUDIO – Kabilen   10 • Now, under Linker -> General, Additional Library Directories:
o $(QTDIR)\lib
• Now under Linker->Input, Additional Dependencies:
o qtmaind.lib QtCored4.lib QtGuid4.lib
• Click OK to save these settings.
• That’s it. Compile. Run. ☺ … When we generated the project from QCreator, it had
created the sample code in it. So to test here, just compile and run.
• Now, if u double click on myApp.ui from the solution explorer, it will send you to Qt
designer. U can change design there, but since we not using the plugin, it won’t
automatically change the files here.
• So the best way is to open the PRO file with QCreator, and edit the UI file there and save
and build. It will create the ui_myapp.h file also.
• Then replace the existing ui file, ui_myapp.h, and qrc_myapp.cpp in the  project by the
newly generated ones to reflect the update.
USING QT WITH VISUAL STUDIO – Kabilen   11 Note: An automated way to do the above is to create custom build events. Follow the
following steps to do this:
• In Solutions explorer, right click on the myapp.ui and select properties
• Under Configuration Properties -> Custom Build Step ->General, Command Line:
o “$(QTDIR)\bin\uic.exe” -o “.\GeneratedFiles\ui_myapp.h” “$(InputPath)”
• Outputs:
o “.\GeneratedFiles\ui_myapp.h”
• Additional Dependencies:
o $(QTDIR)\bin\uic.exe
• Similarly, for resources, Right Click on myapp.qrc and select properties
• Under Configuration Properties -> Custom Build Step ->General, Command Line:
o “$(QTDIR)\bin\rcc.exe” -name “tre” -no-compress “.\myapp.qrc” -o
GeneratedFiles\qrc_myapp.cpp\.
• Output:
o .\GeneratedFiles\qrc_myapp.cpp
• Additional Dependencies:
o .\myapp.qrc
USING QT WITH VISUAL STUDIO – Kabilen   12 • Now, whenever a change is done in the UI or resources, it automatically reflects on
building the project.
For any queries or questions email me: kabilen@delinkx.com
USING QT WITH VISUAL STUDIO – Kabilen   13

Qt Installation for Visual Studio  For Professional & Express Editions* The steps for a successful integration of Qt in Visual Studio IDE are as follows: PRE-REQUISITES: • Make sure the platform SDK is installed if using Visual Studio Express.  • Visual Studio Express and the platform SDK can be downloaded freely from Microsoft downloads. STEP 1: DOWNLOAD LIBRARIES • Download the Qt library from the site: http://www.qtsoftware.com/downloads• Select “LGPL/Free Downloads” • Download the file “Download Qt SDK for windows” – Note: They mention its based on MinGW and does not support VS compiler. Just follow the steps below and Qt can be made compatible with VS.  • Install the SDK completely. STEP 2: SETTING ENVIRONMENT VARIABLES • Add this 2 paths to the Environment Variables: “C:\Qt\2009.01\bin” and “C:\Qt\2009.01\qt\bin”. Note: This path will depend where you install the Qt.  • To add to the path: Control Panel > System > Advanced > Environment Variables • Select “PATH” under system variables. Click “EDIT” and Add this to the end of the line: C:\Qt\2009.01\bin; C:\Qt\2009.01\qt\bin (Remember to separate two paths with a “;”) STEP 3: CONFIGURE QT FOR YOUR MACHINE• Run the Visual Studio Command prompt. Start > Program Files > Visual Studio > Visual Studio Tools > Visual Studio Command Prompt • Go to the path of your installed Qt e.g. cd C:\Qt\2009.01\qt• At the prompt type the command configure. E.g. C:\Qt\2009.01\qt> configure• This will configure Qt for your machine. In case you have multiple compilers installed, and want to build the Qt library using a specific compiler, you must specify a qmake specification. This is done by pasing -platform <spec> to configure. E.g. configure -platform win32-msvc USING QT WITH VISUAL STUDIO – Kabilen   1 STEP 4: BUILDING QT FOR VISUAL STUDIO• Run nmake at the command prompt • This takes lots of time. Will build all the demos, examples and libraries. That’s it QT is now installed. You can follow the tutorials to use Qt.  OPTIONAL STEP: INSTALLING A VISUAL STUDIO ADD-IN* For Express Editions (since this plugin doesn’t get installed on Express edition), follow the instructionsgiven at a later section. (Non‐plugin Step)  • This add-in facilitates the creation of a Qt project in Visual Studio.  • Download the patch at: ftp://ftp.qtsoftware.com/vsaddin/• Download the latest one. • Install (make sure Visual Studio is closed before installing). • Once install is done. Open Visual Studio. Go to the “QT” menu as follows: Qt > Qt Options • Click on “ADD”.  Put a version number there and the path where Qt is. E.g. C:\Qt\2009.01\qt• Click ok.  • Done. Now Qt template is integrated inside VS. USING QT WITH VISUAL STUDIO – Kabilen   2 CREATING A PROJECT IN VISUAL STUDIO• Open Visual Studio • Create new project. Select the following template: • Select “Qt Application”, give a name to the project. Press Ok.  USING QT WITH VISUAL STUDIO – Kabilen   3 • Select Next. • By default the Core and GUI library is included. In case more libraries are required, please select them accordingly.  • Finish. • This will create a plain project and main.cpp containing the following #include <QtGui/QApplication> #include “test_application.h” int main(int argc, char *argv[])  }QApplication a(argc, argv); Test_application w; w.show(); return a.exec();  {• Press F7 to build the solution.  • And F5 to run it.  • You should get something like this running: USING QT WITH VISUAL STUDIO – Kabilen   4 FOR VISUAL STUDIO EXPRESS USERS* NON-PLUGIN STEP: CONFIGURING VISUAL STUDIO ENVIRONMENT If not using the Visual Studio Add-In plugin (for Express Editions Users), then you need to follow the steps here to create a project in Visual Studio. • Follow step 1, 2, 3 and 4 as given above to build Qt.  • Now, to ease use of Qt in VS, run QtCreator. Create a new project there. File->New • Select Either GUI or Console application. Here I am creating a GUI one.  USING QT WITH VISUAL STUDIO – Kabilen   5 • Give the project a name and save it in an empty folder.  • Once created, it will create the necessary files and a UI file. Here you can play with your UI to create the desired GUI. • We shall add a resource file to the project. File->New • Select Resource File • Rename it. Here since I used myApp as the name all over, my resource file is named as myApp.qrc  • Now build the project in QtCreator itself. Build -> Build All• This step create the Q_Object generated files which is required when we going to use in VS. USING QT WITH VISUAL STUDIO – Kabilen   6 • Now we go to Visual Studio, create a new project. • Create a Win 32 Project. I named the project as myVsApp • Remember to create an EMPTY PROJECT USING QT WITH VISUAL STUDIO – Kabilen   7 • Go to the folder where the project is created and add the following directories to it: o GeneratedFiles o Resources • Now copy the following files from the QtCreator Project folder to the myVsApp application folder: o main.cpp o myapp.cpp o myapp.h o myapp.ui o myapp.qrc USING QT WITH VISUAL STUDIO – Kabilen   8 • Now copy the following files from the debug folder of the QtCreator Project folder to GeneratedFiles folder of the VS application folder o moc_myapp.cpp o qrc_myApp.cpp • Now copy the file ui_myapp.h from the QtCreator Project folder to the GeneratedFiles folder • Ok now we go back to our empty project in VS and import those files to our project. Create the necessary filters in the solution explorer window and add existing items. After adding the files you should get something like this: • Now we need to link the libraries to the project. Follow the steps below to link the necessary files. • Under Project->Properties, use Configuration: All Configurations.  • Under Configuration Properties -> Debugging -> Environment: o PATH=$(QTDIR)\bin;$(PATH) USING QT WITH VISUAL STUDIO – Kabilen   9 • Now under C/C++ -> General, Additional Include Directories: o .\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui • Under C/C++ -> Preprocessor, Preprocessor Definitions, replace all with: o UNICODE,WIN32,QT_THREAD_SUPPORT,QT_CORE_LIB,QT_GUI_LIB USING QT WITH VISUAL STUDIO – Kabilen   10 • Now, under Linker -> General, Additional Library Directories: o $(QTDIR)\lib • Now under Linker->Input, Additional Dependencies: o qtmaind.lib QtCored4.lib QtGuid4.lib • Click OK to save these settings. • That’s it. Compile. Run. ☺ … When we generated the project from QCreator, it had created the sample code in it. So to test here, just compile and run. • Now, if u double click on myApp.ui from the solution explorer, it will send you to Qt designer. U can change design there, but since we not using the plugin, it won’t automatically change the files here.  • So the best way is to open the PRO file with QCreator, and edit the UI file there and save and build. It will create the ui_myapp.h file also. • Then replace the existing ui file, ui_myapp.h, and qrc_myapp.cpp in the  project by the newly generated ones to reflect the update. USING QT WITH VISUAL STUDIO – Kabilen   11 Note: An automated way to do the above is to create custom build events. Follow the following steps to do this: • In Solutions explorer, right click on the myapp.ui and select properties • Under Configuration Properties -> Custom Build Step ->General, Command Line: o “$(QTDIR)\bin\uic.exe” -o “.\GeneratedFiles\ui_myapp.h” “$(InputPath)” • Outputs: o “.\GeneratedFiles\ui_myapp.h” • Additional Dependencies: o $(QTDIR)\bin\uic.exe • Similarly, for resources, Right Click on myapp.qrc and select properties • Under Configuration Properties -> Custom Build Step ->General, Command Line: o “$(QTDIR)\bin\rcc.exe” -name “tre” -no-compress “.\myapp.qrc” -o  GeneratedFiles\qrc_myapp.cpp\.• Output: o .\GeneratedFiles\qrc_myapp.cpp • Additional Dependencies: o .\myapp.qrc USING QT WITH VISUAL STUDIO – Kabilen   12 • Now, whenever a change is done in the UI or resources, it automatically reflects on building the project.  For any queries or questions email me: kabilen@delinkx.comUSING QT WITH VISUAL STUDIO – Kabilen   13

Posted in C++, Technology | Tagged , , , , | Leave a comment

QT Using layouts and updating QWidgets based on other widget’s value

#include
#include
#include
#include 

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);//construct QApp

    QWidget *window = new QWidget;//instanciate the QWidget window
    window->setWindowTitle("Enter Your Age");//set the title

    QSpinBox *spinBox = new QSpinBox;//create a spinner
    QSlider *slider = new QSlider(Qt::Horizontal);//create a slider
    spinBox->setRange(0, 130);//set the range that the spinner and slider can go up/down to
    slider->setRange(0, 130);
    /**
     *Listen for signals/events from the slider and spinner
     *listening for values being changed and updating the other object
     * to reflect the changes in the one not being change
     *we register the spinbox's valueChanged event/signal to the slider's
     *setValue function. which is executed when the spinbox's value changes
     */
    QObject::connect(spinBox, SIGNAL(valueChanged(int)),//QObject::connect syntaxt calls connect method in QObject class
                     slider, SLOT(setValue(int)));
    QObject::connect(slider, SIGNAL(valueChanged(int)),
                     spinBox, SLOT(setValue(int)));
    spinBox->setValue(35);//set default age to 35

    QHBoxLayout *layout = new QHBoxLayout;//create a pointer to a layout manager
    //add the widgets to the layout
    layout->addWidget(spinBox);
    layout->addWidget(slider);
    //set the window's layout to the once we created with our child widgets
    window->setLayout(layout);
    //make everything visible
    window->show();
    //return control to QApplication to wait for user interaction
    return app.exec();
}

This example creates a slider and a spinner inside a dialog . As you adjust the value of one the other is adjusted.

Detailed explanation is included in the code above. It produces a GUI that looks like this.

Posted in C++, Technology | Tagged , , , , , | Leave a comment