Saturday, June 20, 2009

Error "identifier "__builtin_va_arg_pack" is undefined" when compiling CUDA

For some installations of CUDA on Ubuntu 8.10 and earlier one will get the error:
/usr/include/bits/stdio2.h(35): error: identifier "__builtin_va_arg_pack" is undefined

/usr/include/bits/stdio2.h(66): error: identifier "__builtin_va_arg_pack" is undefined

/usr/include/bits/stdio2.h(99): error: identifier "__builtin_va_arg_pack" is undefined

/usr/include/bits/stdio2.h(105): error: identifier "__builtin_va_arg_pack" is undefined

/usr/include/bits/stdio2.h(159): error: identifier "__builtin_va_arg_pack" is undefined

/usr/include/bits/stdio2.h(167): error: identifier "__builtin_va_arg_pack" is undefined

/usr/include/bits/stdio2.h(174): error: identifier "__builtin_va_arg_pack" is undefined

/usr/include/bits/stdio2.h(182): error: identifier "__builtin_va_arg_pack" is undefined


This apparently a problem with GCC 4.3. There seems to be several ways to fix this:


METHOD 1:
Upgrade to Ubuntu 9.04 Jaunty or newer. This should fix the problem.


METHOD 2:
add the following after line 28 of /usr/include/bits/stdio2.h:
int __builtin_va_arg_pack();

This should remove the above errors, but a new one might appear:
could not find -lXmu

To fix this, install libxmu-dev package:
sudo apt-get install libxmu-dev


METHOD 3:
Remove the -O3 flag from the COMMONFLAGS section of NVIDA_CUDA_SDK/common/common.mk file and do not use the flag when compiling other code either.

However, this will disable optimization which can make CPU code much slower.


METHOD 4:
Downgrade to GCC 4.2 or 4.1:
sudo apt-get install gcc-4.2
sudo apt-get install g++-4.2


After installation:
sudo rm -d /usr/bin/gcc
sudo ln -s /usr/bin/gcc-4.2 /usr/bin/gcc


This way your system will keep the gcc-4.3 but use by default gcc-4.2.

If you need to go back to 4.3 :
sudo rm -d /usr/bin/gcc
sudo ln -s /usr/bin/gcc-4.3 /usr/bin/gcc




Solution source: http://progjournal.blogspot.com/2008/05/install-cuda-on-ubuntu-710.html

No comments:

Post a Comment