Solutions to GCC C Problems

Linker error undefined reference to `fprint'

Did you mean to write fprintf(..) in your source code?

Linker error undefined reference to `set_fl'

C function set_fl() is given on page 66 of W. Richard Stevens "Advances Programming in the UNIX Environment".

aio_return gives old value. Does not report end of file

Also applies to other low level file read operations.

Did you forget to move the buffer pointer on? See help pages

  man aio_read

Work around

  ioList[j].aiocbp->aio_offset += nbytes;

Solutions to C Program Problems

aio_copy.c fails at run time

aio_copy may fail

Work around

Initialise all of a_write by inserting the line
	memset(&a_write, 0, sizeof(aiocb_t));//WBL 8 Mar 2016 
See also discussion at

This fix is also available as a Github fork.

aio_suspend() Flakey, non-suspend gives tight loop to gobble CPU

Sometimes aio_suspend() does not suspend. The help pages (man aio_suspend 2012-05-08) suggest (even if a NULL timeout is given) that aio_suspend() should wait for an asynchronous I/O request to complete, unless one has already finished. It appears sometimes this does not happen. Instead aio_suspend() returns immediately, without waiting. Checking AIO status shows none have completed.

Compiling with gcc -O2 may give code with gives a segmentation error inside aio_suspend()

Work around

It may be mbuffer will do what you want.

error: inlining failed in call to always_inline '_mm512_min_epi32': target specific option mismatch _mm512_min_epi32 (__m512i __A, __m512i __B)

Work around

Add -mavx512f to gcc command line (version 4.9 onwards needed)

undefined reference to '_mm512_reduce_add_epi32'

It appears _mm512_reduce_add_epi32 does not exist in normal CPUs. Instead it is only in the Intel Many Integrated Core Architecture (MIC) (e.g. the Xeon Phi).

Work around


Linker error undefined reference to `clock_gettime'

Some systems give errors like
tick.o: In function `getTickCount':
tick.c:(.text+0x3d): undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
make: *** [test_md] Error 1
This appears to be because clock_gettime() is in the librt library, which your program may need to be linked to.

Work around

Add -lrt to CC link command

C++ Linker error undefined reference to `main'

In GCC C++
/lib/../lib64/crt1.o: in function `_start':
(.text+0x20): undefined reference to `main'

Work around

Did you nest main() inside a namespace?
Perhaps try using namespace instead?

W.B.Langdon Back 7 March 2016 (last update 14 Sep 2022)