Linking fails

K

Klaus Pirker

Hi

I have a very simple codefragment where I wanna test the _mm_clflush
instruction.

#include <stdio.h>
#include <emmintrin.h>

int main()
{
int *i = NULL;
int a = 123;

i = &a;

printf(" i = %d\n", *i);
_mm_clflush(&i);

return (0);
}

However, when I try to compile & link I get the following error message:

/tmp/ccKOPY3f.o(.text+0x4d): In function `main':
: undefined reference to `_mm_clflush'
collect2: ld returned 1 exit status

Could it be that the instruction is not supported on my Pentium 4 processor?

thanks
 
J

Joachim Schmitz

pete said:
It means that _mm_clflush is neither
declared in <stdio.h>, nor in <emmintrin.h>.
No it does not. It means that _mm_cflush is not part of any library that got
linked with your program.
Other than that just read the 1st reply you got on a similar question in
de.comp.lang.c which stated that this is off topic and beond the scope of
standard C and that you'd need to consult the documentation of your
implementation.

Bye, Jojo
 
M

Martin Ambuhl

pete said:
Klaus Pirker wrote:
It means that _mm_clflush is neither
declared in <stdio.h>, nor in <emmintrin.h>.


Wrong. Wrong. Wild guesses again lead to silly answers.
If the identifier were not declared, that would lead to a compilation
diagnostic. The _linking_ diagnostic means that the function could not
be found in the files being linked, including any libraries used. This
usually signals failure to link a library required for that function.
 
H

Harald van Dijk

Wrong. Wrong. Wild guesses again lead to silly answers. If the
identifier were not declared, that would lead to a compilation
diagnostic.

No, it would not, if the compiler does not issue diagnostics for implicit
function declarations. C90 compilers aren't required to, and plenty do not
by default.
The _linking_ diagnostic means that the function could not
be found in the files being linked, including any libraries used. This
usually signals failure to link a library required for that function.

In this case, I'd guess _mm_clflush is supposed to be defined as a macro
or an inline function in some header. No library would be required, but
you do need to include the correct header, because that is the only place
it would be defined.
 
C

CBFalconer

Klaus said:
I have a very simple codefragment where I wanna test the
_mm_clflush instruction.

#include <stdio.h>
#include <emmintrin.h>

Standard C does not have any <emmintrin.h> include file, nor any
such function as _mm_clflush. Try a newsgroup that deals with your
peculiar installation.
 
C

Chris Dollin

Klaus said:
I have a very simple codefragment where I wanna test the _mm_clflush
instruction.

Ignoring that, I ask:
int main()
{
int *i = NULL;
int a = 123;

i = &a;

Why not:

int a = 123;
int *i = &a;

Shorter and more obvious and without an irrelevant initialisation.

(I do /not/ recommend `int a = 123, *i = &a;`, however.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top