Category Archives: Programming

How to Cross Compiling with codeblocks using linux


The following is how I did this on Ubuntu ‘Precise Pangolin’ Linux:

Step 1:

Install MingW32 for linux

Code:
# sudo apt-get install mingw32

Step 2:

Settings->Compiler and debugger settings

Code:
 Select GNU GCC Compiler and click the Copy button.
 Name this: MingW32 Compiler

Step 3:

Click the Compiler tab and then click the #defines tab.
Add the following:

Code:
  WINVER=0x0400
  __WIN95__
  __GNUWIN32__
  STRICT
  HAVE_W32API_H
  __WXMSW__
  __WINDOWS__

Click the Linker tab and the following under “Other Linker Options”:

Code:
-lstdc++
-lgcc
-lodbc32
-lwsock32
-lwinspool
-lwinmm
-lshell32
-lcomctl32
-lctl3d32
-lodbc32
-ladvapi32
-lodbc32
-lwsock32
-lopengl32
-lglu32
-lole32
-loleaut32
-luuid

*Note: Not all of these are REQUIRED… As I have been recently messing with compiling apps for windows with ogl and dx9 support I have realized that there are some additions I have needed to add here… I will update accordingly when I know more.

Step 4:

Click the Directories tab and the Compiler tab.

Code:
 Modify the path to read the following (where ix86 is your architecture type):
 /usr/i586-mingw32msvc/include

Click the Directories tab and the Linker tab:

Code:
 Modify the path to read the following (where ix86 is your architecture type):
 /usr/i586-mingw32msvc/lib

Click the Directories tab and the Resource Compiler tab:

Code:
 Modify the path to read the following (where ix86 is your architecture type):
 /usr/i586-mingw32msvc/include

Step 5:

Click the Programs tab:

Code:
 C compiler: i586-mingw32msvc-gcc
 C++ compiler: i586-mingw32msvc-g++
 Linker for dynamic libs: i586-mingw32msvc-g++
 Linker for static libs: i586-mingw32msvc-ar
 Debugger: i586-mingw32msvc-gdb    **** MORE ON THIS LATER ****

Click OK and save your changes.

Step 6:

Ubuntu’s mingw32 package and from what I can tell, MingW32 in general doesnt really have a solid gdb option for debugging natively in linux so we’re going to work around this using wine and mingw32’s latest insight build for windows

Install Wine

Code:

# sudo apt-get install wine

Step 7:

Download Insight here:

Code:
http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=82725&release_id=371590

http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=82725&release_id=371590

Step 8:

Once you download insight.exe, extract the archive using wine:

Code:
wine insight.exe

I extracted this to my desktop

Step 9:

Move the insight folder to /opt

the path should now look like

Code:
/opt/insight/bin/gdb.exe

Step 10:

create a shell script in /usr/bin:

