LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 09-20-2004, 02:21 PM   #1
eddydw
LQ Newbie
 
Registered: Jan 2003
Location: Belgium (Wetteren)
Distribution: Red Hat Linux 7.3
Posts: 11

Rep: Reputation: 0
Linker error


Hi ,

I have 3 smaal c programs and cpp programs
See below :
--------------------------------------------------
file reciprocal.hpp

#ifdef _cplusplus
extern "C" {
#endif

extern double reciprocal (int i);

#ifdef _cplusplus
}
#endif
--------------------------------------------------
file reciprocal.cpp
#include <cassert>
#include "reciprocal.hpp"


double reciprocal (int i) {
// I should be non-zero.
assert (i != 0);
return 1.0/i;
}
--------------------------------------------------
file main.c
#include <stdio.h>
#include "reciprocal.hpp"

int main(int argc, char **argv)
{
int i;
i = atoi (argv[1]);
printf("The reciprocal of %d is %g\n",i,reciprocal(i));
return 0;
}


First I compiler main.c with following command gcc -c main.c
Second I compiled reciprocal.cpp with following command g++ -c reciprocal.cpp
then I linked them together with g++ -o reciprocal main.o reciprocal.o.

I get following error after linking but don't understand what this means.

g++: main.o: No such file or directory
g++: reciprocal.o: No such file or directory
g++: no input files

Is this documented somewhere?
Can someone of the expert give me some help please?

Thanks in advance,
Eddy

BTW I am follwing the instructions in the Advanced Linux Programming book
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
linker error pavan Programming 2 10-06-2005 02:58 AM
ld linker error Ankit mittal Programming 2 09-30-2005 08:40 AM
gcc Linker error - please help! Liche Programming 5 09-26-2005 08:14 AM
Linker Error dim79 Programming 2 06-28-2003 10:53 AM
linker error Config Programming 8 06-04-2002 04:33 AM


All times are GMT -5. The time now is 08:44 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration