# Undefined reference to \_MMX\_~ in libSDL.so

**URL:** <https://discourse.libsdl.org/t/undefined-reference-to--mmx--in-libsdl-so/10826>\
**Category:** SDL Development\
**Created:** [May 24, 2004, 8:17pm UTC](https://discourse.libsdl.org/t/undefined-reference-to--mmx--in-libsdl-so/10826 "2004-05-24T20:17:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![2boxers](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/2/dc4da7/32.png) [@2boxers](https://discourse.libsdl.org/u/2boxers)\
**Post date:** [May 24, 2004, 8:17pm UTC](https://discourse.libsdl.org/t/undefined-reference-to--mmx--in-libsdl-so/10826/1 "2004-05-24T20:17:32Z")

</div>

Greetings,

When I try to compile test programs I get the following list of undefined  
references:  
/usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to  
`_MMX_UbluRGB' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to`\_MMX\_Vred5x5’  
/usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to  
`_MMX_VgrnRGB' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to`\_MMX\_grn565’  
/usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to  
`_MMX_VredRGB' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to`\_MMX\_Vgrn565’  
/usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_FF00w' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to`\_MMX\_Ugrn565’  
/usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_Ycoeff' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to`\_MMX\_UgrnRGB’  
/usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_00FFw' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to`\_MMX\_red565’  
/usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_0080w' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to`\_MMX\_Ublu5x5’  
collect2: ld returned 1 exit status

What might be the cause of this?  
Best regards,  
ChasW

Some background:  
I am attempting to build SDL-1.2.7 for linux.  
I am running kernel-2.6.6 and gcc-3.4.0.

In order to get sdl to successfully build with gcc-3.4.0, I had to apply  
this patch…  
Submitted By: Jeremy Utley (jeremy at [linuxfromscratch.org](http://linuxfromscratch.org))  
Initial Package Version: 1.2.7  
Upstream Status: Not submitted  
Origin: jbit from LFS-IRC’s custom hacks  
Description: fixes inline asm code for gcc 3.4 compilation

## diff -aur SDL-1.2.7/src/audio/SDL\_mixer\_MMX.c SDL-1.2.7-new/src/audio/SDL\_mixer\_MMX.c — SDL-1.2.7/src/audio/SDL\_mixer\_MMX.c 2002-11-08 22:13:28.000000000 -0800 +++ SDL-1.2.7-new/src/audio/SDL\_mixer\_MMX.c 2004-04-11 06:27:06.765672328 -0700 @@ -14,7 +14,7 @@ void SDL\_MixAudio\_MMX\_S16(char\* dst,char\* src,unsigned int size,int volume) { **asm**  **volatile** (Date: 2004-04-11

+" pushl %%ebx\n" //XXX: Jbit hack  
" movl %0,%%edi\n" // edi = dst  
" movl %1,%%esi\n" // esi = src  
" movl %3,%%eax\n" // eax = volume  
@@ -102,10 +102,11 @@  
" emms\n"  
".endS16:\n"  
+" popl %%ebx\n" //XXX: Jbit hack  
:  
: “m” (dst), “m”(src),“m”(size),  
“m”(volume)

- : “eax”,“ebx”, “esi”, “edi”,“memory”

- : “eax”,“esi”, “edi”,“memory”  
);  
}  
@@ -119,6 +120,7 @@  
{  
**asm**  **volatile** (  
+" pushl %%ebx\n" //XXX: Jbit hack  
" movl %0,%%edi\n" // edi = dst  
" movl %1,%%esi\n" // esi = src  
" movl %3,%%eax\n" // eax = volume  
@@ -175,10 +177,11 @@  
".endS8:\n"  
" emms\n"  
+" popl %%ebx\n" //XXX: Jbit hack  
:  
: “m” (dst), “m”(src),“m”(size),  
“m”(volume)

- : “eax”,“ebx”, “esi”, “edi”,“memory”

- : “eax”,“esi”, “edi”,“memory”  
);  
}  
#endif  
diff -aur SDL-1.2.7/src/cpuinfo/SDL\_cpuinfo.c  
SDL-1.2.7-new/src/cpuinfo/SDL\_cpuinfo.c  
— SDL-1.2.7/src/cpuinfo/SDL\_cpuinfo.c 2004-02-10 07:31:35.000000000 -0800  
+++ SDL-1.2.7-new/src/cpuinfo/SDL\_cpuinfo.c 2004-04-11  
06:27:06.761672450 -0700  
@@ -105,6 +105,7 @@  
int features = 0;  
#if defined( **GNUC** ) && defined(i386)  
**asm** (  
+" pushl %%ebx\n" //XXX: Jbit Hack  
" movl %%ebx,%%edi\n"  
" xorl %%eax,%%eax # Set up for CPUID instruction \n"  
" cpuid # Get and save vendor ID \n"  
@@ -116,9 +117,10 @@  
" movl %%edx,%0 \n"  
“1: \n”  
" movl %%edi,%%ebx\n"  
+" popl %%ebx\n" //XXX: Jbit Hack  
: “=m” (features)  
:

- : “%eax”, “%ebx”, “%ecx”, “%edx”, “%edi”

- : “%eax”, “%ecx”, “%edx”, “%edi”  
);  
#elif defined(\_MSC\_VER)  
\_\_asm {  
@@ -141,6 +143,7 @@  
int features = 0;  
#if defined( **GNUC** ) && defined(i386)  
**asm** (  
+" pushl %%ebx\n" //XXX: Jbit Hack  
" movl %%ebx,%%edi\n"  
" movl $0x80000000,%%eax # Query for extended functions \n"  
" cpuid # Get extended function limit \n"  
@@ -151,9 +154,10 @@  
" movl %%edx,%0 \n"  
“1: \n”  
" movl %%edi,%%ebx\n"  
+" popl %%ebx\n" //XXX: Jbit Hack  
: “=m” (features)  
:

- : “%eax”, “%ebx”, “%ecx”, “%edx”, “%edi”

- : “%eax”, “%ecx”, “%edx”, “%edi”  
);  
#elif defined(\_MSC\_VER)  
\_\_asm {  
diff -aur SDL-1.2.7/src/video/SDL\_yuv\_mmx.c  
SDL-1.2.7-new/src/video/SDL\_yuv\_mmx.c  
— SDL-1.2.7/src/video/SDL\_yuv\_mmx.c 2004-02-18 09:22:04.000000000 -0800  
+++ SDL-1.2.7-new/src/video/SDL\_yuv\_mmx.c 2004-04-11  
06:27:06.763672389 -0700  
@@ -238,9 +238,7 @@  
“popl %%ebx\n”  
:  
: “m” (cr), “r”(cb),“r”(lum),

- “r”(row1),“r”(cols),“r”(row2),“m”(x),“m”(y),“m”(mod)
- : “%ebx”
- );

- “r”(row1),“r”(cols),“r”(row2),“m”(x),“m”(y),“m”(mod) );  
}  
void Color565DitherYV12MMX1X( int \*colortab, Uint32 \*rgb\_2\_pix,  
@@ -413,9 +411,7 @@  
“popl %%ebx\n”  
:  
:“m” (cr), “r”(cb),“r”(lum),

- “r”(row1),“r”(cols),“r”(row2),“m”(x),“m”(y),“m”(mod)
- : “%ebx”
- );

- “r”(row1),“r”(cols),“r”(row2),“m”(x),“m”(y),“m”(mod) );  
}  
#endif /\* GCC i386 inline assembly \*/

---

<div class="post-metadata">

**Author:** ![Stephane\_Marchesin](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/a183cd/32.png) [@Stephane\_Marchesin](https://discourse.libsdl.org/u/Stephane_Marchesin)\
**Post date:** [May 24, 2004, 8:23pm UTC](https://discourse.libsdl.org/t/undefined-reference-to--mmx--in-libsdl-so/10826/2 "2004-05-24T20:23:05Z")

</div>

2boxers wrote:

> Greetings,
> 
> When I try to compile test programs I get the following list of undefined  
> references:  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to  
> `_MMX_UbluRGB' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_Vred5x5’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to  
> `_MMX_VgrnRGB' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_grn565’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to  
> `_MMX_VredRGB' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_Vgrn565’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_FF00w' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_Ugrn565’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_Ycoeff' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_UgrnRGB’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_00FFw' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_red565’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_0080w' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_Ublu5x5’  
> collect2: ld returned 1 exit status
> 
> What might be the cause of this?

Did you try SDL from cvs ? That should be fixed.

Stephane

---

<div class="post-metadata">

**Author:** ![Mike\_Frysinger](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/mike_frysinger/32/282_2.png) [@Mike\_Frysinger](https://discourse.libsdl.org/u/Mike_Frysinger)\
**Post date:** [May 25, 2004, 1:46am UTC](https://discourse.libsdl.org/t/undefined-reference-to--mmx--in-libsdl-so/10826/3 "2004-05-25T01:46:14Z")

</div>

> 2boxers wrote:
> 
> > What might be the cause of this?

gcc-3.4.0

> Did you try SDL from cvs ? That should be fixed.

yeah, cvs worked for me  
-mikeOn Monday 24 May 2004 04:23 pm, Stephane Marchesin wrote:

---

<div class="post-metadata">

**Author:** ![Stephane\_Marchesin](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/a183cd/32.png) [@Stephane\_Marchesin](https://discourse.libsdl.org/u/Stephane_Marchesin)\
**Post date:** [May 25, 2004, 6:48pm UTC](https://discourse.libsdl.org/t/undefined-reference-to--mmx--in-libsdl-so/10826/4 "2004-05-25T18:48:42Z")

</div>

2boxers wrote:

> Greetings,
> 
> When I try to compile test programs I get the following list of undefined  
> references:  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to  
> `_MMX_UbluRGB' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_Vred5x5’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to  
> `_MMX_VgrnRGB' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_grn565’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to  
> `_MMX_VredRGB' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_Vgrn565’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_FF00w' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_Ugrn565’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_Ycoeff' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_UgrnRGB’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_00FFw' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_red565’  
> /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `_MMX_0080w' /usr/local/sdl/sdl-1.2.7/lib/libSDL.so: undefined reference to `\_MMX\_Ublu5x5’  
> collect2: ld returned 1 exit status
> 
> What might be the cause of this?  
> Best regards,  
> ChasW

Dump my previous comment, cvs will probably fail too.  
Could you try the attached patch (or even better, the attached patch on  
top of the current cvs, if you can get it) ?

Stephane

-------------- next part --------------  
An embedded and charset-unspecified text was scrubbed…  
Name: patch  
URL: [http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040525/cce7d4b9/attachment.txt](http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040525/cce7d4b9/attachment.txt)
