project-navigation
Personal tools

Author Topic: Compiling in Visual Studio 2005  (Read 12809 times)

  • Guest
Compiling in Visual Studio 2005
« on: March 27, 2006, 05:41:49 pm »
Hi, question from a total noob here.  Well.. I'm a professional software developer, but C/C++ isn't my first language and I haven't touched any OpenGL code in a few years.

I've downloaded and played the game.  (yay!)
I've installed SVN and tortoise SVN and downloaded the source.  (yay!)
I opened the ufoai\trunk\src\ufo.sln in VS2005 and attempted to compile it.

When I try to build ref_gl I'm getting the following:

fatal error C1083: Cannot open include file: 'GL/glext.h': No such file or directory   c:\svnroot\ufoai\ufoai\trunk\src\ref_gl\qgl.h

I've searched by HD and I don't have glext.h.

I'm running VS2005 Pro v 8.050727.42 on a WinXP Pro O/S.

Can someone help me?  Thanks.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Compiling in Visual Studio 2005
« Reply #1 on: March 27, 2006, 07:31:59 pm »
i thought, that i was included - but _Bnu our "windows-compiler" told me, that you need to download it.
try this one:
http://www.julius.caesar.de/oglext/

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Compiling in Visual Studio 2005
« Reply #2 on: March 27, 2006, 07:46:12 pm »
if you have any further problems join the irc-channel #ufo:ai at irc.freenode.org and ask _Bnu.

  • Guest
Compiling in Visual Studio 2005
« Reply #3 on: March 27, 2006, 08:52:47 pm »
Thanks very much for the very timely response.  Also having to install the DirectX SDK.

Gill_Bates

  • Guest
Compiling in Visual Studio 2005
« Reply #4 on: March 27, 2006, 11:25:36 pm »
I have a different problem:
The compiler VC++ 2005 complains about any variable declared within a method/function below any other command (C style - cannot decalre variables below any other command line)
Is that something I misconfigured in my VS IDE?

Gill_Bates

  • Guest
Compiling in Visual Studio 2005
« Reply #5 on: March 27, 2006, 11:32:28 pm »
Nevermind - I moved the declared variables a bit higher.
I still can't tell if the problem is mine alone, but at least it compiles (with about 150 warnings)

oxyXen

  • Guest
Compiling in Visual Studio 2005
« Reply #6 on: March 28, 2006, 01:53:06 am »
Code: [Select]
void f( void )
{
   foo = [malloc]
   foo = "bar";
}

char *foo;

void g( void )
{
   foo = [malloc]
   foo = "bar"
}


This is not a problem, but normal behaviour. In this code, when f is used, it doesn't know about foo. g is happy.

ox

Gill_Bates

  • Guest
Compiling in Visual Studio 2005
« Reply #7 on: March 28, 2006, 10:06:45 am »
Thanks, but I'm not sure we're talking about the same thing-
The thing my compiler complained about was something like:
Code: [Select]

typedef struct something_s
{
   int something;
} something_t;


void someFunction (void)
{
   int a; // this is OK
   if (globalVariable > 0)
      return;
   something_t* t; // This is not OK - must declare below int a
   int b; // this is not OK as well
   ...
}

void OKFunction (void)
{
   int a;
   something_t * t;
   int b;
   if (globalVariable > 0)
      return;
   ...
}


Furthermore, I suggest putting NULL in any such something_t pointer before it is used.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Compiling in Visual Studio 2005
« Reply #8 on: March 28, 2006, 01:32:21 pm »
give my the files and lines and i'll fix this.

but be sure to check out the latest svn

Hoehrer

  • Guest
Compiling in Visual Studio 2005
« Reply #9 on: March 28, 2006, 02:17:24 pm »
Quote from: "Gill_Bates"
The thing my compiler complained about was something like:
Code: [Select]

typedef struct something_s
{
   int something;
} something_t;


