Trouble compiling nHD source : undefined variable

Hello, I’ve been attempting to compile a CUDA project called nHD available here: http://code.google.com/p/astro-attic/wiki/NHDIntroduction

I had trouble getting their makefiles to work, so I created visual studio projects for the source. I’m currently trying to compile the executable gpu_manual.

This project requires the following files:

godunov/gpu_muscl_godunov_solver.h

common/thrust_vector.h

riemann_solver/common.h

riemann_solver/gpu_common.h

riemann_solver/gpu_toro.inl

godunov/gpu_muscl_godunov_solver.cu

math/mersenne.h

math/mersenne.cpp

math/vector.h

riemann_solver/matter.h

riemann_solver/matter.cpp

riemann_solver/solver_toro.h 

riemann_solver/solver_toro.cpp 

godunov/fluid_solver.h

godunov/fluid_visualizer.h

godunov/fluid_solver.cpp

godunov/fluid_visualizer.cpp

godunov/gpu_manual.cu

riemann_solver/riemann_solver.h

It also uses the following libraries:

googletest http://code.google.com/p/googletest/

thrust http://code.google.com/p/thrust/

I’m getting the following error when compiling gpu_manual.cu

1>gpu_manual : warning PRJ0042 : The 'Outputs' property for the custom build step for file 'thrust_vector.h' is not set. The custom build step will be skipped.

1>Performing Custom Build Step

1>The custom build tool has been skipped.

1>Compiling with CUDA Build Rule...

1>"C:\CUDA\bin\nvcc.exe"	-arch sm_12 -ccbin "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin"	-Xcompiler "/EHsc /W3 /nologo /O2 /Zi   /MT  " -I""C:\CUDA\include"" -I"./" -I"C:/thrust-v1.1.0/" -I"../../../../All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/inc" -maxrregcount=32  --compile -o "Release\gpu_manual.cu.obj" "c:\Documents and Settings\Decker\Desktop\nhd-0.1\nhd-0.1\godunov\gpu_manual.cu" 

1>gpu_manual.cu

1>tmpxft_0000058c_00000000-3_gpu_manual.cudafe1.gpu

1>c:\documents and settings\decker\desktop\nhd-0.1\nhd-0.1\godunov\../riemann_solver/gpu_common.h(11): error: identifier "_ZN3gpu6kGammaE" is undefined

1>1 error detected in the compilation of "C:\DOCUME~1\Decker\LOCALS~1\Temp/tmpxft_0000058c_00000000-7_gpu_manual.cpp2.i".

1>Build log was saved at "file://c:\Documents and Settings\Decker\Desktop\nhd-0.1\gpu_manual2\Release\BuildLog.htm"

1>gpu_manual - 1 error(s), 1 warning(s)

gpu_manual differs from the default CUDA Build rules by the follow attributes:

Include=""$(CUDA_INC_PATH)";./;C:/thrust-v1.1.0/;…/…/…/…/All Users/Application Data/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/inc"

Arch=“12”

AddedDependencies=“gpu_muscl_godunov_solver.h;…/riemann_solver/gpu_common.h;…/riemann_solver/solver_toro.h;fluid_visualizer.h”

The missing identifier here seems to be ‘kGamma’, which is in the gpu_common.h file:

#pragma once

#include "common.h"

namespace gpu{

const Real kGamma = 1.4;

const Real kTolerance = 1e-6;

__device__ Real soundspeed (Real density, Real pressure) {

  return sqrtf(kGamma * pressure / density);

}

} // namespace gpu

The error occurs on the return statement of soundspeed, but kGamma is defined above and this should be valid code. Any ideas what I’m missing?

Update: If I remove the use of kGamma from soundspeed, gpu_manual.cu compiles successfully. Also, when I attempt to compile gpu_muscl_godunov_solver.cu, I also get undefined identifier errors for ‘kGamma,’ as well as for ‘kTolerance’ and globals ‘kDx’, ‘kDy’, and ‘kDz’ defined in gpu_muscl_godunov_solver.h. I don’t understand why these globals are being seen as undefined, or why the show up as their generated variable names instead of their human-readable names.