I'm getting this error. I'm guessing either there is an error in my code or I am missing a library. Can I please have some ideas on what the problem is?
Code:
main.c:(.text+0x55): undefined reference to
Code:
$ gcc *.c
/tmp/ccP8MDTO.o: In function `getInput':
main.c:(.text+0x55): undefined reference to `validateInput'
main.c:(.text+0xb2): undefined reference to `validateInput'
main.c:(.text+0x10f): undefined reference to `validateInput'
collect2: ld returned 1 exit status
Code:
bool getInput (int* pFahrenheit, int* pFeet, int* pPounds)
{
bool isValid=false;
//Prompt for Temperature
int count=scanf("%d",pFahrenheit);
if(count==1)
{
if (validateInput(*pFahrenheit,0,212))
{
isValid=true;
}
}
}
I'm getting this error. I'm guessing either there is an error in my code or I am missing a library. Can I please have some ideas on what the problem is?
Code:
main.c:(.text+0x55): undefined reference to
Code:
$ gcc *.c
/tmp/ccP8MDTO.o: In function `getInput':
main.c:(.text+0x55): undefined reference to `validateInput'
main.c:(.text+0xb2): undefined reference to `validateInput'
main.c:(.text+0x10f): undefined reference to `validateInput'
collect2: ld returned 1 exit status
Code:
bool getInput (int* pFahrenheit, int* pFeet, int* pPounds)
{
bool isValid=false;
//Prompt for Temperature
int count=scanf("%d",pFahrenheit);
if(count==1)
{
if (validateInput(*pFahrenheit,0,212))
{
isValid=true;
}
}
return(isValid);
}
Most importantly, the diagnostics you're getting say that you have at least three calls to a function named validateInput() that is not defined in your source file and is not included in any of the libraries you're linking. One of those calls is in the function you included above. Where is the function validateInput() defined?
Once you fix that, note that you have declared that your getInput() function returns an object of type bool, but the code doesn't return any value. I assume that you want to add a line of code similar to the line in red I added above.
This User Gave Thanks to Don Cragun For This Post:
Most importantly, the diagnostics you're getting say that you have at least three calls to a function named validateInput() that is not defined in your source file and is not included in any of the libraries you're linking. One of those calls is in the function you included above. Where is the function validateInput() defined?
Once you fix that, note that you have declared that your getInput() function returns an object of type bool, but the code doesn't return any value. I assume that you want to add a line of code similar to the line in red I added above.
Thank you. validateInput() is not defined anywhere.
Yes your right I need to return that.
Is the bool getInput declaration ok? It took me awhile to figure out a way to use it and the compiler not give me an error. I wasn't able to find very much c programming documentation on a bool function. I eventually did this since I saw it recommended several times when I googled it.
Thank you. validateInput() is not defined anywhere.
Yes your right I need to return that.
Is the bool getInput declaration ok? It took me awhile to figure out a way to use it and the compiler not give me an error. I wasn't able to find very much c programming documentation on a bool function. I eventually did this since I saw it recommended several times when I googled it.
If you have a C programming environment that conforms to the 1999 C standard, you should include the stdbool header:
Code:
#include <stdbool.h>
before using bool, true, and false in your program. If you include that header, bool is defined to be an appropriate type and true and false will be defined appropriately for your programming environment. If your compiler provides stdbool.h, you should not use #defines to define bool, false, and true; you should use #include <stdbool.h> instead.
This User Gave Thanks to Don Cragun For This Post:
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
The problem is a function which i typed although it kept saying that it is a undefined reference still. other... (1 Reply)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
i know when undefined reference shows up the program is saying it is not link to that function but the problem... (1 Reply)
Hi guys.
H was learning posix threads in C with anjuta IDE. it gives me
undefined reference to `pthread_create'
I know i should compile it like:
gcc -lpthread main.c
how should i import this configuration in anjuta so i can compile inside it? (2 Replies)
I try to compile a sample c code in fedora eclipse 3.2 as managed makefile using pthread library,it shows some error on pthread functions.Error is of undefined reference to pthread.Anybody guide me to solve this problem.
Thanking you (1 Reply)
Hi, i want to compile a code where fortran calls c . First I compiled C module ,it has pass by gcc. However, after generating .o file. I compiled C and fortran files together by intel fortran and it failed " undefined reference to 'vicerror'". vicerror is a function. I do not know why. (1 Reply)
when i compile my program, i meet the following error:
...
undefined reference to `__ctype_b'
...
anybody knows which shared library should be linked during make?
thanks a lot! (6 Replies)
Hi
I wanted to learn communication between threads and I used a simple example but
I faced with this error while I have a sofware that uses this functions without
any problem
so would you please help me to know the reason
thanks for your help and great favor.
#include <pthread.h>... (2 Replies)
I m writting code in c using another library(parapin) and making Makefile .but there is a error like
undefined reference to `sinf'
undefined reference to `ceilf'
although i have added math.h library in my code
. I tried to run simple programme using math.h
and it run.but in making Makefile it... (2 Replies)
Hello,
plz help me out with this error,
i am getting this error when i compile my code with gcc.
/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
/tmp/cciLxqdV.o(.text+0x3c): In function `HandleUserTransaction()':... (2 Replies)