Compiling under Linux

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Edmund
Posts: 670
Joined: Mon Dec 03, 2007 3:01 pm
Location: Barcelona, Spain

Compiling under Linux

Post by Edmund »

Currently Glass is only available for Windows platforms. Recently there arose the need to also get a working Linux compile. So I downloaded and setup Ubuntu 9.10 in a VM and made some attempts guided by web-tutorials. Unfortuntaly I didnt get very far as I am very unexperienced with the Linux environment.

Could any of you give me some easy to follow guidlines or hints to other information resources. Glass is coded in C++ but I have also got a version compiling flawlessly under C.
So my questions: what compilers are there to do the job, how do I get them to run, are there any easy to setup and operate IDEs.

Thanks in advance.
Edmund
Mincho Georgiev
Posts: 454
Joined: Sat Apr 04, 2009 6:44 pm
Location: Bulgaria

Re: Compiling under Linux

Post by Mincho Georgiev »

Hi Edmund, what compiler do you use under windows as a start.
If your code is compatible with intel under windows, I would suggest you to use it under linux as well, Intel is free under linux BTW. I could give you some guidelines how to install and compile under Ubuntu with Intel if you are interested.
By the way, I've never used 9.10, but as far as I know, there are some issues with ICC. I am using the latest 10.04 without any problems.
Edmund
Posts: 670
Joined: Mon Dec 03, 2007 3:01 pm
Location: Barcelona, Spain

Re: Compiling under Linux

Post by Edmund »

Mincho Georgiev wrote:Hi Edmund, what compiler do you use under windows as a start.
If your code is compatible with intel under windows, I would suggest you to use it under linux as well, Intel is free under linux BTW. I could give you some guidelines how to install and compile under Ubuntu with Intel if you are interested.
By the way, I've never used 9.10, but as far as I know, there are some issues with ICC. I am using the latest 10.04 without any problems.
Hello Mincho, thanks for your instant response. Under Windows I am using Microsoft Visual Studio as my development environment in combination with the Intel C++ compiler. I don't mind upgrading my ubuntu and am downloading the new version as we speak.
Mincho Georgiev
Posts: 454
Joined: Sat Apr 04, 2009 6:44 pm
Location: Bulgaria

Re: Compiling under Linux

Post by Mincho Georgiev »

Ok, here it goes.
First, since you are using Ubuntu only for that (compiling you code) and it is on emulator, the perfect option for you is to login ALWAYS and only as root. This will eliminate a lot of unwanted restrictions and problems for installing and using the intel compiler. Loging as root under 10.04 will be possible only when after installation and logging with your initial account (let's say 'edmund') you set up password for the root:

in terminal:

Code: Select all

passwd 
Enter new UNIX password: [whatever pass you want here]
and after that, this account is not needed anymore, you can log in now as root: when the looging screen appears after reboot, choose other->root->the new password.
Another preliminary preparation would be to install the 'terminal anywhere' in order to help you open it in the needed directory instead of typing it every time:

Code: Select all

sudo apt-get install nautilus-open-terminal 
Download the intel compiler.
https://registrationcenter.intel.com/Re ... NCOM&lang=
I would recommend you the separate packages, IA32 and Intel64 and not the full one in order to avoid mixing later.

follow exactly this two guides
http://software.intel.com/en-us/article ... th-ubuntu/

http://bootstrapping.wordpress.com/2009 ... 10-karmic/

Make sure that g++ and gcc in general are installed. Use the serial number, emailed to you by intel when installing it. Don't change the default directory, should be in /OPT/, you can divide subdirs at intelx86 and intel64 for the two packages. I.E. install them separately.
So the best way to avoid problems is to have /OPT/intelx86 and OPT/intel64 as installation paths.

There are many other thing as well, but if you have problems, I will explain them to you later. One of them could be a 'makeinfo not installed' issue, if you have it, try:

Code: Select all

sudo apt-get install texinfo
If you complete the installation by the 1st guide link I gave you, the next thing that you should know is that you have to set the paths to the intel compiler with the "source" command. Here is what I do (i'm sure there is an easier way, but i'm not a linux specialist,so...) I am making a script with the following:

Code: Select all

source /opt/intel/Compiler/11.1/072/bin/iccvars.sh intel64
icpc src/*.c
save it to a file 'compile' (as example)
and just executed in the terminal like:
./compile

You can save any other configuration like this, for example pgo:

Code: Select all

source /opt/intel/Compiler/11.1/072/bin/iccvars.sh intel64

icpc src/*.c -O2 -prof-gen
or any other you like and just execute them.

For any missing librarys during installation, try synaptic package manager
and the search engine in it, it's very good.
I'm sure there are other stuff that I missed, but basically this is what comes in my mind right now.
Best!
Mincho.
mathmoi
Posts: 286
Joined: Mon Mar 13, 2006 5:23 pm
Location: Québec

Re: Compiling under Linux

Post by mathmoi »

That. Or you could simply do :

Code: Select all

sudo apt-get install g++ build-essential
g++ *.cpp
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Compiling under Linux

Post by Michel »

Hmm it is very bad practice on Linux to employ the root account for daily use.
For your own security the root account should only be used for system maintenance tasks.

User accounts on Linux actually work.

On Ubuntu the root account is usually accessed implictly using sudo. Although you
can get a root shell using

sudo bash
Mincho Georgiev
Posts: 454
Joined: Sat Apr 04, 2009 6:44 pm
Location: Bulgaria

Re: Compiling under Linux

Post by Mincho Georgiev »

Michel wrote:Hmm it is very bad practice on Linux to employ the root account for daily use.
For your own security the root account should only be used for system maintenance tasks.

User accounts on Linux actually work.

On Ubuntu the root account is usually accessed implictly using sudo. Although you
can get a root shell using

sudo bash
Who said "daily use" ?!
He is using ubuntu on VM to compile his code.
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Compiling under Linux

Post by Michel »

He is using ubuntu on VM to compile his code.
Perhaps. But even then one misplaced rm -rf * would wipe out his installation.

It is best to use Linux properly. That way one may actually like it.
Mincho Georgiev
Posts: 454
Joined: Sat Apr 04, 2009 6:44 pm
Location: Bulgaria

Re: Compiling under Linux

Post by Mincho Georgiev »

Michel wrote:
He is using ubuntu on VM to compile his code.
Perhaps. But even then one misplaced rm -rf * would wipe out his installation.

It is best to use Linux properly. That way one may actually like it.
Ok, here is the deal: You keep using it "properly", and I will keep like it as I do.
Edmund
Posts: 670
Joined: Mon Dec 03, 2007 3:01 pm
Location: Barcelona, Spain

Re: Compiling under Linux

Post by Edmund »

It took me quite a while to familiarize myself with the environment but thanks to your support I made some major progress.

I am now at a point where I am getting my first Intel C++ compiler error messages : "could not open source file "Windows.h"" ... what a surprise.
So my next step will be to find an alternative Linux solution for
- pipe/console management and
- time management

but I am sure I will find some references to this in one of the available linux engines. Thanks again for the introduction to this new Operating system!