You are not logged in.

#1 2009-05-06 17:31:38

neuwerld
Member
From: Sweden
Registered: 2009-03-13
Posts: 75
Website

C++ on linux? [SOLVED]

Hello you will have to excuse me Im really a beginner at programming.
I bought a book about programming C++, but in the examples given in the book the program are runned as .exe files.
How do I manage to solve this problem when Im sitting on an linux machine.
Is the only way to run a virtual desktop with windows to test the programs or what?

Thanks in advance!

Last edited by neuwerld (2009-05-06 19:42:47)

Offline

#2 2009-05-06 17:37:55

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

Re: C++ on linux? [SOLVED]

unless the examples use windows-specific code (directx,windows forms,etc)  they will compile and run fine on linux.

you will probably want to use an IDE ( analog to visual studio on windows), personally i like codeblocks. a bit of googling should help you out smile

Last edited by schuay (2009-05-06 17:39:48)

Offline

#3 2009-05-06 18:10:18

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

Re: C++ on linux? [SOLVED]

The '*.exe' files are known as 'windows executables' which run natively on windows;
and you can run them in linux (the most of them) by installing wine and running the command wine <sample.exe>

You can compile the examples in that book in linux too.
Just use the "gcc/g++" tool and then execute the files into the terminal (as usual).

You can also compile (create) windows executables by using the "mingw32-gcc" tool.

Last edited by quarkup (2009-05-06 19:48:07)


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

#4 2009-05-06 19:42:32

neuwerld
Member
From: Sweden
Registered: 2009-03-13
Posts: 75
Website

Re: C++ on linux? [SOLVED]

Thanks for all the help I will try them out!
I may have been taken water over my head with this smile

Offline

#5 2009-05-07 02:14:53

dmartins
Member
Registered: 2006-09-23
Posts: 360

Re: C++ on linux? [SOLVED]

On linux, you would do something like g++ -o myprogram myprogram.cpp
If the program compiles successfully you would end up with 'myprogram' in your current directory.
To run this you'd type ./myprogram
The -o flag to g++ tells it what to name the resulting executable. If you leave this out, it defaults to a.out.

Don't assume you're in over your head yet! There is a steep learning curve when it comes to learning your first one or two programming languages. I'd suggest looking up some basic C++ on linux tutorials to get you over the initial differences between programming on linux and what you'll read in the book.

Last edited by dmartins (2009-05-07 02:18:53)

Offline

#6 2009-05-07 12:00:28

EVRAMP
Member
From: Czech Republic
Registered: 2008-10-03
Posts: 173
Website

Re: C++ on linux? [SOLVED]

I am a happy user of Geany - A fast lightweight IDE and text editor with syntax.

Offline

#7 2009-05-07 18:36:45

JK3mp
Member
Registered: 2009-03-25
Posts: 105

Re: C++ on linux? [SOLVED]

But beware functions and header libraries that are windows specific, thats the only prob with some c++ books is they don't cover much into how to do some things in linux or IF you hvae linux do this or use this as recommended etc.

Offline

Board footer

Powered by FluxBB