void someFunction (void)
{
   int a; // this is OK
   if (globalVariable > 0)
      return;
   something_t* t; // This is not OK - must declare below int a
   int b; // this is not OK as well
   ...
}

Why would this be a problem at all? (mind you i'm not a very good c-programmer as well) if you define variables/structs and do not use/access them before that line there will be no problem in any case. I think your compiler just gives you hints to prevent commons mistakes, but not showing any _real_ errors. ... But that's just a thought.

If this is an error you can't do something like this (this isn't tested though):
Code: [Select]
{
int x;
x = SomeFunction();
if ( x ) {
int temp;
temp = x;
// do alot of calculations and displaying temp.
// temp not needed anymore.
}

// At this point if x was 0 temp was never defined at all (no memory reserved)

}



Quote
Furthermore, I suggest putting NULL in any such something_t pointer before it is used.

Good idea. Will see what i can do here in my code as well.


Werner

Gill_Bates

  • Guest
Compiling in Visual Studio 2005
« Reply #10 on: March 28, 2006, 02:42:42 pm »
Well, when I learned C a long long time ago, they told me that local variable declarations had to be made at the beginning of each scope such as a function scope (I don't recall if this rule included the "if" scope in your example).
I think that because this is a pure C project all the C++ rules of allowing "lazy" declarations are not valid. Anyway, if it is indeed the reason that my compiler complains, we have nothing to worry about. I don't think that saving the stack space is critical to the performance of this code.

Martin: OK, it's just one file, just name your favourite method (e-mail /other). I can't get into your irc server for some obscure reason, so DCC isn't an option.

Hoehrer

  • Guest
Compiling in Visual Studio 2005
« Reply #11 on: March 28, 2006, 02:53:26 pm »
Quote from: "Gill_Bates"
Well, when I learned C a long long time ago, they told me that local variable declarations had to be made at the beginning of each scope such as a function scope (I don't recall if this rule included the "if" scope in your example).

That might be the case ... now that i think about it this seems quite locigal.

Quote
I think that because this is a pure C project all the C++ rules of allowing "lazy" declarations are not valid. Anyway, if it is indeed the reason that my compiler complains, we have nothing to worry about. I don't think that saving the stack space is critical to the performance of this code.

I don't have anything against this .. in fact i would een make it a coding style rule or something. I just wondered that the compiler complains ;)

Quote
Martin: OK, it's just one file, just name your favourite method (e-mail /other). I can't get into your irc server for some obscure reason, so DCC isn't an option.

If nothing else works you can still use the bug-tracker (upload patches) if you have a sf-account.

Werner

Gill_Bates

  • Guest
Compiling in Visual Studio 2005
« Reply #12 on: March 28, 2006, 07:47:56 pm »
Quote

If nothing else works you can still use the bug-tracker (upload patches) if you have a sf-account.


Done, I hope this is OK.

Hoehrer

  • Guest
Compiling in Visual Studio 2005
« Reply #13 on: March 29, 2006, 12:27:24 pm »
Quote from: "Gill_Bates"
Done, I hope this is OK.

Perfect. I had a look into this and i think all these changes have been fixed by me recent commits already .. except for the NULL assignments, but i'll fix that soon.

Does the current svn code compile for you? If yes i'll close this tracker.

Werner

Gill_Bates

  • Guest
Compiling in Visual Studio 2005
« Reply #14 on: March 29, 2006, 09:43:29 pm »
not quite, the RS_ResearchDisplayInfo method was still wrong. There were some declarations below an assignment to variable t

The compilable method is:
Code: [Select]

void RS_ResearchDisplayInfo ( void  )
{
technology_t *t = NULL;
char dependencies[MAX_VAR];
char tempstring[MAX_VAR];
int i;
stringlist_t req_temp;
t = &technologies[globalResearchNum];
req_temp.numEntries = 0;

The rest of the method (comment and if statement) are the same[/code]