relocation truncated, R_X86_64_PC32 against undefined symbol
up vote
0
down vote
favorite
In this C program, I needed to make a a queue applciation in a structured approach. As I was trying to run this program in netbeans, i saw that i was getting a relocation truncated error. My professor told me to run it in Clion and I'm still getting the same exact error. The error is specifically stating that im having undefined reference to 'dequeue', 'enqueue', and 'getCurrentSize'.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value);
void dequeue(int** queue, int* size);
int getCurrentSize(int size);
void display(int* intQueue, int size);
int main()
int input;
int initSize = 3;
int size = 0;
char option = 'a';
char answer = 'y';
int value;
bool enqueueResult, dequeueResult = true;
int* queue = (int*)malloc(initSize * sizeof(int));
for (int i = 0; i<initSize; i++)
queue[i] = 0;
printf("This program implements Queues using structured programming. Enter "
"a number from 1 to 4 . n"
"1. To enqueue a number n"
"2. To dequeue a number n"
"3. To get the current size of the queue n"
"4. To see the contents within the queue n"
"5. Exit the program");
scanf("%d", &input);
switch (input)
case 1:
enqueueResult = enqueue(&queue, &size, value);
if (enqueueResult == true)
printf("The number has been put into the queue!");
else
printf("The number was not able to be enqueued!");
break;
case 2:
dequeue(&queue, &size);
printf("Number was dequeued from the queue");
break;
case 3:
printf("The current size of the queue is: " + getCurrentSize(size));
break;
free(queue);
return 0;
//********************************************************
//QueueLibrary.c below
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value)
int maxSize = *size + 1;
if (*queue == NULL)
return false;
if (*size < 0)
return false;
if (*size == maxSize)
int* copy = (int*)malloc((maxSize + 1) * sizeof(int));
if (copy == NULL)
return false;
maxSize += 1;
for (int i = 0; i < *size; i++)
copy[i] = (*queue)[i];
free(*queue);
*queue = copy;
for (int i = *size; i > *size - 1; i--)
(*queue)[i] = value;
printf("The value %d has been added to the queuen", (*queue)[i]);
*size += 1;
return true;
void dequeue(int** intQueue, int* size)
printf("%d has left the queuen", *intQueue[0]);
for (int i = 0; i < *size; i++)
(*intQueue)[i] = (*intQueue)[i + 1];
if (*size != 0)
*size -= 1;
else
printf("There is nothing left in the queuen");
int getCurrentSize(int size)
return size;
void display(int* intQueue, int size)
printf("The integers in the queue are :n");
for (int i = 0; i < size; i++)
printf("%dn", intQueue[i]);
This is the error message
c declaration relocation
add a comment |
up vote
0
down vote
favorite
In this C program, I needed to make a a queue applciation in a structured approach. As I was trying to run this program in netbeans, i saw that i was getting a relocation truncated error. My professor told me to run it in Clion and I'm still getting the same exact error. The error is specifically stating that im having undefined reference to 'dequeue', 'enqueue', and 'getCurrentSize'.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value);
void dequeue(int** queue, int* size);
int getCurrentSize(int size);
void display(int* intQueue, int size);
int main()
int input;
int initSize = 3;
int size = 0;
char option = 'a';
char answer = 'y';
int value;
bool enqueueResult, dequeueResult = true;
int* queue = (int*)malloc(initSize * sizeof(int));
for (int i = 0; i<initSize; i++)
queue[i] = 0;
printf("This program implements Queues using structured programming. Enter "
"a number from 1 to 4 . n"
"1. To enqueue a number n"
"2. To dequeue a number n"
"3. To get the current size of the queue n"
"4. To see the contents within the queue n"
"5. Exit the program");
scanf("%d", &input);
switch (input)
case 1:
enqueueResult = enqueue(&queue, &size, value);
if (enqueueResult == true)
printf("The number has been put into the queue!");
else
printf("The number was not able to be enqueued!");
break;
case 2:
dequeue(&queue, &size);
printf("Number was dequeued from the queue");
break;
case 3:
printf("The current size of the queue is: " + getCurrentSize(size));
break;
free(queue);
return 0;
//********************************************************
//QueueLibrary.c below
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value)
int maxSize = *size + 1;
if (*queue == NULL)
return false;
if (*size < 0)
return false;
if (*size == maxSize)
int* copy = (int*)malloc((maxSize + 1) * sizeof(int));
if (copy == NULL)
return false;
maxSize += 1;
for (int i = 0; i < *size; i++)
copy[i] = (*queue)[i];
free(*queue);
*queue = copy;
for (int i = *size; i > *size - 1; i--)
(*queue)[i] = value;
printf("The value %d has been added to the queuen", (*queue)[i]);
*size += 1;
return true;
void dequeue(int** intQueue, int* size)
printf("%d has left the queuen", *intQueue[0]);
for (int i = 0; i < *size; i++)
(*intQueue)[i] = (*intQueue)[i + 1];
if (*size != 0)
*size -= 1;
else
printf("There is nothing left in the queuen");
int getCurrentSize(int size)
return size;
void display(int* intQueue, int size)
printf("The integers in the queue are :n");
for (int i = 0; i < size; i++)
printf("%dn", intQueue[i]);
This is the error message
c declaration relocation
You should show the exact error messages you're getting and the command line that produced them.
– R..
Nov 9 at 2:51
i edited the the post to show the error
– Doe J.
Nov 9 at 3:05
3
You are failing to compile and link in theQueueLibrary.c
. You need to update your build process to be sure that file is handled too.
– abelenky
Nov 9 at 3:08
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In this C program, I needed to make a a queue applciation in a structured approach. As I was trying to run this program in netbeans, i saw that i was getting a relocation truncated error. My professor told me to run it in Clion and I'm still getting the same exact error. The error is specifically stating that im having undefined reference to 'dequeue', 'enqueue', and 'getCurrentSize'.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value);
void dequeue(int** queue, int* size);
int getCurrentSize(int size);
void display(int* intQueue, int size);
int main()
int input;
int initSize = 3;
int size = 0;
char option = 'a';
char answer = 'y';
int value;
bool enqueueResult, dequeueResult = true;
int* queue = (int*)malloc(initSize * sizeof(int));
for (int i = 0; i<initSize; i++)
queue[i] = 0;
printf("This program implements Queues using structured programming. Enter "
"a number from 1 to 4 . n"
"1. To enqueue a number n"
"2. To dequeue a number n"
"3. To get the current size of the queue n"
"4. To see the contents within the queue n"
"5. Exit the program");
scanf("%d", &input);
switch (input)
case 1:
enqueueResult = enqueue(&queue, &size, value);
if (enqueueResult == true)
printf("The number has been put into the queue!");
else
printf("The number was not able to be enqueued!");
break;
case 2:
dequeue(&queue, &size);
printf("Number was dequeued from the queue");
break;
case 3:
printf("The current size of the queue is: " + getCurrentSize(size));
break;
free(queue);
return 0;
//********************************************************
//QueueLibrary.c below
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value)
int maxSize = *size + 1;
if (*queue == NULL)
return false;
if (*size < 0)
return false;
if (*size == maxSize)
int* copy = (int*)malloc((maxSize + 1) * sizeof(int));
if (copy == NULL)
return false;
maxSize += 1;
for (int i = 0; i < *size; i++)
copy[i] = (*queue)[i];
free(*queue);
*queue = copy;
for (int i = *size; i > *size - 1; i--)
(*queue)[i] = value;
printf("The value %d has been added to the queuen", (*queue)[i]);
*size += 1;
return true;
void dequeue(int** intQueue, int* size)
printf("%d has left the queuen", *intQueue[0]);
for (int i = 0; i < *size; i++)
(*intQueue)[i] = (*intQueue)[i + 1];
if (*size != 0)
*size -= 1;
else
printf("There is nothing left in the queuen");
int getCurrentSize(int size)
return size;
void display(int* intQueue, int size)
printf("The integers in the queue are :n");
for (int i = 0; i < size; i++)
printf("%dn", intQueue[i]);
This is the error message
c declaration relocation
In this C program, I needed to make a a queue applciation in a structured approach. As I was trying to run this program in netbeans, i saw that i was getting a relocation truncated error. My professor told me to run it in Clion and I'm still getting the same exact error. The error is specifically stating that im having undefined reference to 'dequeue', 'enqueue', and 'getCurrentSize'.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value);
void dequeue(int** queue, int* size);
int getCurrentSize(int size);
void display(int* intQueue, int size);
int main()
int input;
int initSize = 3;
int size = 0;
char option = 'a';
char answer = 'y';
int value;
bool enqueueResult, dequeueResult = true;
int* queue = (int*)malloc(initSize * sizeof(int));
for (int i = 0; i<initSize; i++)
queue[i] = 0;
printf("This program implements Queues using structured programming. Enter "
"a number from 1 to 4 . n"
"1. To enqueue a number n"
"2. To dequeue a number n"
"3. To get the current size of the queue n"
"4. To see the contents within the queue n"
"5. Exit the program");
scanf("%d", &input);
switch (input)
case 1:
enqueueResult = enqueue(&queue, &size, value);
if (enqueueResult == true)
printf("The number has been put into the queue!");
else
printf("The number was not able to be enqueued!");
break;
case 2:
dequeue(&queue, &size);
printf("Number was dequeued from the queue");
break;
case 3:
printf("The current size of the queue is: " + getCurrentSize(size));
break;
free(queue);
return 0;
//********************************************************
//QueueLibrary.c below
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool enqueue(int** queue, int* size, int value)
int maxSize = *size + 1;
if (*queue == NULL)
return false;
if (*size < 0)
return false;
if (*size == maxSize)
int* copy = (int*)malloc((maxSize + 1) * sizeof(int));
if (copy == NULL)
return false;
maxSize += 1;
for (int i = 0; i < *size; i++)
copy[i] = (*queue)[i];
free(*queue);
*queue = copy;
for (int i = *size; i > *size - 1; i--)
(*queue)[i] = value;
printf("The value %d has been added to the queuen", (*queue)[i]);
*size += 1;
return true;
void dequeue(int** intQueue, int* size)
printf("%d has left the queuen", *intQueue[0]);
for (int i = 0; i < *size; i++)
(*intQueue)[i] = (*intQueue)[i + 1];
if (*size != 0)
*size -= 1;
else
printf("There is nothing left in the queuen");
int getCurrentSize(int size)
return size;
void display(int* intQueue, int size)
printf("The integers in the queue are :n");
for (int i = 0; i < size; i++)
printf("%dn", intQueue[i]);
This is the error message
c declaration relocation
c declaration relocation
edited Nov 9 at 3:00
asked Nov 9 at 2:46
Doe J.
62
62
You should show the exact error messages you're getting and the command line that produced them.
– R..
Nov 9 at 2:51
i edited the the post to show the error
– Doe J.
Nov 9 at 3:05
3
You are failing to compile and link in theQueueLibrary.c
. You need to update your build process to be sure that file is handled too.
– abelenky
Nov 9 at 3:08
add a comment |
You should show the exact error messages you're getting and the command line that produced them.
– R..
Nov 9 at 2:51
i edited the the post to show the error
– Doe J.
Nov 9 at 3:05
3
You are failing to compile and link in theQueueLibrary.c
. You need to update your build process to be sure that file is handled too.
– abelenky
Nov 9 at 3:08
You should show the exact error messages you're getting and the command line that produced them.
– R..
Nov 9 at 2:51
You should show the exact error messages you're getting and the command line that produced them.
– R..
Nov 9 at 2:51
i edited the the post to show the error
– Doe J.
Nov 9 at 3:05
i edited the the post to show the error
– Doe J.
Nov 9 at 3:05
3
3
You are failing to compile and link in the
QueueLibrary.c
. You need to update your build process to be sure that file is handled too.– abelenky
Nov 9 at 3:08
You are failing to compile and link in the
QueueLibrary.c
. You need to update your build process to be sure that file is handled too.– abelenky
Nov 9 at 3:08
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219135%2frelocation-truncated-r-x86-64-pc32-against-undefined-symbol%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You should show the exact error messages you're getting and the command line that produced them.
– R..
Nov 9 at 2:51
i edited the the post to show the error
– Doe J.
Nov 9 at 3:05
3
You are failing to compile and link in the
QueueLibrary.c
. You need to update your build process to be sure that file is handled too.– abelenky
Nov 9 at 3:08