Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-26-2003, 04:11 PM   #1 (permalink)
ShadowSoft
Registered User
 
ShadowSoft's Avatar
 
Join Date: Feb 2003
Location: NJ
Posts: 7
ShadowSoft is on a distinguished road
Send a message via AIM to ShadowSoft
Question Linking files?

I'm currently familiar with Turbo Pascal, and decieded to load a c++ compiler on my home computer.

I got a free copy of Bloddshed softwares Dev 4.1 C++.
i tried the basic every programers first, "Hello World"
but the funny thing is that i get no output. Then i read about linking files, even after reading their explanation I'm in the dark.
Does anyone understand what it is to link your files and how you'd go about doing it?
much thanks.
ShadowSoft is offline   Reply With Quote
Old 02-26-2003, 04:43 PM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
i don't think that linking is your problem, perhaps you can show us your program and we'll figure out what's wrong.

anyway, here is an explanation of linking:

(compile-time) linking takes the compiled binary generated from your code, and connects all the pieces together into one binary executable file.
for example, let's say you have 2 files, main.cpp and foo.cpp.
foo.cpp contains the foo() function, and main.cpp contains the main() function, and within main() is a call to foo(). when your compiler compiles main.cpp it generates an object file called main.o (visual studio names them main.obj). in this object file is a symbol, which basically tells the linker "the address of function foo goes here".
when all the object files have been created, it's the job of the linker to take them all and create one executable file. the linker looks at main.o, sees the symbol for foo, and looks through all the object files until it finds where foo() is and puts that in its place. that way your main function can correctly call the foo function.
i imagine your ide is invoking the linker (though gcc) automatically when you perform some sort of 'build' command.

linking also comes into play when you use libraries. luckily for you, your compiler knows how to link in standard libraries (ex: iostream), without any help from you.

this explanation leaves out dynamic linking, but you probably don't need to worry about it for now.
joe_bruin is offline   Reply With Quote
Old 02-27-2003, 07:46 AM   #3 (permalink)
carrja99
Registered User
 
Join Date: Feb 2003
Posts: 34
carrja99 is on a distinguished road
I don't think linking files is your problem, most likely it is either your code or the compiler you are using. The simple basic "hello world" C++ program is:

Code:
#include <iostream.h>

int main()
   {
   cout << "Hello World!" << endl;
   return 0;
   }
As for a compiler, when I was a windows user I used Borland C++, which I thought was the best at the time. However, I currently use g++, and I think there is a windows equivalent named DJGPP or something like that. I suggest you look at that or the free Borland C++ compiler I keep hearing of.
carrja99 is offline   Reply With Quote
Old 02-27-2003, 12:33 PM   #4 (permalink)
ShadowSoft
Registered User
 
ShadowSoft's Avatar
 
Join Date: Feb 2003
Location: NJ
Posts: 7
ShadowSoft is on a distinguished road
Send a message via AIM to ShadowSoft
Lightbulb Well don't i feel stupid

As for a compiler, when I was a windows user I used Borland C++, which I thought was the best at the time. However, I currently use g++, and I think there is a windows equivalent named DJGPP or something like that. I suggest you look at that or the free Borland C++ compiler I keep hearing of.
--------
yeah i meant to write Borland C++. I love that language which is probably one reason why I might be having difficulty with bloodshed's g++.
the cd also came with DJGPP, but i haven't a clue how and what to load.
it's weird the program says that i shouldn't be using
cout<<"hello world"<<endl;
this program goes as....

#include <iostream>

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

---------
and then..i tried using the tutorial and when it cme time to run it was missing files and the updated version the buttons on the toolbar don't work.
My advice is stay away from BloodShed's DevC++4.1 and above.....the whole setup is confusing and it's just plain annoying to use.:th: on you if you hate Borland..the only truly good compiler out there.
ShadowSoft is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code For Displaying files in List Box shash MS Technologies ( ASP, VB, C#, .NET ) 1 08-23-2004 09:53 PM
Installing and using CMUgraphics library. Valmont Standard C, C++ 12 03-29-2003 08:39 AM
All Class Files mixingsoup PHP 12 12-04-2002 06:49 AM


All times are GMT -8. The time now is 10:29 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting