title: error in using open() in CUDA C
body: <p>I try to open a file in CUDA C</p>
  
  <pre><code>fd = open("stats.txt", O_CREAT)
  </code></pre>
  
  <p>The open() is supposed to run in host side, compilation passed but there was a link error.</p>
  
  <pre><code>In function `open':
  /usr/include/x86_64-linux-gnu/bits/fcntl2.h:45: undefined reference to `__open_too_many_args'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I am surprise that searching on Google didn't present anything close. Does anyone has any hints how to solve this problem? Thanks a lot!</p>
  
  <hr>
  
  <p>Yes, I actually used 0644, sorry for the typo. I simplified the program as the following and still get the link error.</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;cuda.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;fcntl.h&gt;
  int main(int argc, char ** argv) {
    int fd;
    if((fd = open("stats.txt",O_CREAT|O_RDWR, 0644)) == -1) { printf("Can't open stats.txt.\n"); }
    else printf("stats.txt opened.\n");
    return 0;
  }
  
  nvcc  -c -arch sm_20 --keep --compiler-options -fno-strict-aliasing  -I/usr/local/cuda/include/ -I../NVIDIA_GPU_Computing_SDK/C/common/inc/ -I../../libcuda -L../NVIDIA_GPU_Computing_SDK/C/lib -lcutil -DUNIX -O3 try.cu -o try
  
  try.cu(13): warning: variable "fd" was set but never used
  
  try.cu(13): warning: variable "fd" was set but never used
  
  g++  -g -c try.cu.cpp -o try.cu_o
  
  g++  -Wall -O3 try.cu_o -o try -L../libcuda -lcuda -L/home/NVIDIA_GPU_Computing_SDK/C/lib -static -static-libgcc   -L/usr/lib64 -lcutil_x86_64 -lm -lc
  
  try.cu_o: In function `open':
  /usr/include/x86_64-linux-gnu/bits/fcntl2.h:45: undefined reference to `__open_too_many_args'
  </code></pre>
  
  <p>Due to some dependency, I have to use older nvcc</p>
  
  <pre><code>nvcc: NVIDIA (R) Cuda compiler driver
  Copyright (c) 2005-2010 NVIDIA Corporation
  Built on Wed_Nov__3_16:16:57_PDT_2010
  Cuda compilation tools, release 3.2, V0.2.1221
  </code></pre>
  
  <p>g++ is 4.6.3. Thanks.</p>