LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-02-2004, 10:53 AM   #1
Kedaeus
LQ Newbie
 
Registered: Aug 2004
Posts: 6

Rep: Reputation: 0
From .Net to C/C++ in Linux ... Eeep!


.. . . A friend of mine, last Friday, passed me a copy of Mandrake 9.x over my cubicle at work. He was being funny, and didn't think that I would go home and install it.. Well I did - and now I’m all the more curious, albeit overwhelmed.. I asked him to bring me a copy of MD10 this morning.

I spend my spare time developing web content with ASP.Net, C#, Vb.Net, and Macromedia Flash.. as well as database applications… and multimedia applications for a personal project I am working on**

I’m a bit confused as to how Linux works for a programmer.. I’m having trouble finding information, from beginning to end, on how to start developing programs in Linux..

It’s somewhat creepy migrating from a society of rules – to one where you make you own law and I fear I’ve been conditioned, as a programmer/computer user, into believing that windows is the end-all-be-all operating system..

**I’m working on a personal project that requires a bare bones operating system.. and unfortunately you can’t get that from Windows, and distribute it, without breaking a licensing law, or the EULA contract.. I’ve been reading a lot about LFS and my question(s) is(are):

Can I develop an application using Kdevelop in Mandrake 9/10 and have it work on… RedHat, Linspire, LFS, Et.al? Or are programs OS/API specific?

Where can I find programming information for the linux Newbie so that I can bring my coding skills in Linux up to par with – or even surpass – my programming skills in Windows? A simple, yet well documented, Hello World tutorial would satiate my appetite and get me started on the path.. also any books that you have read that helped you out would be a great deal of help.

What do you guys use to develop your applications? Is there a specific distro that offers more to the programmer/developer than what I am using?

I have a lot more: But I’ll leave them at that, for now.

-Kedaeus-
 
Old 08-02-2004, 02:12 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
In general, a binary program file compiled on one distribution cannot be guarenteed to run on another because of incompatible library versions; programs are normally distributed in source code for this reason.

It is, however, possible to compile programs as static binaries — programs that do not use external libraries, and link everything into one big file. Then it'll run on any Linux system, provided the CPU is of the right family (you still can't compile a program for an Apple PPC and have it run on i386). To do this, pass the -static option to the compiler.

As far as development environments are concerned, I've heard lots of good things about KDevelop (part of KDE, installed on all major distributions). Personally, I just use xemacs and the command-line.

If you're looking for tutorials, you should find plenty on the web. For the most part, Linux uses standard ANSI C and C++ code. For learning C++, I can recommend the Sams “Teach yourself C++ in 24 hours” book (but it takes over 24 hours to get all the way through it). I already had some programming experience when I started reading it but found it a good introduction to the methodologies of C++.

Hope that's of some help,

— Robert J. Lee
 
Old 08-02-2004, 02:52 PM   #3
SheldonPlankton
Member
 
Registered: Jun 2004
Posts: 129

Rep: Reputation: 15
Here's a very simple Hello World tutorial ...

Redirect stdin to a file called hello.c with cat to create your source code.

Code:
$ cat > hello.c
#include <iostream>
int main() {
std::cout << "Hello, World." << std::endl;
}
^D
Now create a executable called hw with the GNU C++ compiler.
Code:
$ g++ -o hw hello.c
Now execute the program ...
Code:
$ ./hw
Hello, World.
I look at the difference between WIndow development and development in every other environment like this ... In Windows the IDE/framework/whatever assumes to know more about what you want to do than you do thus it is responible for your success. Outside of windows you have only mere tools that only do what you tell to do ,thus responibility for your success (or failure) is yours and yours alone.
 
Old 08-02-2004, 04:05 PM   #4
Kedaeus
LQ Newbie
 
Registered: Aug 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by SheldonPlankton
I look at the difference between Window development and development in every other environment like this ... In Windows the IDE/framework/whatever assumes to know more about what you want to do than you do thus it is responsible for your success. Outside of windows you have only mere tools that only do what you tell to do ,thus responsibility for your success (or failure) is yours and yours alone. [/B]
Very intuitive SheldonPlankton.. and I assume - from my inability to jump in and figure things out - your theory is correct.

Thanks for the code too. One step further in my quest to figuring this stuff out.

-Kedaeus-
 
Old 08-02-2004, 05:04 PM   #5
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Try not to name C++ source code files with a .c extension like SheldonPlankton did. C++ filenames should have a .C (capital c) or .cpp extension. Here's an example of creating a simple hello world program in C:
Code:
#include <stdio.h>

int main(void)
{
  printf("Hello, world!\n");
  return 0;
}
Save that code in a .c file with any text editor or create it the same way SheldonPlankton created the C++ one.

You'd compile it the same way SheldonPlankton compiled the C++ one except you'd use gcc instead of g++: gcc -o hw hello.c
 
Old 08-02-2004, 05:15 PM   #6
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
It should be mentioned that although binaries might not be very portable between *nix systems, source is more so. Most open source projects are developed using a pair of tools called autoconf and automake. They are a framework which handles Makefiles for you and helps manage conditional compilation for various systems. Once you have your source set up with this system, you do a "make dist" and you get a tarball of your source which will (as long as you haven't done any no-nos portability-wise) compile on any *nix system with "./configure && make && make install". (It might require some libraries to be installed before compiling, but not in any distro-specific location)


OT:
You say you have trouble finding information about developing on linux, and I have the same problem with windows. In particular, I have no idea how to go about making one of those installer gizmos -- the wizard where you click next a bunch of times and it puts the binary in the right place plus adds an entry to the start menu. Could you point me in a direction for that? (Needs to be free, at least as in beer..) Do you need to do anything special to make this installer dealy work for a java app?
 
Old 08-02-2004, 06:46 PM   #7
Kedaeus
LQ Newbie
 
Registered: Aug 2004
Posts: 6

Original Poster
Rep: Reputation: 0
I know very little about Java as a stand alone language.

I do know that Visual Studio .Net supports Java Development.

Microsoft was gracious enough, in earlier versions of Visual Studio, to include a Packaging and Deployment wizard** for wraping up your program, and copies of all it's dependant files, in plastic.

However, I've yet to see it on a .Net basis due to the shear amount of web work i've been doing. There is very little to package and deploy when you do all of your work right there on the server.

So unfortunately I cannot comment on that.

And if you are using something other than .Net then I am even farther out in the middle of nowhere.

**This P&DWiz was located under the start menu /programs/Vis Studio/Tools/Package & Deployment
 
Old 08-02-2004, 07:28 PM   #8
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Since you are familiar with C# already, you might also want to take a look at DotGNU, which is basically an OpenSource implementation of the .Net APIs. I've even used it to run apps compiled with VC# .Net on Windows and run it directly on Linux w/o recompiling and vice versa.

You may want to learn other languages like C/C++, and maybe something like Python later on, but if you were to start with DotGNU, you could program with something that is a bit more familiar to you while you get used to the whole Linux environment.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
.Net on Linux neosap Linux - Software 3 05-10-2005 08:33 AM
.NET and linux? Lleb_KCir Linux - Software 2 01-25-2005 10:17 PM
How to get on the net with linux Astropicachu Linux - Newbie 9 04-26-2004 03:54 AM
Xp to net via linux pingurslap Linux - Networking 3 01-08-2004 12:31 PM
.net on linux ?? juby Programming 30 07-21-2003 01:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration