I run into the following error when using make. So, I compiled the same program at the command line to check if there was a problem in my C++ code, but it works perfectly fine at the commandline.
g++ -o Cmain.exe Cmain.o -lmysqlclient -lboost_date_time -L ../lib -L/usr/local/lib -L/usr/lib/mysql
./Cmain.exe
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
make: *** [Cmain.exe] Aborted
make: *** Deleting file `Cmain.exe'
Any suggestions on what might be causing this error and how it can be fixed.
Edit from the edited question, it now became clear that CMain.exe is not being executed, but rather being built.
The same story applies (see below), but I’ll post more relevant hints once there is more new information. Hang on
I can bet 80% that the program calls
std::getenvand doesn’t check the return value of null (0). If you then construct a std::string from it the reported exception is expected.
Search your source code for getenv(…) and replace code like, say:
by, e.g.
You can then use
s.empty()to see whether the variable had a value (you can no longer see whether it existed in the environment because std::string can not represent ‘null’ – only the empty string).PS.: Background/off-topic: