Compilation Error Compiles in 64 bit, but not 32 bit

I am trying to compile a 64 program in 32 bit. It compiles in 64 bit, but gives a few warnings.

The output is:

errol@fermi:~/Desktop/desktop_cleanup/WEGtest$ ./compile5.sh
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.3.3/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.3.3/libstdc++.a when searchi

ng for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.3.3/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.3.3/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.3.3/…/…/…/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/libstdc++.so when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status

I am using it on an Ubuntu 9.04 system. It compiles in 64 bit and does not in 32 bit. The 64 bit compile gives a few warnings, but that is all. I am using Ubuntu 9.04 and it is a 64 bit version on a 64 bit computer. I believe it compiles just fine as a 32 bit gcc only system. it only fails when I include 32 bit CUDA elements.

What is going on here and how can i get it to compile?

I posted a similar question last week on Ubuntu Forum and got suggestions, but none worked.

What library has - -lstdc++ and what directory is it located.

The complier seems to be skipping all libraries that might have -lstdc++. It should not be a surprise that it cannot find .-lstdc++.

Newport_j

Newport_j

libstdc++ is a library. The linker is telling you it cannot find a 32 bit version of the c++ standard library (libstc++) to link against , probably because one is not installed. If you want to compile for 32 bit targets on a 64 bit machine, you need to have the 32 bit versions of those libraries installed. On 64 bit Ubuntu 9.04, the 32bit compatible C++ standard library is provided by the lib32stdc++6 package. Install it and the problem should go away.

I have compiled in 32 and 64 bit on my 64 bit 9.04 with no problem. I simply change the option -m32 or -m64 depending on whether I wanted 32 or 64, respectively. I compiled some 32 bit programs this morning. I know you said something about 32 bit software not running on 64 bit. I have run 32 bit this morning. I believe you told me several months ago how.

Newport_j

PS. In what directory does lib32stdc++6 reside?

So why all the questions then?

If you have not realized it by now (or read the nvcc manual), nvcc uses the C++ compiler to compiler CUDA C code by default. If you want to cross compile using nvcc, you must have a functional C++ (not C) build system for the architecture you are compiling for. Clearly you don’t.

I said no such thing. I warned you that CUDA device code compiled for 32 bit or 64 bit host targets were not interchangeable (despite running on the same card) because the pointer size compiled into the GPU code changes from architecture to architecture. Although this will mean nothing to you, on the device sizeof(void *) = 8 when the host is 64 bits, while sizeof(void *4) =4 if the host is 32 bit. This is despite the fact that current GPUs are 32 bit.

If you cross compile correctly, it will work OK on the target architecture, but the 32 bit program cannot run on the 64 bit host or vice versa, even with the correct libraries. This is not the same as for host code.

Please understand that what you said sounds reasonable. I installed libstdc++6 this morning.

My LD_LIBRARY_PATH is:/usr/local/cuda/lib:

Maybe i , the compiler, is not finding it.

I used the synaptic package manager to install lib32stdc++6 package.on the host computer. I am using it remotely. It should help.

I can only guess at two things. The package was not installed or not installed correctly and/or it was installed and the compiler cannot find it. Hence, the questions as to where the libstdc++6 package is residing.

Newport_j

LD_LIBRARY_PATH has no bearing on this.

You should find the 32 bit versions of the C++ libraries in

/usr/lib32/libstdc++.so.6

/usr/lib32/libstdc++.so.6.0.10

on a correctly installed Ubuntu 9.04 host.

FIN.

Below is the content of my /usr/local/cuda/lib/ directory.

libcublasemu.so libcublasemu.so.2.3 libcublas.so.2 libcudart.so libcudart.so.2.3 libcufftemu.so.2 libcufft.so libcufft.so.2.3

libcublasemu.so.2 libcublas.so libcublas.so.2.3 libcudart.so.2 libcufftemu.so libcufftemu.so.2.3 libcufft.so.2

There is no lib32stdc++6 library in there. So I am assuming the the synaptic package manager must not have installed libstdc++6. I do not know what to think now. I cannot find the library file and the synaptic package manager says it is installed. I assume if I cannot locate on the disk, it is not installed on the disk.

I do not know what to try now.

Newport_j

It shouldn’t be - it has nothing to do with CUDA. It is a 32 bit version of the standard library for the C++ compiler. See my earlier post about where to find them.

here is my /usr/lib32/ directory

ls -al libstdc*

lrwxrwxrwx 1 root root 19 2010-04-12 09:41 libstdc++.so.6 → libstdc++.so.6.0.10

-rw-r–r-- 1 root root 950424 2009-03-16 21:03 libstdc++.so.6.0.10

I do not know if this is correct. Both files are represented, but only libstdc++.so.6.0.10 is on the disk. The other file is connected by a softlink.

I assume that /usr/lib32/ must be in the file path?

Newport_j

It is correct. Install g+±multilib if you have not already done so (I am guessing you haven’t)

I installed 4.2.4-1 ubuntu4 which also installed

4:4.2.3-1 ubuntu5 (it was checked when I checked the first).

I have yet to try and compile. Anything else to install? Anything else to check?

Should I change or add a PATH in my echo $PATH statement?

Newport_j