ok, here's the deal, I'm working with a dll I've created that defines a number of classes and inherited functions for use with a command shell. The dll compiles fine, but when I compile the main file, with dll linked at compile time, it gives me the "<class/function name> does not name a type" error, replacing the class/function name with the classes and fucntions that arent being found
Here's the source code for the main file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <ctime>
#include <conio.h>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
using std::vector;
#ifndef USER
#define USER current_user
#endif /*USER_DEFINED*/
#ifndef L_HOST
#define L_HOST local_host
#endif /* L_HOST_DEFINED */
#ifndef DEF_TIMEOUT
#define DEF_TIMEOUT 120000
#endif /* Defalut timeout defined */
cmd start; //not naming a type
cmd loop; //still no type named
int main(void)
{
USER = default_user; //default_user not defined, but should be in the dll
L_HOST = default_host; //same here
start.login(); //errors due to the dll not being linked
while(!end)
{
loop.parseCmd(loop.prompt(DEF_TIMEOUT)); //same same
loop.execCmd(); //still
end = true; //and here too, not defined
}
system("PAUSE");
}
|
and here is the source code for the dll
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
#include <ctime>
#include <conio.h>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
using std::vector;
#ifndef USER
#define USER current_user
#endif /*USER_DEFINED*/
#ifndef L_HOST
#define L_HOST local_host
#endif /* L_HOST_DEFINED */
#ifndef DEF_TIMEOUT
#define DEF_TIMEOUT 120000
#endif /* Defalut timeout defined */
typedef char* user;
typedef char* host;
typedef int timer;
bool end;
timer tmPrompt;
char _in_pass[50];
user current_user;
host local_host;
host default_host = "Local.host";
user default_user = "User";
vector <char> console_in(1);
template <class prntclss> void con_out(prntclss &outString);
vector <char> con_in(bool alias) //Console input
{
int i,j;
i=1;
j = 0;
char ch;
while(j!=1)
{
ch=getch();
if(ch=='\r')
{
j = 1;
} if(ch=='\b')
{
con_out("\b ");
}
console_in.push_back(ch);
if(alias == true)
{
con_out("*");
if(ch=='\b')
{
con_out("\b ");
}
} else
PRINT:
con_out(ch);
i++;
}
return console_in;
}
template <class prntclss> void con_out(prntclss &outString)
{
std::cout << outString; //todo...fsking find something to replace this...
}
void preout(void)
{
printf("%s", USER);
printf( "%s", "@");
printf("%s", L_HOST);
printf( "! ");
}
class cmd{
int _return;
public:
vector<char> prompt(int timeOut)
{
//TODO test timer
for(tmPrompt = 0; tmPrompt <= timeOut+1; tmPrompt++)
{
if(tmPrompt==timeOut)
{
con_out("Are you still there?");
tmPrompt = 0;
}
preout();
con_in(false);
return con_in(false);
}
}
void login()
{
preout();
printf("%s", "Username:");
con_in(false);
preout();
printf("%s", "\nPassword:");
con_in(true);
}
int parseCmd(vector <char> cmdIn)
{
//TODO code rest of parse cmd
con_out("This is a test");
_return = 0;
}
void execCmd(int cmdcode)
{
//_return;
con_out("Again a test");
}
};
|
Yes I know that a lot of things go unused, this code isnt nearly complete yet.
I use the mingw command line compiler, and I use this command to link at compile time
gcc -L./ -lcmd main.cpp -o test.exe
exact errors are here:
main.cpp:33: error: `cmd' does not name a type
main.cpp:34: error: `cmd' does not name a type
main.cpp: In function `int main()':
main.cpp:38: error: `current_user' was not declared in this scope
main.cpp:38: error: `default_user' was not declared in this scope
main.cpp:39: error: `local_host' was not declared in this scope
main.cpp:39: error: `default_host' was not declared in this scope
main.cpp:41: error: `start' was not declared in this scope
main.cpp:42: error: `end' was not declared in this scope
main.cpp:44: error: `loop' was not declared in this scope
main.cpp:52:2: warning: no newline at end of file
----------------------
thusly I assume my dll isnt being linked. Both files are saved as .cpp, So if any one can help me understand why they arent being linked?