944,031 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2951
  • C++ RSS
Oct 7th, 2006
0

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

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mhelal is offline Offline
2 posts
since Oct 2006
Oct 7th, 2006
0

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

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.
Reputation Points: 251
Solved Threads: 29
Posting Whiz in Training
andor is offline Offline
274 posts
since Jun 2005
Oct 7th, 2006
0

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

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005
Oct 7th, 2006
0

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

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mhelal is offline Offline
2 posts
since Oct 2006
Aug 15th, 2010
0
Re: problems with a C program on different machines, using different compilers
hi..i have just installed turbo c++ software on my pc.And when i run a program then the output screen just blinks for a second and then disappears.Can please Suggest with the appropriate solution as soon as possible
Reputation Points: 10
Solved Threads: 0
Newbie Poster
swatithakur is offline Offline
1 posts
since Aug 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Tic Tac Toe 2D array, Need Help
Next Thread in C++ Forum Timeline: Question about vectors





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC