开发者

Waveform API linking error

I'm getting some kind of linking error with a program utilizing MS-s waveform API. The code I'm using can be found here: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4422&lngWId=3 It's the first bit of code on the page under the heading "Opening the Sound Device". I'm not getting any errors with the code, however my linker complains quite persistently. The output being the following:

d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\crt2.o:crt1.c|| undefined reference to `SetUnhandledExceptionFilter@4'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\crt2.o:crt1.c|| undefined reference to `ExitProcess@4'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\crtbegin.o:cygming-开发者_JAVA技巧crtbegin.c|| undefined reference to `GetModuleHandleA@4'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\crtbegin.o:cygming-crtbegin.c|| undefined reference to `GetProcAddress@8'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libmingw32.a(pseudo-reloc.o):pseudo-reloc.c|| undefined reference to `VirtualQuery@12'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libmingw32.a(pseudo-reloc.o):pseudo-reloc.c|| undefined reference to `VirtualProtect@16'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libmingw32.a(pseudo-reloc.o):pseudo-reloc.c|| undefined reference to `VirtualProtect@16'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\libgcc.a(cygming-shared-data.o)||In function `cmshared_get_ptr_from_atom':|
c:\crossdev\b4.4.1-tdm-1\build-sjlj\mingw32\libgcc\..\..\..\..\gcc-4.4.1\libgcc\..\gcc\config\i386\cygming-shared-data.c|91|undefined reference to `GetAtomNameA@12'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\libgcc.a(cygming-shared-data.o)||In function `_cmshared_create_or_grab':|
c:\crossdev\b4.4.1-tdm-1\build-sjlj\mingw32\libgcc\..\..\..\..\gcc-4.4.1\libgcc\..\gcc\config\i386\cygming-shared-data.c|140|undefined reference to `FindAtomA@4'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\libgcc.a(cygming-shared-data.o)||In function `cmshared_add_ptr_as_atom':|
c:\crossdev\b4.4.1-tdm-1\build-sjlj\mingw32\libgcc\..\..\..\..\gcc-4.4.1\libgcc\..\gcc\config\i386\cygming-shared-data.c|118|undefined reference to `AddAtomA@4'|
||=== Build finished: 10 errors, 0 warnings ===|

I can paste the build log here as well if need be. Could anybody let me know what I need to do to fix this? Or even better, how to troubleshoot it myself so I can fix future problems like this myself?

[EDIT]: Okay so I managed to solve this. While playing around in Project->Build Options->Linker Settings->Link Libraries I noticed that if I add something like kernel32.lib I get an error from ld saying "cannot find -lkernel32.lib". So I searched around till I found the libraries I required and I added absolute paths to them, and now my project compiles flawlessly! :D However this was kind of strange since I did add my library search path and it didn't seem to help. So I went over it again to see why it didn't seem to work and it seems like one has to add a trailing backslash to the path name, like if the libraries are located in "C:\SDK\Lib\" one has to add the trailing slash for Code::BLocks to search it correctly. Once that was fixed I changed the option in Linker Settings->Link Libraries to kernel32 as was recommended and now it works without a hitch.

Thanks to everybody who helped me out with this!!! ^_^


I got the same errors when I place a library into system32 and try to link to it with LIBS += L$$quote(C:/Windows/System32).

When I placed it into a normal directory and set the relative path to it, everything works alright.


Looks like you are not linking with Kernel32.lib Check your project properties.


I'd the same problem and after some time I figured out how to do it, the problem relies on the linker, it's trying to link some windows functions into the exe file, and the compiler cannot find those, this is how I solved this:

  1. Install the Windows 7 SDK, you can download it from here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=3138
  2. Add the library path to the search libraries on CodeBlocks Project / Build Options (select The project if you want to link it to all the configurations you have) / Search Directories / Linker / Add and place the SDK Library path, which should be at: C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib
  3. Add the references to the windows libraries on the linker settings: Project / Build Options / Linker Settings / Add (at Link Libraries) and add kernel32, user32 and gdi32 (this last one should be added if you're using windows gui).

That's it... now rebuild your project and it should work flawlessly.

Note: You need to add this settings to the exe project, if you're creating libraries the error will be shown when try to link the exe file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