I'm having trouble resolving this issue around my vectors and strings. I've created a class for reading shaders (OpenGL), but currently not using it anywhere within my program. The problem is when I test my application, I still get an error. The function where I've narrowed down the error is below and if I comment-out the the lines, my application runs as expected (uncommenting lines in relation to sProgram
causes error:
#define FOR(q, n) for (int q = 0; q < n; q++)
#define SFOR(q, s, e) for (int q = s; q <= e; q++)
#define RFOR(q, n) for (int q = n; q >= 0; q--)
#define RSFOR(q, s, e) for (int q = s; q >= e; q--)
#define ESZ(elem) (int)elem.size()
...
...
bool GLShader::LoadShader(string sFile, int a_iType)
{
FILE* fp = fopen(sFile.c_str(), "rt");
if (!fp)
return false;
// Get all lines from a file
vector<string> sLines;
char sLine[255];
while (fgets(sLine, 255, fp))
sLines.push_back(sLine);
fclose(fp);
// const char** sProgram = new const char*[ESZ(sLines)]; <--- problem with sProgram
// FOR(i, ESZ(sLines))sProgram[i] = sLines[i].c_str();
uiShader = glCreateShader(a_iType);
// glShaderSource(uiShader, ESZ(sLines), sProgram, NULL);
glCompileShader(uiShader);
// delete[] sProgram; <--- Error
int iCompilationStatus;
glGetShaderiv(uiShader, GL_COMPILE_STATUS, &iCompilationStatus);
if (iCompilationStatus == GL_FALSE)
return false;
iType = a_iType;
bLoaded = true;
return 1;
}
This is the error I received:
Error 1 error LNK2019: unresolved external symbol __imp___CrtDbgReportW
referenced in function "public: class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > & __thiscall
std::vector<class std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> >,class std::allocator<class
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
> >::operator[](unsigned int)"
(??A?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?
$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std
@@@2@@std@@QAEAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@I@Z)
c:\Users\Me\documents\visual studio 2013\Projects\FooV1\FooV1\Bar.obj
And in the output:
1>------ Build started: Project: FooV1, Configuration: Debug Win32 ------
1> main.cpp
1>Bar.obj : error LNK2019: unresolved external
symbol __imp___CrtDbgReportW referenced in function "public: class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > & __thiscall std::vector<class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >,class std::allocator<class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > > >::operator[](unsigned int)"
(??A?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator
@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@@2@@std@@QAEAAV?$basic_string@DU?$char_traits
@D@std@@V?$allocator@D@2@@1@I@Z)
1>c:\users\Me\documents\visual studio 2013\Projects\FooV1\Debug\FooV1.exe :
fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========