aspose file tools*
The moose likes C / C++ and the fly likes Problem in linking files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Problem in linking files" Watch "Problem in linking files" New topic
Author

Problem in linking files

prem.sagar yadav
Greenhorn

Joined: Mar 21, 2012
Posts: 1
Hi All,
I am facing problem in linking a file to the main file in eclipse.I am working on Linux platform.Program is running fine using Linux terminal.Problem is with <math.h> hrader.
After including a file as header to main file I am compiling the program with the following command.

gcc -lm -Wall -pedantic -ansi -o logfile.c log.c(Where logfile.c is main file and log.c is file included).

It is working fine on terminal.But while running through Eclipse I am running same command on

Right-Clicking on project--->Properties>settings On GCC Linker But getting the error


**** Build of configuration Debug for project LogPrj ****

make all
Building target: LogPrj
Invoking: GCC C Linker
gcc -lm -Wall -pedantic -ansi -o logfile.c myLog.c -o"LogPrj" ./src/logFile.o ./src/myLog.o
gcc: myLog.c: No such file or directory
make: *** [LogPrj] Error 1

CAN ANYBODY HELP ME IN GETTING RID OFF THIS PROBLEM AS I AM A BEGINNER TO C PROGRAMMING.

FILE NAME: log.c

float myLog(float n)
{
float p,s,i,z;
float a,b,c,d,e;
p=n-1;
s=n+1;
i=p/s;
a=i*i*i;
b=i*i*i*i*i;
c=i*i*i*i*i*i*i;
d=i*i*i*i*i*i*i*i*i;
e=i*i*i*i*i*i*i*i*i*i*i;
z=2*(i+(a/3)+(b/5)+(c/7)+(d/9)+(e/11)+(b*c*i/13)+(e*a*i/15)+(e*b*i)/17);
z=z+2*((e*c*i/19)+(e*d*i/21)+(e*e*i/23)+(e*e*a/25)+(e*e*b/27)+(e*e*c/29));
z=z+2*((e*e*d/31)+(e*e*e/33)+(e*e*e*i*i/35)+(e*e*e*a*i/37)+(e*e*e*b*i/39));
z=z+2*((e*e*e*c*i/41)+(e*e*e*d*i/43)+(e*e*e*e*i/45)+(e*e*e*e*a)/47);
z=z+2*((e*e*e*e*b/49)+(e*e*e*e*c/51)+(e*e*e*e*d/53)+(e*e*e*e*e/55));
z=z+2*((e*e*e*e*e*i*i/57)+(e*e*e*e*e*a*i/59)+(e*e*e*e*e*b*i/61));
z=z+2*((e*e*e*e*e*c*i/63)+(e*e*e*e*e*d*i/65)+(e*e*e*e*e*e*i/67));
z=z+2*((e*e*e*e*e*e*a/69)+(e*e*e*e*e*e*b/71)+(e*e*e*e*e*e*c/73));
z=z+2*((e*e*e*e*e*e*d/75)+(e*e*e*e*e*e*e/77)+(e*e*e*e*e*e*e*i*i/79));
z=z+2*((e*e*e*e*e*e*e*a*i/81)+(e*e*e*e*e*e*e*b*i/83)+(e*e*e*e*e*e*e*b*i/85));
z=z+2*((e*e*e*e*e*e*e*c*i/87)+(e*e*e*e*e*e*e*e*i/89)+(e*e*e*e*e*e*e*e*a/91));
z=z+2*((e*e*e*e*e*e*e*e*b/93)+(e*e*e*e*e*e*e*e*c/95)+(e*e*e*e*e*e*e*e*d/97));
z=z+(2*e*e*e*e*e*e*e*e*e/99);
return z;
}

FILE NAME: logfile.c(Main File)

/*
* logFile.c
*
* Created on: Mar 21, 2012
* Author: root
*/

#include <stdio.h>
#include <math.h>

int main()

{
float q;
FILE *ofp;
int i, j, k;
double l, x = 1.0;

printf("Enter Lower Value ==>");
scanf("%d", &i);
printf("Enter Upper Value ==>");
scanf("%d", &j);

for (k = i; k <= j; k++) {
printf("value of k==>%d\n", k);


l = log(k);


printf("value of log is ==>%f\n", l);

ofp = fopen("outputlog.txt", "a+");
fprintf(ofp, "%d\t%f\t%f\n", k, l, q);

}
return (l);
}




With Regards
Prem Sagar

Anil Kollur
Ranch Hand

Joined: Mar 25, 2000
Posts: 101

Your 2nd file name is "log.c" and not "myLog.c" hence enter the correct filename.
You have named the function inside "log.c" and myLog{} and not the file name as such.
The compiler is clearly stating as it cannot find myLog.c file -> instead try with "log.c" and check


Everyday is a Learning phase! Hence ask "What have I learnt today?"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in linking files