C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-02-2009, 09:49 AM   #1
Registered User
 
Join Date: Feb 2009
Posts: 8
Visual C++ Linking with mmsystem.h

Hello I am trying to write a simple sound recorder in a win32 forms application using visual c++ and am having problems linking to mmsystem.h I have the recorder working fine in a console application but cannot get it to work as a win32 app. when trying to reference the function waveInGetNumDevs() I get a linking error when trying to compile:

Error 1 error LNK2028: unresolved token (0A000031) "extern "C" unsigned int __stdcall waveInGetNumDevs(void)" (?waveInGetNumDevs@@$$J10YGIXZ) referenced in function "public: __clrcall record::Form1::Form1(void)" (??0Form1@record@@$$FQ$AAM@XZ) record.objrecord


I am assuming this has to do with managed and unmanaged code mixed together. So i made a header file referencing just the needed function and surrounded it with #pragma unmanaged and am compiling with /clr option.

Here is the header file:
Code:
#sound.h
#include "windows.h"
#include "mmsystem.h"
#pragma unmanaged
WINMMAPI  UINT WINAPI waveInGetNumDevs(void);
Here is the code generating the error:
Code:
#include "sound.h"
#pragma managed
namespace record {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	public ref class Form1 : public System::Windows::Forms::Form
	{
		HWAVEIN hwin;
		MMRESULT result;
		int numDevices;
	public:
		Form1(void)
		{
			InitializeComponent();
			numDevices = waveInGetNumDevs();
		}
Any help on this matter would be appreciated. Thanks a lot.

--koooee
koooee is offline   Reply With Quote
Old 07-02-2009, 02:11 PM   #2
Registered User
 
hk_mp5kpdw's Avatar
 
Join Date: Jan 2002
Location: Northern Virginia/Washington DC Metropolitan Area
Posts: 2,787
mmsystem.h is a header and you don't link with headers, you link with libraries. There is probably a library you need to explicitly link with (winmm.lib if I'm not mistaken) in your project settings.
__________________
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
--Charles Babbage, 1792-1871

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
hk_mp5kpdw is offline   Reply With Quote
Old 07-02-2009, 02:43 PM   #3
Registered User
 
Join Date: Feb 2009
Posts: 8
i feel stupid....(that was in my console version of the code) thanks for the reply.

if anyone is wondering...put this line in stdafx.h

Code:
#pragma comment(lib, "winmm.lib")
koooee is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
We Got _DEBUG Errors Tonto Windows Programming 5 12-22-2006 05:45 PM
C++ std routines siavoshkc C++ Programming 33 07-28-2006 12:13 AM
load gif into program willc0de4food Windows Programming 14 01-11-2006 10:43 AM
Errors with including winsock 2 lib gamingdl'er C++ Programming 3 12-05-2005 08:13 PM
Learning OpenGL HQSneaker C++ Programming 7 08-06-2004 08:57 AM


All times are GMT -6. The time now is 07:19 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22