Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 09-20-2004, 01:21 PM   #1
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" {

extern double reciprocal (int i);

#ifdef _cplusplus
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,

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


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 01:58 AM
ld linker error Ankit mittal Programming 2 09-30-2005 07:40 AM
gcc Linker error - please help! Liche Programming 5 09-26-2005 07:14 AM
Linker Error dim79 Programming 2 06-28-2003 09:53 AM
linker error Config Programming 8 06-04-2002 03:33 AM

All times are GMT -5. The time now is 05:17 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration