Showing posts with label Compiling. Show all posts
Showing posts with label Compiling. Show all posts

Tuesday, 15 January 2019

Cross Compiling Clarity

I have an important distinction to make clear... Cross Compiling is using a machine with a different processor type than the target machine for your program.

So, you have a PC with an Intel Core 2 Duo in it, and you use a compiler to output an ARM executable, that is cross compiling.

If you're on an Intel Core Duo toting 15" MacBook pro (from 2006) and you use that to produce the same ARM executable, that's still cross-compiling.  BUT if you use that MacBook to generate a windows executable it's not cross compiling, as the processor is the same in both targets, you're not crossing over...

Some folks argue this differently, because you're crossing between the Windows and Apple OS's you're cross-compiling.  In my book, and by the definition given elsewhere, you're not, in this case you are cross-platform (the platform being the OS) but you're not cross compiling because the processors are the same family.

That's all, I just wanted this out there, argue as you all see fit.


Wednesday, 5 February 2014

Code::Blocks from Source on Linux (Debian) Mint

I've had a bit of a programming tools review, especially on my Linux boxes.  I've been using the stable release of Code::Blocks 12 for a long time, the reason being the lack of time and space to evaluate the newer v13.


Today however, the boss is out of the office, and with two projects under test I'm not going to do any more project progression for the next two days... This is therefore my window of opportunity... My chance to try v13!

And just to add to my thrill... God I'm sad... I built it from source...

For my own records then, my steps were...

1. Install the dependencies...
  sudo apt-get update
  sudo apt-get upgrade
  sudo apt-get install gtk+-2.0
  sudo apt-get install libwxgtk2.8-dev
  sudo apt-get install libwxbase2.8-dev
2. Download the source http://www.codeblocks.org/downloads
3. Extract to a folder and within...
  ./configure
  sudo make
  sudo make install
4. Edit the ld.so.conf
  sudo nano /etc/ld.so.conf
- Add -
include /usr/local/lib
- Save -
  sudo ldconfig
5. Run Code Blocks!

So far my tests have been fine, the project all load, and better than all this... My main project compile time has gotten a lot shorter, I'm talking we've gone from 1m8s on v12 to 48seconds... This may sound like nothing, but extend this out over 137 projects... That's just over 45 minutes on a full system rebuild for the main project.

Thursday, 30 January 2014

glfw v3 on Debian/Mint/Ubuntu

Please Subscribe now to help me reach 1000 subs :)
This is a post just for me really, but if it helps others, so be it...

Installing glfw on Linux (Mint/Ubuntu/Debian)... My steps...

sudo apt-get install libx11-dev libgl1-mesa-dev libglu1-mesa-dev -libxrandr-dev libxext-dev
sudo apt-get install cmake xorg-dev

Download glfw code, and extract... Move to that folder...

sudo cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=on -DCMAKE_INSTALL_PREFIX=/usr
sudo make
sudo make install

Then lets say we want to build the "boing" example, move to the examples folder with the boing.c file...

gcc -Wall -g -c ./boing.c -o obj/boing.o
g++ -o bin/Boing obj/boing.o -lGLU -lGL -lm -lX11 -lpthread -lXxf86vm -lglfw

So in Code::Blocks, your linker settings look like this for a glfw project:


Monday, 6 January 2014

boost libraries and -Weffc++

I've got a peeve for the day, I've come to use the boost libraries, specifically signals2, in a little project and I wanted to knock up some code to demonstrate what I was up to quickly... However, I've just sat with Code::Blocks spewing beeeellllions of errors and warnings at me.... All from code which looks fine.

The warnings and problems are all coming from Boost... Don't include boost and all is well... but I know boost is fine, I know thousands of people use it, I know its tested... why... oh why is my project cocking it up?

Well, it seems I use -Weffc++ in my compiler scripts, by automatic and default, I like the effective warnings... The problem is, this switch breaks using boost... Boost clearly does not listen to Scott Meyer.. grrr.

So folks, if you want to use boost, don't use the g++ switch -Weffc++

Tuesday, 24 September 2013

Code::Blocks - A few Tips

I'm trying to set up a new Linux box to do some code (C++) in code blocks, now I do like how easy linking with multiple libraries is with code blocks - rather than fiddling with the command line or creating a make file which can obfuscate your build results...

But I'm not a huge fan of Code::Blocks, my biggest problems at the moment is I have a huge screen resolution, but no-matter how big it never feels like I've got enough workspace area available, it sort of feels hemmed in, this mainly comes from the poor way you can't layout editor windows side by side, or horizontally.  Forcing you to feel one file open at a time.

Then add to this that some of the editor settings pages - like "Settings->Environment" - full the whole height of the screen.  So you're there trying to edit the editor and you have this whole page filled with settings, and just as annoyingly you can't click off the editor settings back into the editor to look at something you've changed... You have to accept the settings, close the settings page and then you can see what you've done, this disjoints what you've changed from what you're viewing.

But I have a couple of tips to help you make things better.. First of all, pop into the View table and turn on the TODO list


Dock the panel for to-do items wherever you like...


And then you can add simple "// TODO MESSAGE" type items into your code to remind you what you're up to.


Another tip, if you want to maximise your coding area, you can close the messages windows - where the build output and messages go - but then getting them back open is a pain... To open them again, just press F2!

And finally, another one to maximise your working space, the editor tab showing the filename you're typing in.. Double click it... This will move into the maximised area version of the editor (by default) its a new theme called "Code::Blocks::Minimal".  If this is not setup then you can go into "Settings -> Environment" and then select the "View" (eyeball) on the right, and you're looking to make sure that this setting is selected:



Friday, 16 November 2012

Guide To Building a Raspberry Pi C/C++ compiler on Ubuntu


These are personal notes on setting up a Cross Compiler for C/C++ on my Ubuntu 12.04 machine, so I can build programs for the Raspberry Pi.

Of course my reason for this is that my PC's are far more powerful than my Pi, even compiling the most trivial program can result in waiting a duration or two on the Pi.  So, I want to employ my heavy PC metal to generate the ARM architecture code for me.

The first steps were to install all the pre-requisites, I'm assuming you have Ubuntu 12.04 32bit LTS installed fresh and clean (either as a real machine, or as a virtual one) and that you know how to use your Linux Machine, here we go.

sudo apt-get update
sudo apt-get upgrade
sudo shutdown -r now

Reboot... Log back in etc....

sudo apt-get install subversion bison flex gperf build-essential texinfo gawk libtool automake

Download ncurses tar ball from "http://ftp.gnu.org/pub/gnu/ncurses" extract it and then within its folder:

./configure
sudo make install

Download crosstool-ng from "http://www.crosstool-ng.org", extract its tar ball and from its folder:

./configure --prefix=/opt/cross
sudo make install

Now we need to add this built item to the path:

PATH=$PATH:/opt/cross

And now we need a space to do the building of the cross compiler:

cd ~
mkdir Pi
cd Pi
/opt/cross/bin/ct-ng menuconfig

Goto "Paths and misc options" and then turn ON "Try features marked as EXPERIMENTAL".

Goto "Target Options" and into "Target Archetecture" and select "ARM".
Go into "Target Options" and set Endieness to "little".
Go into "Bitness" and set it to "32bit".

Goto "Operation System"
Go into "Target OS" and select "Linux".

Goto "Binary Utilities" and then select "Binary Utilities" latest version (2.22 as of writing).

Goto "C Compiler" and enable "Show Lincro Version" these are the 4.7+ versions supporting C++11, and enable C++.

Exit and save.

And now we kick off the building of the tool chain:

/opt/cross/bin/ct-ng build

The output for me ended up in "~/x-tools/" as per the paths selected in the paths & misc options.