(note: shell scripts should start with a hash (#) bang (!), ie: “# ! / bin / sh ” [with no spaces] but when I add that the forum post tanks)

Code:
# sudo gedit /usr/bin/i586-mingw32msvc-gdb

and add the following:

Code:
wine /opt/insight/bin/gdb.exe "$@"

Save the file and quit gedit

Step 11:

Code:
# sudo chmod +x /usr/bin/i586-mingw32msvc-gdb

Now we have a way to execute the windows version of mingw32’s gdb for windows in linux using our shell script wrapper

Step 12:

Create a new console application project in Codeblocks…

Using the wizard select the MingW32 Compiler option.

Step 13:

Right click the project and go to properties. Click the Targets tab and set the Output Filename to be whatever you want with a .exe file extension. Make sure the Type is a Console Application.

Step 14:

Hit F9 in codeblocks and the hello world application runs!! YAY!

Set a breakpoint on line 5 and hit F8 and the application breaks in the debugger!! Woot!

Now you can successfully compile, execute, and debug windows applications in linux using codeblocks!!!

Source post:  Click here

Advertisements

Programming Languages are Like Women


 There are so many programming languages available that it can be 
very  difficult to get to know them all well enough to pick the 
right one for you.  On the other hand most men know what kind of 
woman appeals to them. So here  is a handy guide for many of the 
popular programming languages that describes  what kind of women 
they would be if programming languages were women.

 Assembler - 
A female track star who holds all the world speed 
records.  She  is hard and bumpy, and so is not that pleasant to 
embrace.  She can cook up  any meal, but needs a complete and 
detailed recipe.  She is not beautiful or  educated, and speaks in 
monosyllables like "MOV, JUMP, INC".  She has a  fierce and 
violent temper that make her the choice of last resort.

 FORTRAN - 
Your grey-haired grandmother.  People make fun of her 
just because  she is old, but if you take the time to listen, you 
can learn from her  experiences and her mistakes.  During her 
lifetime she has acquired many  useful skills in sewing and 
cooking (subroutine libraries) That no younger  women can match, 
so be thankful she is still around.  She has a notoriously  bad 
temper and when angered will start yelling and throwing dishes.  
It was  mostly her bad temper that made grandad search for another 
wife.

 COBOL - 
A plump secretary.  She talks far too much, and most of 
what she says  can be ignored.  She works hard and long hours, but 
can't handle really  complicated jobs.  She has a short and 
unpredictable temper, so no one really  likes working with her.  
She can cook meals for a huge family, but only knows  bland 
recipes.

 BASIC - 
The horny divorcee that lives next door.  Her specialty 
is seducing  young boys and it seems she is always readily 
available for them.  She  teaches them many amazing things, or at 
least they seem amazing because it is  their first experience.  
She is not that young herself, but because she was  their first 
lover the boys always remember her fondly.  Her cooking and  
sewing skills are mediocre, but largely irrelevant, it's the 
frolicking that  the boys like.  The opinion that adults have of 
Mrs.  BASIC is varied.  Shockingly, some fathers actually 
introduce their own sons to this immoral  woman!  But generally 
the more righteous adults try to correct the badly  influenced 
young men by introducing them to well behaved women like Miss  
Pascal.

 PL/I - 
A bordello madam.  She wears silk dresses, diamonds, furs 
and red high  heels.  At one time she seemed very attractive, but 
now she just seems  overweight and tacky.  Tastes change.

 C - 
A lady executive.  An avid jogger, very healthy, and not too 
talkative.  Is an good cook if you like spicy food.  Unless you 
double check everything  you say (through LINT) you can unleash 
her fierce temper.  Her daughter C++  is still quite young and 
prone to tantrums, but it seems that she will grow  up into a fine 
young woman of milder temper and more sophisticated character.

 ALGOL 60 - 
Your father's wartime sweetheart, petite, well 
proportioned, and  sweet tempered.  She disappeared mysteriously 
during the war, but your dad  still talks about her shapely form 
and their steamy romance.  He never  actually tasted much of her 
cooking.

 Pascal - 
A grammar school teacher, and Algol 60's younger sister.  
Like her  sister she is petite and attractive, but very bossy.  
She is a good cook but  only if the recipe requires no more than 
one pot (module).

 Modula II 
- A high-school teacher and Pascal's daughter.  Very 
much like her  mother, but she has learned to cook with more than 
one pot.

 ALGOL 68 - 
Algol 60's niece.  A high-society woman, well educated 
and terse.  Few men can fully understand her when she talks, and 
her former lovers still  discuss her mysterious personality.  She 
is very choosy about her romances  and won't take just any man as 
her lover.  She hasn't been seen lately, and  rumor has it that 
she died in a fall from an ivory tower.

 LISP -
 She is an aging beatnik, who lives in a rural commune with 
her hippie  cousins SMALLTALK and FORTH.  Many men (mostly college 
students) who have visited the farmhouse,-- enthusiastically 
praise the natural food, and perpetual love-ins that take place 
there.  Others criticize the long cooking times, and the abnormal 
sexual postures (prefix and postfix). Although these women seldom 
have full-time jobs, when they do work, their employers praise 
them for their imagination, but usually not for their efficiency. 

APL - 
A fancy caterer specializing in Greek food.  She can cook 
delicious meals for rows and rows of tables with dozens of people 
at each table.  She doesn't talk much, as that would just slow her 
work down.  Few people can understand her recipes, since they are 
in a foreign language, and are all recorded in mirror writing.

LOGO - A grade-school art teacher.  She is just the kind of 
teacher that you wish you had when you were young.  She is shapely 
and patient, but not an interesting conversationalist.  She can 
cook up delicious kiddie snacks, but not full-course meals.

LUCID & PROLOG - 
These clever teenagers show a new kind of cooking 
skill. They can cook-up fine meals without the use of recipes, 
working solely from a description of the desired meal (declarative 
cooking).  Many men are fascinated by this and have already 
proposed marriage.  Others complain that the girls work very 
slowly, and that often the description of the meal must be just as 
long as a recipe would be.  It is hard to predict what these girls 
will be like when they are fully mature.

Ada - 
A WAC colonel built like an amazon.  She is always setting 
strict rules, but if you follow them, she keeps her temper.  She 
is quite talkative, always spouting army regulations, and using 
obscure military talk.  You gotta love her though, because the 
army says so.

The History of Programming Languages


Before 1940

The first programming languages predate the modern computer. At first, the languages were codes.
The Jacquard loom, invented in 1801, used holes in punched cards to represent sewing loom arm movements in order to generate decorative patterns automatically.

During a nine-month period in 1842-1843, Ada Lovelace translated the memoir of Italian mathematician Luigi Menabrea about Charles Babbage’s newest proposed machine, the Analytical Engine. With the article, she appended a set of notes which specified in complete detail a method for calculating Bernoulli numbers with the Engine, recognized by some historians as the world’s first computer program

The 1940s

In the 1940s the first recognizably modern, electrically powered computers were created. The limited speed and memory capacity forced programmers to write hand tuned assembly language programs. It was soon discovered that programming in assembly language required a great deal of intellectual effort and was error-prone.
In 1945, Konrad Zuse published details of his programming language Plankalkül. However, it was not implemented in his time and his original contributions were isolated from other developments because Germany was isolated during the war.
Some important languages that were developed in this time period include:

  • 1943 – Plankalkül (Konrad Zuse)
  • 1943 – ENIAC coding system
  • 1949 – C-10

The 1950s and 1960s

In the 1950s the first three modern programming languages whose descendants are still in widespread use today were designed:

  • FORTRAN, the “FORmula TRANslator”, invented by John W. Backus et al.;
  • LISP, the “LISt Processor”, invented by John McCarthy et al.;
  • COBOL, the COmmon Business Oriented Language, created by the Short Range Committee, heavily influenced by Grace Hopper.

Another milestone in the late 1950s was the publication, by a committee of American and European computer scientists, of “a new language for algorithms”; the Algol 60 Report (the “ALGOrithmic Language”). This report consolidated many ideas circulating at the time and featured two key innovations:

  • The use of Backus-Naur Form (BNF) for describing the language’s syntax. Nearly all subsequent programming languages have used a variant of BNF to describe the context-free portion of their syntax.
  • The introduction of lexical scoping for names in arbitrarily nested scopes.

Algol 60 was particularly influential in the design of later languages, some of which soon became more popular. The Burroughs B5000 was designed to be programmed in an extended subset of Algol.
Some important languages that were developed in this time period include:

  • 1951 – Regional Assembly Language
  • 1952 – Autocode
  • 1954 – FORTRAN
  • 1958 – LISP
  • 1958 – ALGOL
  • 1959 – COBOL
  • 1962 – APL
  • 1962 – Simula
  • 1964 – BASIC
  • 1964 – PL/I 

 

1967-1978: establishing fundamental paradigms

The period from the late 1960s to the late 1970s brought a major flowering of programming languages. Most of the major language paradigms now in use were invented in this period:

  • Simula, invented in the late 1960s by Nygaard and Dahl as a superset of Algol 60, was the first language designed to support object-oriented programming. Smalltalk (mid 1970s) provided a complete ground-up design of an object-oriented language.
  • C, an early systems programming language, was developed by Dennis Ritchie and Ken Thompson at Bell Labs between 1969 and 1973.
  • Prolog, designed in 1972 by Colmerauer, Roussel, and Kowalski, was the first logic programming language.
  • ML built a polymorphic type system (invented by Robin Milner in 1978) on top of Lisp, pioneering statically typed functional programming languages.

Each of these languages spawned an entire family of descendants, and most modern languages count at least one of them in their ancestry.
The 1960s and 1970s also saw considerable debate over the merits of “structured programming”, which essentially meant programming without the use of GOTO. This debate was closely related to language design: some languages did not include GOTO, which forced structured programming on the programmer. Although the debate raged hotly at the time, nearly all programmers now agree that, even in languages that provide GOTO, it is bad style to use it except in rare circumstances. As a result, later generations of language designers have found the structured programming debate tedious and even bewildering.
Some important languages that were developed in this time period include:

  • 1970 – Pascal
  • 1972 – C
  • 1972 – Smalltalk
  • 1972 – Prolog
  • 1973 – ML
  • 1978 – SQL

The 1980s: consolidation, modules, performance

The 1980s were years of relative consolidation. C++ combined object-oriented and systems programming. The United States government standardized Ada, a systems programming language intended for use by defense contractors. In Japan and elsewhere, vast sums were spent investigating so-called “fifth generation” languages that incorporated logic programming constructs. The functional languages community moved to standardize ML and Lisp. Rather than inventing new paradigms, all of these movements elaborated upon the ideas invented in the previous decade.
However, one important new trend in language design was an increased focus on programming for large-scale systems through the use of modules, or large-scale organizational units of code. Modula, Ada, and ML all developed notable module systems in the 1980s. Module systems were often wedded to generic programming constructs—generics being, in essence, parameterized modules (see also parametric polymorphism).
Although major new paradigms for programming languages did not appear, many researchers expanded on the ideas of prior languages and adapted them to new contexts. For example, the languages of the Argus and Emerald systems adapted object-oriented programming to distributed systems.
The 1980s also brought advances in programming language implementation. The RISC movement in computer architecture postulated that hardware should be designed for compilers rather than for human assembly programmers. Aided by processor speed improvements that enabled increasingly aggressive compilation techniques, the RISC movement sparked greater interest in compilation technology for high-level languages.
Language technology continued along these lines well into the 1990s. However, the adoption of languages has always been driven by the adoption of new computer systems, and in the mid-1990s one of the most important new systems in computer history suddenly exploded in popularity.
Some important languages that were developed in this time period include:

  • 1983 – Ada
  • 1983 – C++
  • 1985 – Eiffel
  • 1987 – Perl
  • 1989 – FL (Backus)

The 1990s: the Internet age

The rapid growth of the Internet in the mid-1990s was the next major historic event in programming languages. By opening up a radically new platform for computer systems, the Internet created an opportunity for new languages to be adopted. In particular, the Java programming language rose to popularity because of its early integration with the Netscape Navigator web browser, and various scripting languages achieved widespread use in developing customized applications for web servers. Neither of these developments represented much fundamental novelty in language design; for example, the design of Java was a more conservative version of ideas explored many years earlier in the Smalltalk community, but the widespread adoption of languages that supported features like garbage collection and strong static typing was a major change in programming practice.
Some important languages that were developed in this time period include:

  • 1990 – Haskell
  • 1990 – Python
  • 1991 – Java
  • 1993 – Ruby
  • 1994 – PHP
  • 2000 – C#

Programming language evolution continues………

source:collected

Installing Net Beans IDE in Ubuntu 11.10 Oneiric Ocelot


The NetBeans IDE is an award-winning integrated development environment available for Windows, Mac, Linux, and Solaris. The NetBeans project consists of an open-source IDE and an application platform that enable developers to rapidly create web, enterprise, desktop, and mobile applications using the Java platform, as well as PHP, JavaScript and Ajax, Groovy and Grails, and C/C++.
The NetBeans project is supported by a vibrant developer community and offers extensive documentation and training resources as well as a diverse selection of third-party plugins.

Release Overview

NetBeans IDE 7.0 introduces language support for development to the Java SE 7 specification with JDK 7 language features. The release also provides enhanced integration with the Oracle WebLogic server, as well as support for Oracle Database and GlassFish 3.1. Additional highlights include Maven 3 and HTML5 editing support; a new GridBagLayout designer for improved Swing GUI development; enhancements to the Java editor, and more.
NetBeans IDE 7.0 is available in English, Brazilian Portuguese, Japanese, Russian, and Simplified Chinese.

Get the NetBeans IDE 7.0.1

The latest available download is NetBeans IDE 7.0.1, which is an update to NetBeans IDE 7.0.

Download NetBeans IDE 7.0

NetBeans IDE 7.0.1 includes the following notable changes:

  • Full JDK 7 support: Running NetBeans IDE on top of JDK 7 and support for the final version of the JDK 7 language features
  • Integration of the recent patches
  • Performance improvements

Installing NetBeans IDE 7.X.X


Java 6 or above is required for installing and running the PHP and C/C++ NetBeans Bundles and also JDK 6 or above is required for installing and running the Java SE, Java EE and All NetBeans Bundles.

So the first thing you have to do is to download Java 7 and JDK 7 and install in your computer. You can do that by typing this in your terminal.

 sudo apt-get install openjdk-7-jdk openjdk-7-jre


If you want to know more about  OpenJDK visit their official site using this link.
After successfully installing Java 7 and JDK 7, you have to download NetBeans.
The latest stable release is NetBeans IDE 7.0.1, that you can download from this link.
If not you can also go for the beta release NetBeans IDE 7.1, download link.
After downloading Netbeans  IDE, right click on the downloaded file and go to “Properties”.
There go to the “Permissions” tab. Tick on the “Execute”. Then run it in a terminal. Follow
the guidance supplied by the installation wizard. Finish and exit the installation wizard 
when NetBeans IDE is successfully installed.
*If you haven’t installed Java 7 and JDK 7, you won’t be able to continue the setup.

Happy programming !!!!!!