LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 05-12-2002, 07:48 AM   #1
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
C++ linking?


How do I link a C++ program properly? gcc complains of a lot of unresolved symbols when I use just gcc foo.cpp. Is there some library I have to link against.?
 
Old 05-13-2002, 03:12 AM   #2
tda
Member
 
Registered: Mar 2002
Location: Ukraine, Kiev
Distribution: Mandrake 7.2
Posts: 37

Rep: Reputation: 15
You definitely have to link your program with some libraries. But which librarires you should link is depends of your program. See also -L -l and -I options for gcc.
 
Old 05-13-2002, 03:59 AM   #3
gui10
Member
 
Registered: Mar 2001
Distribution: enigma, slack8
Posts: 677

Rep: Reputation: 30
i believe the command to compile a C++ program is using g++ instead of gcc. maybe you could try that first?
 
Old 05-13-2002, 06:33 AM   #4
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Original Poster
Rep: Reputation: 30
I highly doubt it. gcc is supposedly able to handle c, c++, and asm and linking of obj code. Besides, my code uses c++ keywords, which would cause syntax errors ona regular c compiler which it didn't. The errors only appeared during linking.
 
Old 05-13-2002, 06:35 AM   #5
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
you should listen to gui only g++ automatically links in the required c++ libraries, gcc will give linker errors for c++ programs
 
Old 05-14-2002, 01:33 AM   #6
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by llama_meme
you should listen to gui only g++ automatically links in the required c++ libraries, gcc will give linker errors for c++ programs
g++ worked. i stand corrected.
 
  


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 Problems doubleds Linux - Software 4 12-03-2004 09:49 PM
linking directories david@aber Linux - Newbie 3 11-25-2004 07:45 AM
Linking LS to 'L' uveraser Linux - General 2 05-20-2004 10:24 AM
Linking Python and C++ irfanhab Programming 2 05-15-2004 01:22 PM
error while linking... trouby Linux - Software 0 10-15-2003 05:18 PM

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

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