473,237 Members | 1,407 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

Unix, "hello world"

How would I go about creating a simple "hello world" program that will
run in Unix. I am using MS Visual C++.
Jul 22 '05 #1
6 4082
Matthew wrote:
How would I go about creating a simple "hello world" program that will
run in Unix. I am using MS Visual C++.


From the hello world page:

#include <iostream>

int main()
{
std::cout << "Hello, world!\n";
}

If you are interested in various ways of doing hello world, you might find

http://www2.latech.edu/~acm/HelloWorld.shtml

ammusing.
Best

Kai-Uwe
Jul 22 '05 #2
Matthew wrote:
How would I go about creating a simple "hello world" program that will
run in Unix. I am using MS Visual C++.


#include <iostream>

int main()
{
std::cout << "hello world" << std::endl;
return 0;
}

- Pete
Jul 22 '05 #3
Matthew posted:
How would I go about creating a simple "hello world" program that will
run in Unix. I am using MS Visual C++.


#include <iostream>

int main(void)
{
std::cout << "Hello World!!";
}
Jul 22 '05 #4
Matthew wrote:
How would I go about creating a simple "hello world" program that will
run in Unix. I am using MS Visual C++.


Visual C++, AFAIK, is only capable of creating executable that run
on MS Windows. Older versions could create MS-DOS executables, and
there is a cross-compiler for Mac OS.

There is another way, though. You could use a third-party product
to run a Windows executable on Unix. I've heard of WinE and VMWare.
Both are kind of "virtual machines". They would run the executable,
but slower and with limited access to OS resources.

One thing you should know, every Unix-clone OS comes with its own
version of a C compiler (and often with a C++ compiler too). So,
in order to create a program on Unix, you don't need Visual C++.

Also, it's all irrelevant to comp.lang.c++ because it's all platform
specific. Please ask the question about creating an executable from
your code either in a newsgroup for your OS or for your compiler.

V
Jul 22 '05 #5
Matthew wrote:
How would I go about creating a simple "hello world" program that will
run in Unix. I am using MS Visual C++.


Well, first, I'd trash VC and get a compiler that generates Unix
executables...
Jul 22 '05 #6
Matthew wrote:
How would I go about creating a simple "hello world" program that will
run in UNIX. I am using MS Visual C++.


You've got a few answers, but not really the whole picture yet.

Box, Pete and Kop showed you how to write source code that's portable to
UNIX. Just use only the ANSI interface, like what Bjarne Stroustrup
describes in The C++ Programming Language, and you'll be good.

To do much else in UNIX, you'll need to use POSIX, which is an API that
most, if not all, UNIX systems support fully, so you should check it
out. Any good book that talks about UNIX programming will cover POSIX.
Example: Advanced Programming in the UNIX Environment, by W. R. Stevens.

That's how to write code for UNIX.

The next group is talking about cross compilers. A cross compiler
compiles on one type of system (example: Win 32) to a different type of
system (example: UNIX). I can't think of any cross compilers off the
top of my head. GCC (the GNU compiler) will do it, but it's very
complicated. If someone hasn't made and maintain binaries to do what
you want, it may not be worth it to try to do this yourself. The GCC
Cross-Copmile HOWTO is stale (old, out-of-date) and might not be of much
help.

The alternative is to use a library to do your dirty work for you. Wine
was mentioned (www.winehq.org). This library emulates most (not all)
windows function calls, which allows you to run BINARY windows programs
on a UNIX system. I think it'll even run .exe files directly. Check it
out if this sounds like what you are after.

There are also libraries that allow UNIX programs to run on windows.
Cygwin (www.cygwin.com) is free and gives you an environment for running
UNIX programs. Cygwin also gives you a full UNIX development
environment, so this maybe is something you should consider seriously.
Instead of tediously switching computers to test your UNIX programs, or
using a dual-boot setup, you could just run cygwin and test and develop
there, and learn something about UNIX itself at the same time. All this
without ever having to leave windows! Plus it's free. Definitely check
this out.

Also, MinGW (www.mingw.org) is a free gcc compiler for windows. It only
gives you about 80% of the POSIX environment, but runs native UNIX
programs. It's better integrated into windows than Cygwin. And it can
even run UNIX configure scripts (with MSYS, available on the same site).
But it's not a full unix environment, just a gcc compiler for windows.
It's really designed for moving from UNIX to windows with GCC, not the
other way around. But it's still good so you might want to look at it.

Finally, the best way to go might just to get some neutral (neither
Win32 nor POSIX) library. This is the way to go if you're starting from
scratch (if you're porting a large existing code base, look into the
emulation libraries above). wxWindows (www.wxwindows.com) is a portable
GUI library that gives you much more than just POSIX (no GUI in POSIX),
and is also portable to a large number of systems, win32, UNIX and
UNIX-like. There's also SDL (www.libsdl.org) which is similar to
wxWindows but lighter weight and designed for media (games, etc.) type apps.

There you go!

Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ME | last post by:
I am trying to find a prewritten method for converting a string like this:"Hello World" to this "Hello\sWorld". I plan to use it to build a regular expression. Specifically I am looking for a...
9
by: PG | last post by:
Hi gurus, I have AIX visual age C++ compiler version 5.0.2.3. I have a simple hello world program that gives compilation errors. Any help will be appreciated. Thanks PG ***test.cpp**** ...
21
by: Alf P. Steinbach | last post by:
Just because there seems to be a lack of post-standard _correct_ tutorials: <url: http://home.no.net/dubjai/win32cpptut/>. Disclaimer: written this evening so perhaps there are "bugs" in the...
33
by: ankursinha | last post by:
Hi, Is it possible to write a C program that prints "Hello World" on screen without having a single semi-colon in the entire program? The extra constraint here is that u r not allowed to use...
42
by: Prashanth Badabagni | last post by:
Hi, Can any body tell me how to print "hello,world" with out using semicolon Thanks in advance .. Bye Prashanth Badabagni
8
by: vijay | last post by:
Hello, As the subject suggests, I need to print the string in the reverse order. I made the following program: # include<stdio.h> struct llnode { char *info;
4
by: arnuld | last post by:
i am learning C and doing the exercise 1-1 of K&R2, where K&R ask to remove some parts of programme and experiment with error, so here i go: #include <stdio.h> int main () { printf('hello...
0
by: Gerardo Herzig | last post by:
Hi all. Im having some "problems" with a small concurrent plpython function. Based on a small example about concurrent programming, there is some code which works fine under python: #!...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.