• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem in linking files

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 103
Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic