Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
genwindef.cpp
Go to the documentation of this file.
1 //$Id: genconf.cpp,v 1.35 2008/10/15 21:51:24 marcocle Exp $ //
2 
3 #ifdef _WIN32
4  // Disable a warning in Boost program_options headers:
5  // inconsistent linkage in program_options/variables_map.hpp
6  #pragma warning ( disable : 4273 )
7  #define popen _popen
8  #define pclose _pclose
9  #define fileno _fileno
10  #include <stdlib.h>
11 #endif
12 
13 // Include files----------------------------------------------------------------
14 #include <vector>
15 #include <string>
16 #include <iostream>
17 #include <fstream>
18 #include "LibSymbolInfo.h"
19 
20 using namespace std;
21 
22 namespace windef {
23  void usage(){
24  cerr << "Usage: genwindef [-l <dllname>] [-o <output-file> | exports.def] <obj or lib filenames>" << endl;
25  exit(1);
26  }
27 }
28 
29 //--- Command main program-----------------------------------------------------
30 int main ( int argc, char** argv )
31 //-----------------------------------------------------------------------------
32 {
33  string outfile("exports.def");
34  string library("UnknownLib");
35  string objfiles;
36  bool debug(false);
37 
38  int arg;
39  if (argc < 3) windef::usage();
40  arg = 1;
41  while (argv[arg][0] == '-') {
42  if (strcmp(argv[arg], "--") == 0) {
43  windef::usage();
44  }
45  else if (strcmp(argv[arg], "-l") == 0) {
46  arg++;
47  if (arg == argc) windef::usage();
48  library = argv[arg];
49  }
50  else if (strcmp(argv[arg], "-o") == 0) {
51  arg++;
52  if (arg == argc) windef::usage();
53  outfile = argv[arg];
54  }
55  arg++;
56  }
57  if (arg == argc) windef::usage();
58  for (arg; arg < argc; arg++) {
59  objfiles += argv[arg];
60  if( arg+1 < argc) objfiles += " ";
61  }
62 
63  CLibSymbolInfo libsymbols;
64  ofstream out(outfile.c_str());
65  if(out.fail()) {
66  cerr << "windef: Error opening file " << outfile << endl;
67  return 1;
68  }
69  out << "LIBRARY " << library << endl;
70  out << "EXPORTS" << endl;
71 
72  libsymbols.DumpSymbols(const_cast<char*>(objfiles.c_str()), out);
73 
74  out.close();
75 
76 
77  return 0;
78 }
79 
80 
81