Hi Martin,

The problem appears to be due to some difference between the your header files and those distributed with the CUDA library.  Below I have shown the output of various tests: (i) object code compiled using the header files provided by Martin and also CUDA; (ii) using C code compared to C++; and (iii) contents of library provided by Martin and also CUDA. If I compile and link using your header file and library, the function names are mangled in both my object code and the glut library. In this case everything works i.e the code links and can be executed. Not sure why the CUDA supplied glut is different.

cheers
steve

test_CUDA.obj (C code using glut header files provided with CUDA)
------------
00000000 N .debug$S
00000000 i .drectve
00000000 t .text
00aa766f a @comp.id
00000001 a @feat.00
         U _glutInit
00000000 T _my_function

test_CUDA.cc (C++ code using glut header files provided with CUDA)
------------
00000000 N .debug$S
00000000 i .drectve
00000000 t .text
00000000 T ?my_function@@YAXHPAPAD@Z
00ab766f a @comp.id
00000001 a @feat.00
         U _glutInit

test_Martin.c (C code using glut header files provided by Martin)
-------------
00000000 N .debug$S
00000000 i .drectve
00000000 t .text
00aa766f a @comp.id
00000001 a @feat.00
         U __imp____glutInitWithExit@12
         U _exit
00000020 t _glutInit_ATEXIT_HACK@8
00000000 T _my_function

test_Martin.cc  (C++ code using glut header files provided by Martin)
--------------
00000000 N .debug$S
00000000 i .drectve
00000000 t .text
00000000 T ?my_function@@YAXHPAPAD@Z
00ab766f a @comp.id
00000001 a @feat.00
         U __imp____glutInitWithExit@12
         U _exit
00000020 t _glutInit_ATEXIT_HACK@8

CUDA freeglut.lib
-----------------
00000000 T ___glutInitWithExit@12
00000000 I __imp____glutInitWithExit@12
00000000 I __imp__glutInit@8
00000000 T _glutInit@8

Martin's freeglut.lib
---------------------
00000000 T ___glutInitWithExit@12
00000000 I __imp____glutInitWithExit@12
00000000 I __imp__glutInit@8
00000000 T _glutInit@8


From: Martin Payne <lists@martinpayne.me.uk>
To: FreeGLUT developers list <freeglut-developer@lists.sourceforge.net>
Sent: Friday, 27 April 2012 4:23 PM
Subject: Re: [Freeglut-developer] cannot link freeglut.lib using cygwin

Hi Steve,

Assuming you are using version 2.8.0, it was built and tested on Visual Studio 2010, so you shouldn't have any problems getting it compiled and linked. Is the problem specific to the project below, or does it happen on even the simplest of GLUT applications? Which freeglut header file are you #include-ing? Can you include the full command line for your compilation and link steps?

Regards,
Martin

On 26/04/2012 20:37, Stephen Jeffrey wrote:
Hi Dee,

I didn't compile the freeglut library - I am using pre-compiled versions. I have tried both the freeglut.lib provided with CUDA and also Martin Payne's version (using the link on your web page): http://www.transmissionzero.co.uk/software/freeglut-devel/. Both of these precompiled versions have mangled names.

Isn't it strange that in my object code the GLUT functions are not mangled, but other functions are? Is there something wrong with my header files? 

cheers
steve


From: Diederick C. Niehorster <dcnieho@gmail.com>
To: Stephen Jeffrey <stephen_j_jeffrey@yahoo.com.au>; FreeGLUT developers list <freeglut-developer@lists.sourceforge.net>
Sent: Thursday, 26 April 2012 10:16 PM
Subject: Re: [Freeglut-developer] cannot link freeglut.lib using cygwin

well, the glut function names should not be mangled in the lib. That
what's the .def file is for. Are you passing that to the linker when
creating the lib?

Best,
Dee

On 26/04/2012, Stephen Jeffrey <stephen_j_jeffrey@yahoo.com.au> wrote:
> Hi
>
> I am getting an error linking freeglut.lib when using cl.exe (VS 2010) and
> cygwin on Windows 7:
>
> error LNK2019: unresolved external symbol _glutCreateWindow referenced in
> function "void __cdecl my_function()....
>
> My application requires both GLUT and CUDA. I can link with the CUDA library
> because CUDA function names are mangled in both my object code and the CUDA
> library.
> However, I cannot link with the GLUT library because the names are mangled
> in the library, but not in my object code:
>
> In my object code:
> U _cudaThreadExit@0
> U _glutInitWindowSize
>
> In cudart.lib:
> 00000000 T _cudaThreadExit@0
>
> In freeglut.lib:
> 00000000 T _glutInitWindowSize@8
>
> Does anyone know why the GLUT function names are not being mangled in my
> object code?
>
> cheers
> steve
>




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freeglut-developer

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freeglut-developer