This is the mail archive of the
mailing list for the GCC project.
Re: linking qsort with gfortran
- From: Tim Prince <n8tm at aol dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 22 Dec 2012 07:15:08 -0500
- Subject: Re: linking qsort with gfortran
- References: <CE7946E5-B513-4380-B3C6-5BA2ED002FC9@mac.com>
- Reply-to: tprince at computer dot org
On 12/21/2012 7:58 PM, email@example.com wrote:
First, apologies if this question has been answered elsewhere or I am doing something really stupid. I have searched for several hours for a solution to my problem with no success.If there is no Fortran wrapper for qsort in your library you should be
able to call it via iso_c_binding. qsort isn't in a gcc library,
usually it's glibc, although I don't know mac specifics.
I am trying to do a GCC build of a mix of C and Fortran source that has been successfully compiled for many years with both the PGI and Intel compilers. I have one Fortran routine that calls "qsort", a sorting routine provided in most libraries. I know it is provided in the GCC libraries. However, because the call is from Fortran code, it will properly link with the library and I get this error:
Undefined symbols for architecture x86_64:
"_qsort_", referenced from:
I understand that the trailing underscore is the problem, but I cannot use the "no-underscoring" compiler flags because the code also links to other libraries that do provide the underscore which then breaks everything else. I am using gfortran to do the linking though I get the same error with gcc. I am using version 4.8 currently but get the same error with 4.7. Everything is on OS X, 10.7.
Any help would be greatly appreciated. Thank you.