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 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
http://stackoverflow.com/questions/21844284/aio-write-always-fails-with-error-einval
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
None.
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?
%a format sometimes includes , comma
Why does C "%a" fprintf output format contain comma?
Dunno
https://www.gnu.org/software/libc/manual/html_node/Floating_002dPoint-Conversions.html
describes how to use %a in printf().
It does not mention the output containing a comma but sometimes it does.
E.g.:
-0x1,e6175b5c28f5cp+21
Oddly printf gives -3,98206e+06
(note also use of comma rather than decimal point)
for the same double
Python3 float.fromhex() does not like this format.
-0x1,e6175b5c28f5cp+21
Traceback (most recent call last):
z = float.fromhex(y)
ValueError: invalid hexadecimal floating-point string
gawk --posix simply stops number conversion at the comma
and gives 1
Perhaps something to do with locale LC_NUMERIC?
Work around
Replace , with .
That is, replace comma with full stop.
Alternatively
map to binary and display as hexadecimal?
gcc undefined reference to `operator new[](unsigned long)'
Example
/opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld: /tmp/cc1HjaE2.o: in function `function_malloc2(int)':
test_new.cc:(.text+0x32): undefined reference to `operator new[](unsigned long)'
collect2: error: ld returned 1 exit status
Work around
Did you compile C++ code with gcc?
Use g++
W.B.Langdon
Back
7 March 2016
(last update 9 July 2024)