| | |
problems with a C program on different machines, using different compilers
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2006
Posts: 2
Reputation:
Solved Threads: 0
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
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
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.
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)
•
•
Join Date: Oct 2006
Posts: 2
Reputation:
Solved Threads: 0
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
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.
![]() |
Similar Threads
- XP random shut down, lots of other problems (Troubleshooting Dead Machines)
- calendar problem (C)
- C program please help (C)
- Same application not working on all machines (ASP.NET)
- Problems Loading Software (Viruses, Spyware and other Nasties)
- .exe cannot be run on particular machines (Visual Basic 4 / 5 / 6)
- How to code a program that can show color text output??? (C)
- Need help with the program i have written i am unable to correct the problems. please (C++)
Other Threads in the C++ Forum
- Previous Thread: I can't understand "C++ pointer". Please help me!! (code included)
- Next Thread: Help with program
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






