Click to See Complete Forum and Search --> : adding libs in VS.NET
monkschain
10-11-2004, 02:51 PM
Hi, I'm using VS.NET and I'm going through the Petzold book. As the .NET '03 wil not open the Petzold projects from the CD, I am trying to recreate them in .NET
I'm having trouble with a project which is very simple Win32 Hello window which plays a .wav file using PlaySound().
I do not know the steps needed to get the .wav into the project , how to link to the WinMM.lib which is needed, and how to make the linker settings in the IDE etc. Do I need to create a new resource from the .wav file??
Cheers
jonnin
10-11-2004, 05:09 PM
yes, you should add the file as a resource if you do not plan to open it from the disk (that should work too).
To link a LIB file, you must include the header file that goes with it (.h).
Leave the project settings alone until you get a handle on the easier stuff - they can mess up more than they will help if you are new to them.
monkschain
10-12-2004, 07:26 AM
The lib I required was to play a wav file.
One solution was to copy the wavefile into the project folder and the lib is added in the linker:
right click on solution name
Properties>Linker>Input>additional dependencies>add name of lib
So I add the wav file as a resource file. What is the difference between adding the file as a resource and opening it from the disk?
The project seems fine the way I did it. Don't know if the linker setting above linked to the .h?
Resources and linking is a bit of a sticky subject for me at the moment.
Does anyone know of a decent book that teaches these kinds of IDE details- preferably C++ or Win32?
Cheers
jonnin
10-12-2004, 05:08 PM
a resource is bundled into the executable i *think*. Not 100% sure, it seems that way with the bitmaps and icons, all I have tried. Opening on disk means the file is on the disk, perhaps you were opening it from the current folder (for example, file.open(whatever.wav)) instead of supplying a path (file.open(c:
whatever.wav)... that could be it. From visual, if you execute within the environ, the current folder is the project folder, if you run it by double click the executable, the current is the folder the exe is inside.
libs generally need a .h if they are "function bundle libs" (not a technical name, but a description). A lib can also contain images, icons, waves, or any other data. Do you see the .h in the file list? you can bypass the .h by creating your own, or using extern "C" magic, or uglier stuff extracted from hex editors or dumpbin or the like, it gets worse from here...
monkschain
10-12-2004, 06:25 PM
a resource is bundled into the executable i *think*. Not 100% sure, it seems that way with the bitmaps and icons, all I have tried.
That rings a bell actually from previous stuff I did.
Opening on disk means the file is on the disk, perhaps you were opening it from the current folder (for example, file.open(whatever.wav)) instead of supplying a path (file.open(c:
Yep I was aware that you could put the whole file path in but I wasn't sure about the syntax + Petzold didn't do this in the project so I figured this was a simpler way. The .wav resides in the directory above the Debug dir (where the .exe is). I just tried the program with the wav moved to Debug dir and that seems OK also.
The lib was winMM.lib so I presume it is a function library. (?) No there is no .h file there nor in the original Petzold project. I've seen the extern statement a lot when I was using Builder, but I can't remember what it does off hand. Is it like a declaration but one that acts like a global between modules ?
Hmm...the other stuff I'm not familiar with...
Cheers
jonnin
10-12-2004, 07:37 PM
ah winmm is the directinput/directx or somesuch, which does need a header, but the name is different- directx.h or the like? I forget that too... Details escape me, sorry about that.
extern tells the compiler that the implementation/declaration of something is "somewhere else" : "let the linker resolve this one, not the compiler".
don't sweat the other stuff, but keep dumpbin in the back of your mind in case you ever want to tap into someone else's dll or lib -without really knowing what's there, you can dump a list of the exported functions, and cook up enough code to call them if you are really desperate...
monkschain
10-13-2004, 07:32 AM
winmm is the directinput/directx or somesuch, which does need a header, but the name is different- directx.h or the like?
There is no header in the project, unless it's hidden away and I'm not looking in the right places. It's certainly not in the solution explorer. The program includes windows.h- would this provide an appropriate link to the header file for winMM.lib?- I know that it is a master include that includes other Windows header files which include other headers. I would like to clear this up if possible because the compiling and linking is where I am a bit vague still.
also...what exactly is dumping?
jonnin
10-13-2004, 11:09 AM
I included mmsystem.h and dinput.h, its probably the first one that matches that lib file. My program taps a usb joystick, nothing fancy.
look under external depend's in the IDE under files for the includes that are not in project but are included by statements.
Dump - I don't know the origin, maybe core-dump, a unix-ism for spitting out the entire system state to a file when a program crashes. Anyway, dump = get data from ....
Danny
10-13-2004, 11:33 AM
Originally posted by jonnin
a resource is bundled into the executable i *think*. Not 100% sure, it seems that way with the bitmaps and icons, all I have tried. O
Indeed, they are. That's why Windows .exe file are so bloated:) If you examine the PE format you will find the location for this stuff inside the image file. It is possible of course to use external resources, such as sound files and images that are loaded at runtime but these aren't exactly the same thing.
monkschain
10-13-2004, 02:54 PM
I've just installed the MSDN documentation so I should be able to go through the IDE 'getting started' and figure stuff out. Would like to get into some of that DirectX programming myself but figured I'd better start with basic Win32 first.
Thanks for the help :cool:
devx.com
Copyright Internet.com Inc. All Rights Reserved