# julia set example - unable to run already searched other posts to check if the solution already exis

Dear Experts,

I have just started exploring CUDA. From the book “CUDA by Example (Sanders & Kandrot)” - I tried to compile and run the Julia set example. However, could not do so.
I am using 3.2 kit on Windows 7 (64 bit). Visual studio 2008. Have two GTX460 cards connected with SLI.
As you probably know, the julia set example code is:

========================================

• NVIDIA Corporation and its licensors retain all intellectual property and
• proprietary rights in and to this software and related documentation.
• Any use, reproduction, disclosure, or distribution of this software
• and related documentation without an express license agreement from
• NVIDIA Corporation is strictly prohibited.
• Please refer to the applicable NVIDIA end user license agreement (EULA)
• associated with this source code for terms and conditions that govern
• your use of this NVIDIA software.

*/
#include “book.h”
#include “cpu_bitmap.h”

#define DIM 1000

struct cuComplex {
float r;
float i;
cuComplex( float a, float b ) : r(a), i(b) {}
device float magnitude2( void ) {
return r * r + i * i;
}
device cuComplex operator*(const cuComplex& a) {
return cuComplex(ra.r - ia.i, ia.r + ra.i);
}
device cuComplex operator+(const cuComplex& a) {
return cuComplex(r+a.r, i+a.i);
}
};

device int julia( int x, int y ) {
const float scale = 1.5;
float jx = scale * (float)(DIM/2 - x)/(DIM/2);
float jy = scale * (float)(DIM/2 - y)/(DIM/2);

``````cuComplex c(-0.8, 0.156);
cuComplex a(jx, jy);

int i = 0;
for (i=0; i<200; i++) {
a = a * a + c;
if (a.magnitude2() > 1000)
return 0;
}

return 1;
``````

}

global void kernel( unsigned char *ptr ) {
// map from blockIdx to pixel position
int x = blockIdx.x;
int y = blockIdx.y;
int offset = x + y * gridDim.x;

``````// now calculate the value at that position
int juliaValue = julia( x, y );
ptr[offset*4 + 0] = 255 * juliaValue;
ptr[offset*4 + 1] = 0;
ptr[offset*4 + 2] = 0;
ptr[offset*4 + 3] = 255;
``````

}

// globals needed by the update routine
struct DataBlock {
unsigned char *dev_bitmap;
};

int main( void ) {
DataBlock data;
CPUBitmap bitmap( DIM, DIM, &data );
unsigned char *dev_bitmap;

``````HANDLE_ERROR( cudaMalloc( (void**)&dev_bitmap, bitmap.image_size() ) );
data.dev_bitmap = dev_bitmap;

dim3    grid(DIM,DIM);
kernel<<<grid,1>>>( dev_bitmap );

HANDLE_ERROR( cudaMemcpy( bitmap.get_ptr(), dev_bitmap,
bitmap.image_size(),
cudaMemcpyDeviceToHost ) );

HANDLE_ERROR( cudaFree( dev_bitmap ) );

bitmap.display_and_exit();
``````

}

========================================

Press F5 (Debug mode), and following lines are displayed in the output window.

‘firstCuda.exe’: Loaded ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\cudart64_32_16.dll’, Binary was not built with debug information.
The program ‘[4624] firstCuda.exe: Native’ has exited with code -1073741701 (0xc000007b).

Press F5 (Release mode), and following lines are displayed in the output window.

1>------ Build started: Project: firstCuda, Configuration: Release x64 ------
1>Compiling with CUDA Build Rule…
1>“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe” -arch sm_10 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin” -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -maxrregcount=32 --compile -o “x64\Release\sample.cu.obj” “c:\Suresh_Cuda\firstCuda\firstCuda\sample.cu”
1>sample.cu
1>tmpxft_00000678_00000000-3_sample.cudafe1.gpu
1>tmpxft_00000678_00000000-8_sample.cudafe2.gpu
1>sample.cu
1>tmpxft_00000678_00000000-3_sample.cudafe1.cpp
1>tmpxft_00000678_00000000-14_sample.ii
1>sample.cu.obj : error LNK2001: unresolved external symbol cudaGetErrorString
1>sample.cu.obj : error LNK2001: unresolved external symbol __cudaUnregisterFatBinary
1>sample.cu.obj : error LNK2001: unresolved external symbol cudaLaunch
1>sample.cu.obj : error LNK2001: unresolved external symbol cudaSetupArgument
1>sample.cu.obj : error LNK2001: unresolved external symbol __cudaRegisterFunction
1>sample.cu.obj : error LNK2001: unresolved external symbol __cudaRegisterFatBinary
1>sample.cu.obj : error LNK2001: unresolved external symbol cudaFree
1>sample.cu.obj : error LNK2001: unresolved external symbol cudaMemcpy
1>sample.cu.obj : error LNK2001: unresolved external symbol cudaConfigureCall
1>sample.cu.obj : error LNK2001: unresolved external symbol cudaMalloc
1>C:\Suresh_Cuda\firstCuda\x64\Release\firstCuda.exe : fatal error LNK1120: 10 unresolved externals
1>Build log was saved at “file://c:\Suresh_Cuda\firstCuda\firstCuda\x64\Release\BuildLog.htm”
1>firstCuda - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Suggestions towards resolving the issue in debug mode would be appreciated.
Thank you.

Hi!

As the experts do not reply you, i’ll do it

Your problem is in the linker. If you are using Visual Studio, you have to include (‘linking’) the libraries that you need.
In your case, i believe that is the cuda runtime library.

If the release version runs, go to the project properties (with the release configuration selected) and copy the linker section values to the debug version.

Good luck!