Undefined reference errors + stdio.h errors

Hello, I am attempting to program a Wii remote using the Native C++ Wiimote library by gl.tter, http://www.wiiyourself.gl.tter.org/

When I first went to compile my program, I received numerous errors about undefined functions, all of which were remedied by #include-ing windows.h and stdio.h at the beginning of the wiimote library. However, when I attempt to compile my program now, I receive a bunch of errors about undefined references

undefined reference to '__imp_time_BeginPeriod'
undefined reference to '__imp_timeEndPeriod'
undefined reference to '__imp_HidD_GetHidGuid'
undefined reference to '__imp_SetupDiGetClass_DevsA'
undefined reference to '__imp_SetupDiGetDeviceInterfaceDetailA'
undefined reference to '__imp_HidD_GetAttributes'
undefined reference to '__imp_timeGetTime'
undefined reference to '__imp_SetupDiEnumDeviceIntefaces'
undefined reference to '__imp_SetupDiDestroyDeviceInfoList'
[Error] ld returned 1 exit status
recipe for target "sandbox.exe" failed

All of these errors are occuring in the object file for my program.
I am using Dev-C++ with the MingW compiler

Thank you.

Last edited on
Seems like you aren't linking to the library files correctly.

Looking up those functions on google and looking at the readme that comes with the source code it looks like you need these.

if you're not using VC you need to link with these libraries:
setupapi.lib
winmm.lib
hid.lib (from the DDK)


I don't use Dev-C++ or MingW but looking up how to add library files shouldn't be that hard.
Ok, I linked those files and did everything in the Readme, but i got more errors, so I gave up on Dev-C++ and tried Visual C++ 2008. I added the *WDK*\inc\api to the includes and *WDK*\lib\win7\i386 as per the Readme. Now I get a host of errors in the stdio.h.
1>stdafx.cpp
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(189) : error C2144: syntax error : 'int' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(189) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(189) : error C2065: '_Inout_' : undeclared identifier
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(189) : error C2146: syntax error : missing ')' before identifier 'FILE'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(189) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(189) : error C2491: '_filbuf' : definition of dllimport data not allowed
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(189) : error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(190) : error C2065: '_In_' : undeclared identifier
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(190) : error C2144: syntax error : 'int' should be preceded by ')'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(190) : error C2448: '_flsbuf' : function-style initializer appears to be a function definition
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(190) : error C2146: syntax error : missing ';' before identifier 'FILE'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(190) : error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(195) : error C2144: syntax error : 'int' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(195) : error C2143: syntax error : missing ';' before '*'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(195) : error C2065: '_In_z_' : undeclared identifier
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(195) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(195) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(195) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(195) : error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(198) : error C2065: '_Inout_' : undeclared identifier
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(198) : error C2146: syntax error : missing ')' before identifier 'FILE'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(198) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(198) : error C2182: 'clearerr' : illegal use of type 'void'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(198) : error C2491: 'clearerr' : definition of dllimport data not allowed
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(198) : error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(200) : error C2065: '_Inout_' : undeclared identifier
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(200) : error C2146: syntax error : missing ')' before identifier 'FILE'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(200) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(200) : error C2491: 'clearerr_s' : definition of dllimport data not allowed
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(200) : error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(202) : error C2065: '_Inout_' : undeclared identifier
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(202) : error C2146: syntax error : missing ')' before identifier 'FILE'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(202) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(202) : error C2491: 'fclose' : definition of dllimport data not allowed
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(202) : error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(208) : error C2144: syntax error : 'int' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(208) : error C2143: syntax error : missing ';' before '*'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(208) : error C2065: '_In_' : undeclared identifier
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(208) : error C2144: syntax error : 'int' should be preceded by ')'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(208) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(208) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(208) : error C2059: syntax error : ')'
...and a lot more errors (there's a limitation on the size of the post)

Any idea how this is happening?


Last edited on
Topic archived. No new replies allowed.