problems with a C program on different machines, using different compilers

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 2
Reputation: mhelal is an unknown quantity at this point 
Solved Threads: 0
mhelal mhelal is offline Offline
Newbie Poster

problems with a C program on different machines, using different compilers

 
0
  #1
Oct 7th, 2006
Hi

I have Fedora Core 5 2.6.17-1.2174_FC5 with gcc version: gcc (GCC) 4.1.1 200
60525 (Red Hat 4.1.1-1)

everything compiles well, and run smoothly on my machine. But the actual production machine is Linux 2.4.20-46.9.legacysmp
with gcc version gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

on the production machine, I get errors like:
1) warning #266: function declared implicitly
while ((read = getline (&line, &len, sfile)) != -1) {

2) undefined reference to `sem_init'
3) undefined reference to `sem_destroy'

while I am using the correct headers:
#define _GNU_SOURCE
#include <stdio.h>

for the getline

and
#include <semaphore.h>

for the sem_init and sem_destroy

I receive the same "warning #266: function declared implicitly" for my own defined functions as well, while my header is included,

any ideas where could be the problem,

sorry for asking a question that might be basic, but it is my first time to move code between different machines in linux and compilers versions,

I appreciate any help,

thanks,

Manal
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 275
Reputation: andor has a spectacular aura about andor has a spectacular aura about andor has a spectacular aura about 
Solved Threads: 29
andor's Avatar
andor andor is offline Offline
Posting Whiz in Training

Re: problems with a C program on different machines, using different compilers

 
0
  #2
Oct 7th, 2006
So if I understand corectly even you include your header files the compiler tells you that they are implicitly declared. That means that in first case they were also implicitly declared but the linker resolved the problems but with the second compiler the linker didn't resolved it. Always declare explicitly if U want to avoid these kind of problems.
Btw the getline is not C function and its not declared in stdio.h.
If you want to win, you must not loose (Alan Ford)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,398
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1467
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: problems with a C program on different machines, using different compilers

 
0
  #3
Oct 7th, 2006
getline() in the posted example is probably his own C function because the parameters are incorrect for the c++ version. May I suggest you look in semaphore.h and see if there is a marco you need to define.
Last edited by Ancient Dragon; Oct 7th, 2006 at 8:34 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2
Reputation: mhelal is an unknown quantity at this point 
Solved Threads: 0
mhelal mhelal is offline Offline
Newbie Poster

Re: problems with a C program on different machines, using different compilers

 
0
  #4
Oct 7th, 2006
thank you for your help,

No, I didn't declare a function called getline in my code, and I used it based on the manual as in:
http://www.die.net/doc/linux/man/man3/getline.3.html

and same about sem_init and sem_destroy, both are used according to:

http://www.die.net/doc/linux/man/man3/sem_init.3.html

and
http://www.die.net/doc/linux/man/man...destroy.3.html

and I can locate the semaphore.h on the machine, and the file contains the definitions:
extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value) __THROW;
extern int sem_destroy (sem_t *__sem) __THROW;

and my own defined functions, can now be located, sorry

Thank you again, I appreciate your help,

Manal
Last edited by mhelal; Oct 7th, 2006 at 11:06 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC