1. Basic Program
——————————-
Install C and C++ Compilers in Linux Mint
sudo aptitude install build-essential
or
sudo apt-get install build-essential
This will install all the required packages for C and C++ compilers
Compiling Your first C Programs –
Now you need to open first.c file
sudo gedit first.c
add the following lines save and exit the file
#include <stdio.h>
int main()
{
printf(“Hello world\n”);
return 0;
}
or
right click in /home/[UserName]
Create New Document -> Empty Document
name file icheck.cpp
paste this program
// Hello World
#include <stdio.h>
main()
{
printf(“Hello, world!\n”);
return 0;
}
Or this program
// C program to check whether a given integer is odd or even
#include <stdio.h>
int main()
{
int ival, remainder;
printf(“Enter an integer : “);
scanf(“%d”, &ival);
remainder = ival % 2;
if (remainder == 0)
printf(“%d is an even integer\n”, ival);
else
printf(“%d is an odd integer\n”, ival);
return 1;
}
(UserName is scott)
Open Terminal (Hotkey – Control + Alt + T)
gcc /home/scott/icheck.cpp
/home/scott/a.out (a.out is defult output file if no name is supplied, and is created in /home/scott folder by default)
Or
gcc -o hello hello.c
where hello is the name of output file
/home/scott/hello
now do input and output in terminal.
Code Blocks –
File -> New project -> Console Application
folder – /home/scott/ hw/hw_basic
path – /home/scott/hw/hw_basic/hw_basic.cpp
see – hw_basic.cpp for source code
Set path – /home/scott/hw/hw_basic/hw_basic.cpp
Use F9 or compile button in toolbar to run the program
compiled Exe (hw_basic) is in – /home/scott/hw/hw_basic/bin/Release
Start Terminal
/home/scott/hw/hw_basic/bin/Release/hw_basic
2. OpenGL Program
——————————-
Nividia Driver instalation in Linux Mint 17
—————————————–
You need to connected to internet, you should be able to download 70 – 100 MB in reasonable time. (3G, Broadband connection is preferred)
Start Menu – Administration – Driver Manager
select – nvidia 331 (recommended)
[Apply changes]
Above step installs working proprietary nvidia drivers. After that you can install latest nvidia drivers. This step also removes the problem of noveau interferring with installation if latest driver (run file from nvidia) is directly installed.
Optional – (If you want latest drivers)
Then Download the latest driver like “NVIDIA-Linux-x86_64-340.32.run” from nvidia website.
Save it in “/home/nea/drv/n340.run” (change name for easy typing in terminal)
Start Terminal (Ctrl + Alt + T)
sudo service mdm stop
You will go to command line. Login Again.
sudo telinit 3
sudo sh /home/nea/drv/n340.run
Now the driver will install. Accept, Rebuild Modules or Script
sudo service mdm start (very important)
If X Sever does not start or system hangs or Command Line, press Ctrl + Alt + Del to restart. Or restart from restart button.
After restart. Login, Check Driver version from Start Menu -> Preference -> Nvidia X Server Settings. You can change resolution here.
Code Blocks
———————————-
Using Code Blocks is must for big Cross Platform software development.
Install C and C++ Compilers in Linux Mint –
Start Terminal and type
sudo aptitude install build-essential // all the required packages for C and C++ compilers (gcc)
Intall Code Blocks –
sudo apt-get install codeblocks // Code Blocks
or
search “code blocks in linux mint” in google
go to – codeblocks – Linux Mint Community
install from there
or
read instructions from codeblocks page and install if you want nightly builds
Install reuired development libraries –
sudo apt-get install libx11-dev // x11 for window
sudo apt-get install libgl -dev // OpenGL
sudo apt-get install libopenal -dev // OpenAL
Nothing will be installed or upgraded if the package is already installed.
File -> New project -> Open GL Project
folder – /home/scott/gl/gl_basic
path – /home/scott/gl1/gl_basic/gl_basic.cpp
see – gl_basic.cpp for source code
Set path – /home/scott/gl1/gl_basic/gl_basic.cpp
Use F9 or compile button in toolbar to run the program
compiled Exe (gl_basic) is in – /home/scott/gl1/gl_basic/bin/Release
double click it to run the program
or
Start Terminal
/home/scott/gl1/gl_basic/bin/Release/gl_basic
Compile whole program with static lib to get your Exe working without problems on other machines.