I am creating a basic web testing tool that sends HTTP requests, comparing results sent at different times.
Anyway, I am also trying to get into creating header files etc. The program has the following structure among other header and CPP files I got from a sample online somewhere that does the HTTP stuff. I am essentially building a testing framework around it. Anyway here goes...
Header Files:
test.h
Source Files:
test.cpp
main.cpp
test.h
1 2 3 4 5 6 7 8 9 10 11
#ifndef RECORD_H_
#define RECORD_H_
namespace test{
class record {
public:
staticint recordTest(const string test1, const string test2);
};
}
#endif
When compiling, compilation works but linking fails as follows:
1>main.obj : error LNK2019: unresolved external symbol "public: static int __cdecl test::record::recordTest(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?recordTest@record@test@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) referenced in function _main
1>.\Debug/httpCheck.exe : fatal error LNK1120: 1 unresolved externals
I've looked around the web and found different things regarding settings the system / subsystem in the linker options and also adding DDLs to the compiler options but I don't think these are relevent and also didn't work.
When you define recordTest(), you have to write which class it belongs to. That is int record::recordTest(const string test1, const string test2){//...
From looking at a few other things online the problem may be due to the sample mentioned above being converted to the 2008 VS format. No idea what the problem could be or how to fix it though...