View previous topic - View next topic |
Author |
Message |
Y treefingers Y I wanna be a ballerina!
Joined: 21 Apr 2003 Posts: 29
|
Posted: Sun Jun 15, 2003 5:30 pm Post subject: |
[quote] |
|
sorry... got one more question (maybe more in the future).. i got a linker error that says "c:\dev-c++\window.o(.text+0x280):window.cpp: undefined reference to `PlaySoundA@12'
c:\dev-c++\window.o(.text+0x2a0):window.cpp: undefined reference to `PlaySoundA@12' "
it says that when i try to do this...
PlaySound("1979.wav",NULL,SND_FILENAME|SND_ASYNC);
any ideas would help me so much, thanks
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Sun Jun 15, 2003 5:40 pm Post subject: |
[quote] |
|
you proably need to link with libwinmm.a
add it under project options->parameters -> linker _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
Y treefingers Y I wanna be a ballerina!
Joined: 21 Apr 2003 Posts: 29
|
Posted: Sun Jun 15, 2003 9:03 pm Post subject: |
[quote] |
|
hmm... you know how to do that w/ Dev-C++?
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Sun Jun 15, 2003 9:23 pm Post subject: |
[quote] |
|
Y treefingers Y wrote: | hmm... you know how to do that w/ Dev-C++? |
Err, my reply was how todo it with dev-C++ in msvc++ you would add winmm.lib
here's a step by step guide:
1: press alt + p
2: click the parameter tab
3: click the "Add Library or Object" button
4: go to the DevCpp folder, find the lib folder and select libwinmm.a
done. _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
Y treefingers Y I wanna be a ballerina!
Joined: 21 Apr 2003 Posts: 29
|
Posted: Mon Jun 16, 2003 12:14 am Post subject: |
[quote] |
|
yes! it works! but one more thing... i want to send this program to my friends, so how do i save the songs onto the program itself so they dont have to have the song already, but it'll be in the program?
|
|
Back to top |
|
|
DrV Wandering Minstrel
Joined: 15 Apr 2003 Posts: 148 Location: Midwest US
|
Posted: Mon Jun 16, 2003 4:16 am Post subject: |
[quote] |
|
I think you maybe need to add an entry to the resource file (rsrc.rc) or something similar... _________________ Don't ask no stupid questions and I won't send you away.
If you want to talk fishing, well, I guess that'll be okay.
|
|
Back to top |
|
|
Jihgfed Pumpkinhead Stephen Hawking
Joined: 21 Jan 2003 Posts: 259 Location: Toronto, Canada
|
Posted: Mon Jun 16, 2003 6:41 am Post subject: Pumpkins' Game? |
[quote] |
|
Well, this is a little off-topic, but...
Y treefingers Y wrote: | PlaySound("1979.wav",NULL,SND_FILENAME|SND_ASYNC); |
Please tell me you're setting your game to Smashing Pumpkins music. I love their music, despite their name (which is, frankly, a little offensive to the pumpkin-headed).
|
|
Back to top |
|
|
Y treefingers Y I wanna be a ballerina!
Joined: 21 Apr 2003 Posts: 29
|
Posted: Mon Jun 16, 2003 2:40 pm Post subject: |
[quote] |
|
well, im not making a game... just a window application, but yeah...its Smashing Pumpkins. They are one of my favorite bands, along with Radiohead (Treefingers). I was going to put on some Mellon Collie and the Infinite Sadness stuff on the program to learn how to have music on and stuff like that.
hey, this is the "off-topic" forum, so it doesnt really matter
|
|
Back to top |
|
|
Y treefingers Y I wanna be a ballerina!
Joined: 21 Apr 2003 Posts: 29
|
Posted: Tue Jun 17, 2003 9:53 pm Post subject: |
[quote] |
|
hmm...DrV...what would i put in the RC? anyone know how to save songs on the program?
|
|
Back to top |
|
|
DrV Wandering Minstrel
Joined: 15 Apr 2003 Posts: 148 Location: Midwest US
|
Posted: Wed Jun 18, 2003 2:34 am Post subject: |
[quote] |
|
Y treefingers Y wrote: | hmm...DrV...what would i put in the RC? anyone know how to save songs on the program? |
Hmm... I dunno... I just thought that was how you do it. Maybe I can find an example. Most of the stuff I've done with resource compilers and the like has been with VB, so it probably doesn't apply here, unless the compiler is the same, which I kind of doubt. ;) But if I find something, I'll post it. _________________ Don't ask no stupid questions and I won't send you away.
If you want to talk fishing, well, I guess that'll be okay.
|
|
Back to top |
|
|
LeoDraco Demon Hunter
Joined: 24 Jun 2003 Posts: 584 Location: Riverside, South Cali
|
Posted: Wed Jul 02, 2003 7:16 am Post subject: |
[quote] |
|
ThousandKnives wrote: | Ugh. I should've really stopped being a cheap-ass many many years ago and bought Visual but, I guess I'm just cheap to the end. |
Well, while Piracy is generally frowned upon -- especially as it is illegal in the US, et al. -- it [the Piracy] can be your friend, especially when the item to be pirated is an over-priced piece of software.
I myself use VC6 when in Windows -- simply because I'm too lazy to download and set up a separate MingW compiler, and the DOS versions of standard GNU-Linux apps are entirely too slow to even think of using DJGPP on my box.
However, when in a Linux environ, I stick to beautiful emacs and the tidy Bourne Again Shell. That's all anyone really needs, heh. _________________ "...LeoDraco is a pompus git..." -- Mandrake
|
|
Back to top |
|
|
Y treefingers Y I wanna be a ballerina!
Joined: 21 Apr 2003 Posts: 29
|
Posted: Sat Jul 19, 2003 1:40 am Post subject: |
[quote] |
|
couple of questions
1.) i am setting up directx now (yes, i might finally make a game someday), and i found a directx program to test it out (to see if i got directx properly in on the Compiler Settings). When i compile it, it gets a linker error that says "g++: c:\dev-c++\ld.o: No such file or directory
" i dont even know what Id is, and i dont even know what a O file is...can someone explain all these problems and tell me how to fix it? (BTW...i searched my PC and there is no file named id.o)
2.) how much does Microsoft Visual C++ cost? (you can tell why i want it, haha)
|
|
Back to top |
|
|
Jihgfed Pumpkinhead Stephen Hawking
Joined: 21 Jan 2003 Posts: 259 Location: Toronto, Canada
|
Posted: Sat Jul 19, 2003 7:10 am Post subject: Compiling/Linking |
[quote] |
|
I'm no expert, but I'll help you as far as I can until one comes along.
A .o file is an object file. Object files are the middle area between source code and binary program. In fact, they're sort of like little programs themselves, they just can't do anything useful on their own.
Creating a program goes something like this:
1. Write the source. Code: | #include <iostream>
int main () {
cout << "Linus, there's no such thing as a Great Pumpkin.";
return 0;
} | etc.
2. Compile. This turns your source code (linus.cpp) into an object file (linus.o).
3. Link. This takes all the object files you need and mushes them together so that they come out looking more or less like a program. In the above, you might think that linking is pointless, because there's only one object file and therefore nothing to link to. But that "#include " in the source means you are using another object file, probably something like "iostream.o" (that's a wild guess, it could be called anything). The program that links all the stuff together is smart enough to know based on your source that you'll need iostream.o, so it does it itself, but it isn't always that smart, and usually needs to be instructed on what specifically to link with what.
It's trying to link against your ld.o file because its own code is not sufficient, just as my code didn't really contain any iostream code, it just pretended to know what it was talking about. That's the difference between a .cpp source file and .h header file: the .cpp contains the guts, the know-how, the stuff that'll be turned into a .o file, in a word, the code; the .h contains the bare description of it, so that other source can use the stuff inside without actually have any idea what's happening. The linker takes all the .o files, all of which have only a partial knowledge (gained by headers) of what's going on, and it squishes them all together into one big, happy .exe, and that's what you run.
Usually, when you write a simple one-file test program, this all happens in one step. Calling gcc helloworld.cpp invokes both the compiler and linker all at once, so you don't even realize what's going, and never have to deal with the .o file. Once you get multi-file programs, though, you're going to have to start understanding the difference between compiling and linking.
For some reason, none of the online tutorials I've ever read have been very good at explaining this process, possibly because it's hard to explain, as I've just proven with my goofy attempt. Anyway, that's why I've gone into it at such length, and I'm very sorry if you knew all this before.
The simple answer to your question is that you probably have a "ld.cpp" (or "ld.c" or "ld.cc" or "ld.whatever") file lying around somewhere just waiting to be compiled into a ld.o file. I don't know how you do this from Dev-C++ but from the command line it's a simple "gcc ld.cpp -c" (the "-c" says "just make an object file, don't try to make an executable").
Ta-daa! Hope this helps some.
P.S., from what I've heard and seen (though I've never used it myself), MSVC will hide this stuff from you to a degree. That may be a good thing or a bad thing, depending on whether you want to "expand your mind" and be u83r133+, or whether you want to write functioning programs quickly. Keep in mind also that MSVC is the most proprietary of all the compilers I've seen (i.e., don't expect to write anything for Linux or Mac (and they might be phasing out DOS, too)), and it costs an arm and a leg.
|
|
Back to top |
|
|
LeoDraco Demon Hunter
Joined: 24 Jun 2003 Posts: 584 Location: Riverside, South Cali
|
Posted: Sat Jul 19, 2003 10:21 am Post subject: Re: Compiling/Linking |
[quote] |
|
Jihgfed Pumpkinhead wrote: | That's the difference between a .cpp source file and .h header file: the .cpp contains the guts, the know-how, the stuff that'll be turned into a .o file, in a word, the code; the .h contains the bare description of it, so that other source can use the stuff inside without actually have any idea what's happening. |
That's not entirely true; rather, it is true for about 99% of the time. However, gcc and msvc -- and several other compilers, more than likely -- have a hard time interpreting templated classes properly. That is to say, it is rather ambiguous to simply include an interface specification for a template sans the "guts", as it were, as the guts themselves are only compiled if they are needed. (It would make no sense to compile a class template file named "FooTemplate.cpp".) This is why you'll generally see all templated classes include their interface and their implementation all in one file. (Either by inlining the implementation in the class declaration, or by appending what would be in the implementation file at the end of the header file.)
However, this is not an issue for non-templated classes/files/projects, heh.
Also, as this is true for templates, you can load up your compilers local <vector> or <map>, or whatever, and see how it is implemented, should you be curious. Vector scares me. _________________ "...LeoDraco is a pompus git..." -- Mandrake
|
|
Back to top |
|
|
Rainer Deyke Demon Hunter
Joined: 05 Jun 2002 Posts: 672
|
Posted: Sat Jul 19, 2003 6:24 pm Post subject: |
[quote] |
|
Side note: the proper extension for C++ header files is .hpp, not .h. .h is the extension for C header files. Using .hpp for C++ header files serves as a reminder that the file in question is in C++ and cannot be included by .c files. Just as important, if you use an editor with syntax highlighting, the .hpp extension tells it to use C++ syntax highlighting whereas a .h file would have C syntax highlighting.
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|