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 06-25-2002, 04:24 PM   #1
Eits0
Member
 
Registered: May 2002
Location: Finland
Distribution: Mandrake 9.0
Posts: 188

Rep: Reputation: 30
Linking program in g++?


OK, I have begun serious self-studying of C++, and I'm currently at day 4 in the book "Teach Yourself C++ Programming in 21 days". It is very, VERY good book in my opinion!!!

However, in day one, there was little confucing thing called "linking", which was explained like "Translated source code becomes .OBJ file, which then can be linked to working .exe file."

I use g++ to translate my code, and it has never created any .obj files which I should link. It just makes .exe, or what ever it's called in Linux(?).
Soooo, my question is: Should it make .obj file or is it just winblows feature?

After I have completed the book, prepare for difficult questions

PS: You feel smart? What is value range (arvoalue) of unsigned long int
 
Old 06-25-2002, 10:12 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
You must be compiling and linking in a single step to avoid creating object (.o) files. When you start creating more complex projects that require makefiles to assist in building you will be creating object files prior to linking.
 
Old 06-25-2002, 10:21 PM   #3
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
btw: 32 bits - 4294967295
 
Old 06-26-2002, 08:05 AM   #4
Eits0
Member
 
Registered: May 2002
Location: Finland
Distribution: Mandrake 9.0
Posts: 188

Original Poster
Rep: Reputation: 30
Quote:
btw: 32 bits - 4294967295
That is the correct answer!!!

OK, so if I'm going to make complex program that has self created libraries(? .h ending files anyway) I must link them together.
And am I able to run those programs I have now translated in machines without Dev software???

thx
 
Old 06-26-2002, 09:37 AM   #5
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
No, multiple .h files will not require you to link multiple .o files. You will only have to link multiple .o files if you write multiple .c files. It's at this stage that make (man make) becomes useful. Until you start writing serious (useful) programs I wouldn't recommend worrying too much about this, just keep your source in one file.

Not quite sure if I understand your second question, but the executable produced will not require gcc to run, if that's what you mean.

Alex
 
Old 06-26-2002, 12:33 PM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
To answer the second question: yes. If you have uses static linking (the default one), the answer is yes.
 
Old 06-27-2002, 08:02 AM   #7
Eits0
Member
 
Registered: May 2002
Location: Finland
Distribution: Mandrake 9.0
Posts: 188

Original Poster
Rep: Reputation: 30
OK, thankyou.
Now I feel bit wiser again.
 
  


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
Linking program with .a libraries rudy2 Programming 2 04-22-2005 05:36 AM
Problem linking assembly program with C lib. 95se Programming 1 03-08-2005 09:44 PM
Problems linking a C library into a C++ program sfrdll Programming 3 06-21-2004 01:36 PM
a simple dynamic linking program kris273 Programming 3 04-18-2004 06:26 AM
C++, linking, and program distribution leiavoia Programming 11 08-24-2003 05:35 PM

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

All times are GMT -5. The time now is 03:24 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