Workaround with gcc 4.4.x for CUDA 2.3 SDK

There are several discussions about gcc 4.4.x for CUDA SDK building issues, e.g. on FC 11 I am using.

General solutions are to step back 4.3 or use compat-34. Here is another workaround way:

Please edit common/common.mk

ADD one more flag to NVCCFLAGS
–compiler-options -fno-inline

As in gcc 4.4.x, check against inline function be declared as weak. If you still meet the problem about always-inline functions like memcpy and memset, I suggest to recover common.mk, and override nvccflags -O2 with -O0 or null. This is the cheapest way to go through 4.4.x issue, cheers!

Another suggested again, maybe to Nvidia:
in Makefile, please add two lines for clean
@make -C common -f Makefile_paramgl clean
@make -C common -f Makefile_rendercheckgl clean

Finally,
make clean; make

Done, cheers. External Image

It doesn’t work for me, still reports the same error. I have added the flag, cleaned and make-d.

This is my common.mk

[highman@gpu common]$ diff common.mk common.mk.org 

126c126

< 	NVCCFLAGS   += --compiler-options -fno-strict-aliasing --compiler-options -fno-inline

---

> 	NVCCFLAGS   += --compiler-options -fno-strict-aliasing

Obviously, it will bring some differences. If no, please check your configuration. post your error informaiton.

And, be careful. un-cleaned library, so suggest to add two more lines in C/Makefile

clean: tidy $(addsuffix .ph_clean,$(PROJECTS))

		@make -C common clean

		@make -C common -f Makefile_paramgl clean

		@make -C common -f Makefile_rendercheckgl clean

Another way would be to separate the code:

1: minimal cuda code, compiled in a static or shared library with nvcc and gcc 4.3

2: 4.4/4.5 for the rest, link with (1)

I did exactly to your advice, but it still reports the error about weak declaration in simpleTemplates project. The error shows to string.h and string3.h files in /usr/include, and to common_functions.h in cuda subdirs.

Anyway, thanks for your effort.

SOLUTION for Ubuntu 9.10.

Same as for smokyboy, changing to gcc-4.3 in common.mk or adding the no-inline flag did not work. The only way was to uninstall gcc/g+±4.4, and make manually the link of /usr/bin/gcc to /usr/bin/gcc-4.3, and same for g++.

