.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Programming (http://forums.bots-united.com/forumdisplay.php?f=25)
-   -   visual C++ 6.0 metamod compile question (http://forums.bots-united.com/showthread.php?t=934)

cruft 28-02-2004 09:31

visual C++ 6.0 metamod compile question
 
Does anyone have step-by-step instructions on how to setup visual c++ 6.0 to compile a metamod dll? I've been playing with it for while without any luck. The problem isn't compiling. I'm able to compile the dll without any errors. The problem is that metamod doesn't load the resulting dll.

I should also mention that I've been compiling the same source with the free borland c++ compiler without any metamod loading issues. For the borland compile, I have to use a .def file for it to work correctly. I also tried a .def file with visual c++ and didn't have any luck there either.

Pierre-Marie Baty 28-02-2004 16:20

Re: visual C++ 6.0 metamod compile question
 
Strange...
Is it really your compiler's configuration ?
I assume you're talking about compiling metamod plugins, not metamod itself.
Have you tried recompiling a metamod plugin of which you have the source code ?

Austin 29-02-2004 10:24

Re: visual C++ 6.0 metamod compile question
 
You for sure need a def file or Metamod will not load the dll since the dll will not have any exports.

Here is an example Metamod def file of mine "hostageFix.def"

LIBRARY hostageFix_mm
EXPORTS
GiveFnptrsToDll @1
SECTIONS
.data READ WRITE

For Vc 6.0 you will also need a /def:"hostageFix.def"
in the link options in the project settings.

I had this exact same problem the first time I tried to make a mm dll.

If you still can't get it working download this small mm project to see how everything is set up. You will obviously have to change the include paths in this project. All it does is keep hostages from taking damage to fix the pod bot 2.5 crash.

http://austinbots.com/hostagefixsource.zip

It has project files for both VC60 and VC.NET
It also shows a nice organized way is setting up a Metamod project separating your functions from the Metamod required stuff and correctly using a common include file. This MIGHT be a little over kill for a tiny project but it really help on larger projects.

This project also shows you how to add a VERSION RESOURCE to your dll so you can right click it, do a properties, go to version and see what version it is!

HELLO!
Any BOT authors listening?
VERSION STAMP YOUR DLLS!
WHAT A NOVEL IDEA!

cruft 29-02-2004 20:53

Re: visual C++ 6.0 metamod compile question
 
Thanks for the tips. There were 2 problems that prevented me from getting a metamod loadable .dll 1) my .def file was incorrect - I was using the .def file from my borland c++ compile and it's different for visual c++, and 2) I needed to add the /def option you mentioned for the .def file to take effect. End result is now metmod loads the .dll. w00t!!

Pierre-Marie Baty 01-03-2004 00:26

Re: visual C++ 6.0 metamod compile question
 
Quote:

Originally Posted by Austin
HELLO!
Any BOT authors listening?
VERSION STAMP YOUR DLLS!
WHAT A NOVEL IDEA!

I hear you Austin, I hear you :)
However this win32-specific version stuff does not suit the version convention scheme I'd like to use. I version stamp most of my files under the form YYYYMMDD[-b] for year, month, day and (optionally) build, such as "version 20040229-2", which tells me the file was the second release built on february 29, 2004. Windows, on the other hand, wants me to version stamp my files like "1.0.0.1" or so. It doesn't represent anything for me... :(

If you tell me I can keep my version convention scheme with the Windows version stamp resource, I'll add this version stamp resource right away to all of my projects, I swear !

Austin 01-03-2004 06:04

Re: visual C++ 6.0 metamod compile question
 
Quote:

Originally Posted by Pierre-Marie Baty
I hear you Austin, I hear you :)
However this win32-specific version stuff does not suit the version convention scheme I'd like to use. I version stamp most of my files under the form YYYYMMDD[-b] for year, month, day and (optionally) build, such as "version 20040229-2", which tells me the file was the second release built on february 29, 2004. Windows, on the other hand, wants me to version stamp my files like "1.0.0.1" or so. It doesn't represent anything for me... :(

If you tell me I can keep my version convention scheme with the Windows version stamp resource, I'll add this version stamp resource right away to all of my projects, I swear !

PM, I woudl say this fits in almost exactly with what you described.
http://austinbots.com/version.jpg


The only downside is you can't have leading 0's,
otherwise it is exactly what you wanted but with "."

AND you COULD use the file and product version anyway you want to since it is free text.

I agree the version resource, like SOOO MANNY things was totally duffed by
the V-O-L-E. (the inq.'s (http://www.theinquirer.net) pet name for MS. Look up vole at dictionary.com! ahaha! )

Yes, tell me why few if any ms executables follow this 1.1.1.1 ridiculous scheme, but their development tools seem to force this on us.


BUT, I believe ANY version stamping is better than NONE even 1.1.1.1.

I believe totally in the simple major.minor version scheme.
This is easy for the end users to deal with, the whole point.
The version isn't for developers. We should have build numbers internally that we use.


For a professional product you SHOULDN'T have a bunch of releases!
(Steam for example. What a mess... sorry to say…)

Pierre-Marie Baty 01-03-2004 09:56

Re: visual C++ 6.0 metamod compile question
 
Thanks a lot for the info !

Do you know if it is possible to have these resource strings reference variables ?
So far I use a function which generates the file version number at startup from the __DATE__ preprocessor macro and puts it in a string. I'd like this string to be tied at run-time to the FileVersion resource string if this is possible. Do you have an idea ?

Austin 01-03-2004 10:45

Re: visual C++ 6.0 metamod compile question
 
You can hack the .rc file directly.
VC doesn't load it until you open it in the resource editor.
So you could write a script that opens it, writes out the new version when your project is opened.

I saw an example on how to implement an auto build version incrementor at either
http://www.devguru.com
or
http://www.codeguru.com
a long time ago..

Pierre-Marie Baty 02-03-2004 01:12

Re: visual C++ 6.0 metamod compile question
 
missed!
it's http://www.codeproject.com
:D

http://www.codeproject.com/macro/autobuild.asp
thanks anyway :)

Austin 02-03-2004 02:24

Re: visual C++ 6.0 metamod compile question
 
I forgot about codeproject.
I have been looking at that site. Nice site.
Nice method for auto build numbers.
I think I will start using it, thanks!

Pierre-Marie Baty 02-03-2004 04:56

Re: visual C++ 6.0 metamod compile question
 
1 Attachment(s)
I've got something better for you, Austin ... :)
Code:

// The purpose of this program is to be called in the "Pre-Build Step" state of
// your project compilation so as to generate an updated resource file featuring
// an automatically updated version number, along with several other optional
// parameters. It is particularly useful with IDEs where no resource editors are
// available, such as Borland or MingW32. It can also be used with MSVC to always
// keep your executable version numbers up to date.
//
// The version number string and DWORD are generated automatically by the program
// according to the YYYYMMDD convention (year - month - day), as in "20040228".
//
// makeres.cpp
 
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
#include <string.h>
 

int myfputs (FILE *fp, const char *fmt, ...)
{
  // this function sends a message string to a file. It's basically a wrapper for fputs() which
  // allows me to pass formatted strings, printf style, instead of building them myself.
 
  va_list argptr;
  static char string[1024];
 
  if (fp == NULL)
          return (1); // reliability check
 
  // concatenate all the arguments in one string
  va_start (argptr, fmt);
  vsprintf (string, fmt, argptr);
  va_end (argptr);
 
  fputs (string, fp); // send the concatenated string to the file
 
  return (0); // and return with a "no error" signal
}
 

const char *MakeVersion (void)
{
  // this function builds the version number string and the welcome message string out of it.
  // The version number string is a 8 digit string describing the date at which the program was
  // compiled, in which the digits are arranged under the form "YYYYMMDD" (year, month, day).
  // This order allow earlier dates to be represented by a smaller 8-digit number and later
  // dates to be represented by greater ones. We use the __DATE__ standard C macro to get the
  // program compile date string ; this string being under the form "Mmm DD, YYYY" such as in
  // "Mar 4, 2003", we need to process it in order to convert it into our own YYYYMMDD format.
 
  const char *compile_date = __DATE__;
  static char version[64];
  char year[5], month[3], day[3], temp[8];
 
  // get the year under the form YYYY
  strncpy (temp, compile_date + 7, 4);
  temp[4] = 0; // terminate the string
  sprintf (year, "%04d", atoi (temp)); // and format the 4 digits
 
  // translate the month string under the form MM
  if (strncmp ("Jan", compile_date, 3) == 0)
          strcpy (month, "01");
  else if (strncmp ("Feb", compile_date, 3) == 0)
          strcpy (month, "02");
  else if (strncmp ("Mar", compile_date, 3) == 0)
          strcpy (month, "03");
  else if (strncmp ("Apr", compile_date, 3) == 0)
          strcpy (month, "04");
  else if (strncmp ("May", compile_date, 3) == 0)
          strcpy (month, "05");
  else if (strncmp ("Jun", compile_date, 3) == 0)
          strcpy (month, "06");
  else if (strncmp ("Jul", compile_date, 3) == 0)
          strcpy (month, "07");
  else if (strncmp ("Aug", compile_date, 3) == 0)
          strcpy (month, "08");
  else if (strncmp ("Sep", compile_date, 3) == 0)
          strcpy (month, "09");
  else if (strncmp ("Oct", compile_date, 3) == 0)
          strcpy (month, "10");
  else if (strncmp ("Nov", compile_date, 3) == 0)
          strcpy (month, "11");
  else if (strncmp ("Dec", compile_date, 3) == 0)
          strcpy (month, "12");
  else
          strcpy (month, "??"); // unable to understand the month string, WTH ???

  month[2] = 0; // terminate the string
 
  // get the day under the form DD
  strncpy (temp, compile_date + 4, 2);
  temp[2] = 0; // terminate the string
  sprintf (day, "%02d", atoi (temp)); // and format the 2 digits
 
  // build the version string and the welcome text string
  sprintf (version, "%s%s%s", year, month, day);
 
  return (version); // finished
}
 

int main (int argc, char **argv)
{
  // this function creates a minimal RC file that will be used to build a MSVC project,
  // featuring the appropriate version number and optional strings passed as arguments.
 
  FILE *fp = NULL;
  char filename[256] = "";
  char version_versionstring[32], temp_string[32];
  int version_year, version_month, version_day, version_release, index;
  char version_comment[256] = "";
  char version_companyname[256] = "";
  char version_filedescription[256] = "";
  char version_internalname[256] = "";
  char version_legalcopyright[256] = "";
  char version_legaltrademarks[256] = "";
  char version_originalfilename[256] = "";
  char version_privatebuild[256] = "";
  char version_productname[256] = "";
  char version_specialbuild[256] = "";
 
  // no argument specified ?
  if (argc == 1)
          goto PrintUsageAndExit; // then print a little help blurb and terminate the program
 
  // parse all arguments
  for (index = 1; index < argc; index++)
  {
          if (argv[index][0] != '-')
                strcpy (filename, argv[index]); // if not beginning by a dash, it's the filename
 
          else if (strnicmp ("-t", argv[index], 2) == 0)
                strcpy (version_comment, argv[index] + 2); // comment
          else if (strnicmp ("-c", argv[index], 2) == 0)
                strcpy (version_companyname, argv[index] + 2); // company name
          else if (strnicmp ("-d", argv[index], 2) == 0)
                strcpy (version_filedescription, argv[index] + 2); // file description
          else if (strnicmp ("-i", argv[index], 2) == 0)
                strcpy (version_internalname, argv[index] + 2); // internal name
          else if (strnicmp ("-l", argv[index], 2) == 0)
                strcpy (version_legalcopyright, argv[index] + 2); // legal copyright
          else if (strnicmp ("-m", argv[index], 2) == 0)
                strcpy (version_legaltrademarks, argv[index] + 2); // legal trademarks
          else if (strnicmp ("-o", argv[index], 2) == 0)
                strcpy (version_originalfilename, argv[index] + 2); // original filename
          else if (strnicmp ("-p", argv[index], 2) == 0)
                strcpy (version_privatebuild, argv[index] + 2); // private build
          else if (strnicmp ("-n", argv[index], 2) == 0)
                strcpy (version_productname, argv[index] + 2); // product name
          else if (strnicmp ("-s", argv[index], 2) == 0)
                strcpy (version_specialbuild, argv[index] + 2); // special build
          else
                goto PrintUsageAndExit; // invalid parameter
  }
 
  // no output file specified ?
  if (filename[0] == 0)
  {
          printf ("%s: no output filename\n", argv[0]);
          goto PrintUsageAndExit; // then exit with an error condition
  }
 
  // open version.rc file for writing, and squash all that's in it
  fp = fopen (filename, "w");
  if (fp == NULL)
  {
          printf ("Error opening resource file \"%s\" for writing\n", filename);
          goto PrintUsageAndExit; // exit with an error condition if the file couldn't be open
  }
 
  // make the version string
  sprintf (version_versionstring, MakeVersion ());
 
  // make the version year, month, day and release
  memset (temp_string, 0, sizeof (temp_string));
  strncpy (temp_string, version_versionstring + 0, 4);
  version_year = atoi (temp_string);
  memset (temp_string, 0, sizeof (temp_string));
  strncpy (temp_string, version_versionstring + 4, 2);
  version_month = atoi (temp_string);
  memset (temp_string, 0, sizeof (temp_string));
  strncpy (temp_string, version_versionstring + 6, 2);
  version_day = atoi (temp_string);
  memset (temp_string, 0, sizeof (temp_string));
  strcpy (temp_string, version_versionstring + 8);
  version_release = atoi (temp_string);
 
  // now generate the RC file
  myfputs (fp, "// Auto-generated, so don't bother.\n");
  myfputs (fp, "\n");
  myfputs (fp, "#include <winver.h>\n");
  myfputs (fp, "\n");
  myfputs (fp, "VS_VERSION_INFO VERSIONINFO\n");
  myfputs (fp, "FILEVERSION %d,%d,%d,%d\n", version_year, version_month, version_day, version_release);
  myfputs (fp, "PRODUCTVERSION %d,%d,%d,%d\n", version_year, version_month, version_day, version_release);
  myfputs (fp, "FILEFLAGSMASK 0x3fL\n");
  myfputs (fp, "#ifdef _DEBUG\n");
  myfputs (fp, "FILEFLAGS VS_FF_DEBUG\n");
  myfputs (fp, "#else\n");
  myfputs (fp, "FILEFLAGS 0x0L\n");
  myfputs (fp, "#endif\n");
  myfputs (fp, "FILEOS VOS__WINDOWS32\n");
  myfputs (fp, "FILETYPE VFT_DLL\n");
  myfputs (fp, "FILESUBTYPE VFT2_UNKNOWN\n");
  myfputs (fp, "BEGIN\n");
  myfputs (fp, "  BLOCK \"StringFileInfo\"\n");
  myfputs (fp, "  BEGIN\n");
  myfputs (fp, "          BLOCK \"040904b0\"\n");
  myfputs (fp, "          BEGIN\n");
  myfputs (fp, "                VALUE \"Comments\", \"%s\\0\"\n", version_comment);
  myfputs (fp, "                VALUE \"CompanyName\", \"%s\\0\"\n", version_companyname);
  myfputs (fp, "                VALUE \"FileDescription\", \"%s\\0\"\n", version_filedescription);
  myfputs (fp, "                VALUE \"FileVersion\", \"%s\\0\"\n", version_versionstring);
  myfputs (fp, "                VALUE \"InternalName\", \"%s\\0\"\n", version_internalname);
  myfputs (fp, "                VALUE \"LegalCopyright\", \"%s\\0\"\n", version_legalcopyright);
  myfputs (fp, "                VALUE \"LegalTrademarks\", \"%s\\0\"\n", version_legaltrademarks);
  myfputs (fp, "                VALUE \"OriginalFilename\", \"%s\\0\"\n", version_originalfilename);
  myfputs (fp, "                VALUE \"PrivateBuild\", \"%s\\0\"\n", version_privatebuild);
  myfputs (fp, "                VALUE \"ProductName\", \"%s\\0\"\n", version_productname);
  myfputs (fp, "                VALUE \"ProductVersion\", \"%s\\0\"\n", version_versionstring);
  myfputs (fp, "                VALUE \"SpecialBuild\", \"%s\\0\"\n", version_specialbuild);
  myfputs (fp, "          END\n");
  myfputs (fp, "  END\n");
  myfputs (fp, "  BLOCK \"VarFileInfo\"\n");
  myfputs (fp, "  BEGIN\n");
  myfputs (fp, "          VALUE \"Translation\", 0x409, 1200\n");
  myfputs (fp, "  END\n");
  myfputs (fp, "END\n");
 
  fclose (fp); // finished, close the file
 
  printf ("Resource file generated successfully.\n"); // reassure the end user...
  return (0); // ...and go away!
 
PrintUsageAndExit:
  // this code is only reached when something went wrong
  printf ("%s - Project resource file generator\n", argv[0]);
  printf ("\tby Pierre-Marie Baty <pm@bots-united.com>\n");
  printf ("\n");
  printf ("Usage: %s\t[-t\"Comment\"] [-c\"Company Name\"] [-d\"File Description\"]\n", argv[0]);
  printf ("\t[-i\"Internal Name\"] [-l\"Legal Copyright\"] [-m\"Legal Trademarks\"]\n");
  printf ("\t[-o\"Original Filename\"] [-p\"Private Build\"] [-n\"Product Name\"]\n");
  printf ("\t[-s\"Special Build\"] filename.rc\n");
  printf ("\n");
  printf ("\t\tGenerates a resource file using the specified parameters.\n");
  printf ("\n");
  printf ("\t%s {-h|-?|/h|/?|--help|/help}\n", argv[0]);
  printf ("\n");
  printf ("\t\tPrints this help text and program usage.\n");
  printf ("\n");
  printf ("The purpose of this program is to be called in the \"Pre-Build Step\" state of\n");
  printf ("your project compilation so as to generate an updated resource file featuring\n");
  printf ("an automatically updated version number, along with several other optional\n");
  printf ("parameters. It is particularly useful with IDEs where no resource editors are\n");
  printf ("available, such as Borland or MingW32. It can also be used with MSVC to always\n");
  printf ("keep your executable version numbers up to date.\n");
  printf ("\n");
  printf ("The version number string and DWORD are generated automatically by the program\n");
  printf ("according to the YYYYMMDD convention (year - month - day), as in \"20040228\".\n");
 
  return (1); // exit with an error condition
}

Put it in C:\Program Files\Microsoft Visual Studio\VC98\BIN and call it before each compilation (using a batch file or whatever)... you can also specify all the fields you want in the version tab from the command line !

I really love wasting my time, don't you think so ? :D


All times are GMT +2. The time now is 01:46.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.