Compiling with lccwin32 - problems

Locked
EmeraldTiger
Posts: 392
Joined: Fri Sep 17, 2010 1:53 am

Compiling with lccwin32 - problems

Post by EmeraldTiger »

So I`m trying to get into coding (while simultaneously learning Japanese... what a ride), so I`m following this tutorial: http://www.quake2.com/dll/tutorials/c/c1.html (It`s for Q2, but can usually be applied to Q3 as well)

It says to use lccwin32. I realize it`s majorly outdated but I`m more comfortable with following instructions exactly as they are told as I don`t want to mess things up and all. So I wrote the code down mentioned in the link, but when I go to compile it (make file) this is what I get:

f:\program files\lccwin32\lcc\bin\make.exe: Don't know how to make f:\program files\dll compiler\lcc\bin\hello.c

Any idea of what I`m doing wrong? :paranoid:

Thanks in advance. Hopefully if I learn enough in time I can help out Eraser a bit with his mod. (though I may only be able to do as much as add new items, etc. and not change major gameplay mechanics)
[color=#00FF00][b]EmeraldProductions[/b][/color]
http://emeraldproductions.weebly.com/index.html
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Compiling with lccwin32 - problems

Post by Silicone_Milk »

My instinct is saying that perhaps you have an invalid makefile.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Compiling with lccwin32 - problems

Post by ^misantropia^ »

That tutorial isn't applicable to Q3A, you need to download the SDK.
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Compiling with lccwin32 - problems

Post by Silicone_Milk »

from what I read he's just trying to get

Code: Select all

int main(int argc, char **argv){
    printf("hello, world!"); 
    return 0; 
}
to compile with lccwin32 for right now.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Compiling with lccwin32 - problems

Post by ^misantropia^ »

You're right. I might have spoken out of turn if the goal is to learn C in general, not as it pertains to Q3A.

@EmeraldTiger: may I recommend Visual Studio Express? It's a great IDE and you won't have to fudge with Makefiles.
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Compiling with lccwin32 - problems

Post by Silicone_Milk »

I second misantropia's suggestion.

makefiles are no fun :(
EmeraldTiger
Posts: 392
Joined: Fri Sep 17, 2010 1:53 am

Re: Compiling with lccwin32 - problems

Post by EmeraldTiger »

So now I`m using Visual Studio 2008, following this tutorial on C++: http://www.learncpp.com/

I`m trying to write a function which takes an integer parameter and returns double it`s value. I followed what the tutorial had to say and looked back and carefully examined where to put the code, this is what I did:

Code: Select all

#include <stdafx.h>
#include <iostream>

int doubler(int x, int 2)
{
	return x * 2; // takes a specified value and returns double it`s value
}

int main()
{
	using namespace std
	cout << doubler(6, 2) << endl;
	return 0;
}
I coded it right (no syntax errors or whatever) but my compiler spits out this one and only error message:

Code: Select all

fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
The C++ guide told me I could use VS2008, yet I`m getting an error message for missing paths even though I did exactly what they said. Why is it at the top of the Google listings for "learn c++" if it`s relying on an outdated version of the program? That confuses me greatly, and defies all common sense and logic.

Thank you very much in advance.
[color=#00FF00][b]EmeraldProductions[/b][/color]
http://emeraldproductions.weebly.com/index.html
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Compiling with lccwin32 - problems

Post by Silicone_Milk »

stdafx.h is a precompiled header.

For this current program you can remove that include line and the compiler will complain about a couple more things:

"int double(int x, int 2)" is incorrect. You can't use a number as a variable name in c++. You can rewrite this as

Code: Select all

int doubler(int x, int num){
    return x * num; 
} 
and you also forgot a semi-colon after "using namespace std"

Something to note - the 'using namespace std;' line (dont forget the semicolon) usually goes right under the include statements and not in the main function.

On another note, you might want to get in the habit now of just prefixing std functions with std:: instead of falling back on "using namespace". In larger projects it makes things, in my opinion, more clear on what's coming from where.
EmeraldTiger
Posts: 392
Joined: Fri Sep 17, 2010 1:53 am

Re: Compiling with lccwin32 - problems

Post by EmeraldTiger »

I got it working now, thank you. :up:

I am upset however that my compiler is so stupid. Does anyone know of a compiler that will list all the errors from the start? I wonder why it will mention that a file does not exist yet it won`t even complain about the syntax errors until I fix the other issue.
[color=#00FF00][b]EmeraldProductions[/b][/color]
http://emeraldproductions.weebly.com/index.html
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Compiling with lccwin32 - problems

Post by Silicone_Milk »

Well, the compiler won't complain about syntax issues because there's no point in doing so if it already encountered a fatal error (missing file). The compiler just assumes the program won't compile without the file and bails out.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Compiling with lccwin32 - problems

Post by ^misantropia^ »

EmeraldTiger wrote:I am upset however that my compiler is so stupid. Does anyone know of a compiler that will list all the errors from the start? I wonder why it will mention that a file does not exist yet it won`t even complain about the syntax errors until I fix the other issue.
If you use the VS IDE, it'll highlight syntax and other errors as you type.
Kaz
Posts: 1077
Joined: Wed Mar 08, 2006 3:43 am

Re: Compiling with lccwin32 - problems

Post by Kaz »

You might already know this, but Q3 is straight ANSI C instead of C++, just in case you're learning this for the primary purpose of modding Q3. Either way, keep at it! :up:
Locked