Actually, when you uninstall gcc-4.4 and do the make before creating the link of gcc/g++, the compilation fails at some point because it can’t find “gcc” (which makes sense since when you uninstall gcc-4.4, Ubuntu deletes the link /usr/bin/gcc.

But, that would not make any sense since I specified to use CC:=gcc-4.3, then I suspected somewhere else CC and CXX were being re-assigned to gcc/g++.

And the culprit seemed to be

src/simpleAtomicIntrinsics/Makefile2

At end of Makefile2 you can see
NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc
CXX := g++
CC := gcc
LINK := g++ -fPIC

and then all subsequent compilations fail because this

Then, I deleted the CXX, CC and LINK assignments in src/simpleAtomicIntrinsics/Makefile2 and did again make, but the error of “gcc: no such file or directory persisted”

"…
make -C src/simpleTextureDrv/
make[1]: Entering directory `/home/pichards/NVIDIA_GPU_Computing_SDK/C/src/simpleTextureDrv’
gcc: No such file or director
"

Then I simply decided to create manually the link /usr/bin/gcc to gcc-4.3 and theproblem was solved, I could not find exactly the rule in the Makefiles that was trying to use gcc instead of expanding $(CC)…

Then solution for Ubuntu 9.10:

Install gcc and g++ 4.3, then change manually the links gcc and g++ to the 4.3 counterparts.

Not very clean until we figure out where exactly the Makefiles are getting messy

Cheers

To be simple, you do not bother to step back gcc 4.3.* for SDK building.

Right, as indicated above, --no-inline cannot solve all the issues on some platforms as Ubuntu 9.10, then you haveto change some system-level declarations. This is not a good method at all.

Alternatively, you can simply change common.mk as below.

[highman@gpgpu C]$ diff common/common.mk common/common.mk.org 

159c159

< 	COMMONFLAGS += 

---

> 	COMMONFLAGS += -O2 

162,164c162,164

< 	CXXFLAGS	+= -fno-strict-aliasing -O2

< 	CFLAGS	  += -fno-strict-aliasing -O2

---

> 	CXXFLAGS	+= -fno-strict-aliasing

> 	CFLAGS	  += -fno-strict-aliasing

This does not influence device performance and it also applies to SDK 3.0beta, however, in 3.0beta, some other problems arise because of the software definition elegance issues…

The changes in post #7 (highman) worked for me on Ubuntu 9.10 with a HP311 (NVIDIA ION LE) with CUDA 2.3 and driver version 190.42 (NVIDIA-Linux-x86-190.42-pkg1.run).

I was able to compile and run all the examples in the SDK.

External Media

Compile problem solved:

gcc 4.3 and 4.4 did not work but 4.1 did. The gcc, g++ and gcov are but symlinks to the gcc-4.x etc, so I just deleted those and made new symlinks to the 4.1’s, and then all compiled w/o a squeak.

No doubt a config file should be used to find out what compiler version is/are available, and adjust the makefile accordingly. I use Debian-Sid 2.6.32-2.slh.3-sidux-amd64 x86_64 and NVIDIA 190.53.

All demos seem to run fine.

A config file should also be able to detect existing and missing dependencies. I guess I’m spoiled using Debian, apt-get finds all needed deps. I remember way back, External Image using rpm based stuff i always ended up with missing stuff, but here Nvidia could easily use a distribution agnostic config file. My debian repos even had some libcuda1 files.

Finally I to put

PATH=$PATH:/usr/local/cuda/bin
export PATH
LD_LIBRARY_PATH=/usr/local/cuda/lib64
export LD_LIBRARY_PATH

into my ~/.bashrc so I would not get the missing libcudart.so.2 message, again the installer/config file could have done this.

OK, I’m a newbie and I tried the instructions in the previous post about installing gcc-4.1, etc. and re-making the symlinks. I am running Kubuntu 9.10. I perform a “make clean” and then “make”. Here’s my output:

$ make

make[1]: Entering directory `/home/johnz/NVIDIA_GPU_Computing_SDK/C/common’

a - obj/release/bank_checker.cpp.o

a - obj/release/cmd_arg_reader.cpp.o

a - obj/release/cutil.cpp.o

a - obj/release/stopwatch.cpp.o

a - obj/release/stopwatch_linux.cpp.o

a - obj/release/multithreading.cpp.o

make[1]: Leaving directory `/home/johnz/NVIDIA_GPU_Computing_SDK/C/common’

make[1]: Entering directory `/home/johnz/NVIDIA_GPU_Computing_SDK/C/common’

make[1]: Leaving directory `/home/johnz/NVIDIA_GPU_Computing_SDK/C/common’

make[1]: Entering directory `/home/johnz/NVIDIA_GPU_Computing_SDK/C/common’

make[1]: Leaving directory `/home/johnz/NVIDIA_GPU_Computing_SDK/C/common’

make -C src/histogram/

make[1]: Entering directory `/home/johnz/NVIDIA_GPU_Computing_SDK/C/src/histogram’

gcc: No such file or directory

^Cmake[1]: *** [obj/release/histogram64.cu.o] Interrupt

make: *** [src/histogram/Makefile.ph_build] Interrupt

The system hanged on the “gcc: No such file or directory”. I note that the files,

/home/johnz/NVIDIA_GPU_Computing_SDK/C/src/histogram/obj/release/histogram_gold.cpp.o

/home/johnz/NVIDIA_GPU_Computing_SDK/C/src/histogram/obj/release/main.cpp.o

are created.

Please be nice to me :rolleyes: - I am not a programmer and my intent is to get the SDK to compile the samples, run the samples, then learn/work with PyCuda to develop some stock analysis programs.

Sorry if I’m reviving a dead thread, but I would like to say that this method worked for me on Ubuntu 9.10 using CUDA 2.3 and the 190.53 drivers.

I’m curious why these compile errors are coming up. Is it because of certain compiler optimizations were defaulted in gcc 4.4 which were not present in 4.3?