use
KurtCode:return ((sched_record *) p)->course - ((sched_record *) q)->course;
use
KurtCode:return ((sched_record *) p)->course - ((sched_record *) q)->course;
Sounds like you have setup a Windows Application project but you have actually written a console application. Also the file sortFunction ( is that the actual name ? it should have a .c extension) has to be added to the project.
But then I don't know anything about code::blocks
Kurt
Last edited by ZuK; 04-19-2012 at 05:08 PM.
Actually I just decided to set up a window application project and made new files with the exact same coded as above, with of course the correction to the sortFunction. Now I get a
I checked the spelling, and I have it defined in my .h file. Wish I can figure this one out. It is pointing to line 26 of my main.c file. I pretty sure this is the way to define the parameters of the qsort function.Code:undefined reference to 'sortFunction'
Code:qsort(data, MAX_RECORD, sizeof(sched_record), sortFunction);
Interesting, I just tried it on our unix system at school and works perfectly fine.
That is a linker error. Verify the spelling and case of the function.
Make sure you added the C source file containing sortFunction to the CB Project.
Verify that the files containing the code is really being compiled.
Verify that the right files are being linked in the right order.
Turning on Full Compiler Logging should help verify the above items
FAQ-Compiling (errors) - CodeBlocks
Tim S.
Last edited by stahta01; 04-19-2012 at 05:35 PM.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
Here is the compile log:
Maybe someone can figure out what the heck is going on.Code:mingw32-gcc.exe -Wall -g -c "C:\Users\Clint Sharp\Documents\C Files\Server1\main.c" -o obj\Debug\main.o mingw32-g++.exe -o bin\Debug\Server1.exe obj\Debug\main.o obj\Debug\main.o: In function `main': C:/Users/Clint Sharp/Documents/C Files/Server1/main.c:26: undefined reference to `sortFunction' collect2: ld returned 1 exit status Process terminated with status 1 (0 minutes, 0 seconds) 1 errors, 0 warnings