(C++) Class for reading Windows-INI-like files
Hmm quite possibly could we get some code, or possibly just a .zip to download your work environment. And possibly an explanation of those linker errors you are getting. Or even better the exact linker errors copied from your IDE's console window. Thanks.Midnight wrote:how the hell do you make this thing work.
I keep getting linker errors from a couple ini functions and I tried to include it every way I know how.. including how the website describes.
yet I can't shake these damn linker errors... any ideas??
TheQuestion = 2B || !2B
well the code is the example on the website
the errors where with addsomething.. but it's how I'm linking I think.
I've tried #pragma.. I've tried adding inireader.lib as a dependancy.. you know the spot where irrlicht examples does irrlicht.lib.. I've tried without that also and just include the folder like irrlicht.
I've tried adding inireader.h and not adding it.. I've tried it all.
I'm using msvc express 2005.
seem to have misplaced my code I'll post again if needed when i find it.
the errors where with addsomething.. but it's how I'm linking I think.
I've tried #pragma.. I've tried adding inireader.lib as a dependancy.. you know the spot where irrlicht examples does irrlicht.lib.. I've tried without that also and just include the folder like irrlicht.
I've tried adding inireader.h and not adding it.. I've tried it all.
I'm using msvc express 2005.
seem to have misplaced my code I'll post again if needed when i find it.
these are the current errors.. I must have changed something it was something to do with getValue2Di or something before. going to try some other linker setups and see if I can get back to that point.1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strncmp already defined in LIBCMT.lib(strncmp.obj)
1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _atoi already defined in LIBCMT.lib(atox.obj)
1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
what is the proper way to link it though? #pragma?
additional dependancies?
do i include inireader in my project?
the website isn't very descriptive.
damn the lag sometimes is unbearable..
anyways I removed all except for the folder include and iinireader.h
and this is what i got.
I check one typo report myself and the code matched so what else is there and why hasn't it been updated?
anyways I removed all except for the folder include and iinireader.h
and this is what i got.
I don't really see any typo's in the code but I haven't gone over it all.. I'm using version 2.1 so I'm assuming thats the one with all the known fixes?1>Main.obj : error LNK2019: unresolved external symbol "public: class irr::core::dimension2d<int> __thiscall irr::io::IIniFileReader::SValue2Di::toDimension(void)" (?toDimension@SValue2Di@IIniFileReader@io@irr@@QAE?AV?$dimension2d@H@core@4@XZ) referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol "class irr::io::IIniFileReader * __cdecl irr::io::createIniFileReader(char const *,bool)" (?createIniFileReader@io@irr@@YAPAVIIniFileReader@12@PBD_N@Z) referenced in function _main
I check one typo report myself and the code matched so what else is there and why hasn't it been updated?
If I understand this linker error right you haven't linked the Irrlicht.lib.
Code: Select all
#pragma comment(lib, "Irrlicht.lib")and yet I have it right there
EDIT: and i just noticed i had ini->drop commented
on rebuild
Code: Select all
#include <Irrlicht.h>
#include <IIniFileReader.h>
using namespace irr;
using namespace io;
using namespace video;
#pragma comment(lib,"Irrlicht.lib")
//#pragma comment(lib,"IniReader.lib")
int main(int argc, char** argv)
{
irr::io::IIniFileReader* ini = createIniFileReader("Config.ini");
/*
if(!ini->load())
{
ini->drop();
// First we create an empty INI-File reader
ini = createIniFileReaderEmpty();
// now we fill the class with our default data
// first we create the section device
ini->addSection("device");
// and than we create the keys and assign them standard values
ini->addKeyToSection("device","antialias","true");
ini->addKeyToSection("device","bits","32");
ini->addKeyToSection("device","resolution","800x600");
ini->addKeyToSection("device","stencil","true");
ini->addKeyToSection("device","vsync","false");
ini->addKeyToSection("device","driver","edt_opengl");
// since our INI-File reader object is only stored in memory we
// have to save it to a file.
// to do so we first need to set a filename where to save
ini->setSaveFileName("Config.ini");
if(!ini->save())
{
ini->drop();
return 1;
}
}
*/
irr::SIrrlichtCreationParameters param;
param.AntiAlias = ini->getValueB("device","antialias");
param.Bits = ini->getValueI("device","bits");
param.Fullscreen = ini->getValueB("device","fullscreen");
param.Stencilbuffer = ini->getValueB("device","stencil");
param.Vsync = ini->getValueB("device","vsync");
param.WindowSize = ini->getValue2Di("device","resolution").toDimension();
param.DriverType = ini->getValueDrv("device","driver");
irr::IrrlichtDevice* device = createDeviceEx(param);
/* irr::IrrlichtDevice* device = irr::createDevice(irr::video::EDT_DIRECT3D9, irr::core::dimension2d<irr::s32>(800, 600), 16, false, false, false);
*/
irr::video::IVideoDriver* driver = device->getVideoDriver();
while(device->run())
{
//all engine rendering should happen here
if (device->isWindowActive())
{
driver->beginScene(true, true, irr::video::SColor(0,0,0,0));
driver->endScene();
}
}
//ini->drop();
device->closeDevice();
device->drop();
return 0;
}on rebuild
Code: Select all
1>Main.obj : error LNK2019: unresolved external symbol "public: class irr::core::dimension2d<int> __thiscall irr::io::IIniFileReader::SValue2Di::toDimension(void)" (?toDimension@SValue2Di@IIniFileReader@io@irr@@QAE?AV?$dimension2d@H@core@4@XZ) referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol "class irr::io::IIniFileReader * __cdecl irr::io::createIniFileReader(char const *,bool)" (?createIniFileReader@io@irr@@YAPAVIIniFileReader@12@PBD_N@Z) referenced in function _mainThe tutorials were full of typos. After MasterGod told me they were I fixed them.
The last two linker errors occur because you didn't link with inireader.lib.
If you set the dependencies it work fine for me.
Have you tried to set the Runtime Library to the same as your application uses?
The MSCV Projectfile that comes with the SDK is using Multithreaded (Debug) DLL. Try to set it to Multithreaded (Debug) if your application uses this runtime.
The last two linker errors occur because you didn't link with inireader.lib.
If you set the dependencies it work fine for me.
Have you tried to set the Runtime Library to the same as your application uses?
The MSCV Projectfile that comes with the SDK is using Multithreaded (Debug) DLL. Try to set it to Multithreaded (Debug) if your application uses this runtime.
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
1. Why comment?
2. Try not using it as an external lib, try adding all the source files (.h && .cpp) to the project and see if that helps.
P.S
If you try option #2 don't forget to remove that #pragma comment line.
Code: Select all
//#pragma comment(lib,"IniReader.lib") 2. Try not using it as an external lib, try adding all the source files (.h && .cpp) to the project and see if that helps.
P.S
If you try option #2 don't forget to remove that #pragma comment line.
bug:
replace
with
Code: Select all
CIniFileReaderStub::SValue3Di CIniFileReaderStub::getValue3Di(const c8* section, const c8 *key)
{
stringc str = getValue(section,key);
str.replace('x',' ');
SValue3Di v;
sscanf(str.c_str(),"%d %d %d",&v.Y,&v.Y,v.Z);
return v;
}Code: Select all
sscanf(str.c_str(),"%d %d %d",&v.Y,&v.Y,v.Z);sscanf(str.c_str(),"%d %d %d",&v.X,&v.Y,&v.Z);
ok so... after installing directx and rebuilding irrlicht in debug to be sure and doing all the fixes i noticed on this thread.. it compiles without error.
however when it runs it loads the first two console lines irrlicht prints out about the OS and hangs.. I'm assuming it's hanging on the createfilereader part but I'm not sure.
also I included it directly into my project to achieve this.
I'm going to try rebuilding the library with the fixes and see if that works possibly. also I forgot to mention I'm using irr 1.4
has anyone else gotten this to work with msvce2005?
however when it runs it loads the first two console lines irrlicht prints out about the OS and hangs.. I'm assuming it's hanging on the createfilereader part but I'm not sure.
also I included it directly into my project to achieve this.
I'm going to try rebuilding the library with the fixes and see if that works possibly. also I forgot to mention I'm using irr 1.4
has anyone else gotten this to work with msvce2005?
As you can see I have a long history with this code so yeah, I was able to compile it with vc8 and now that I use vc9 it compiles just fine too.
I used v1.4 and now latest revision and it works well with both versions of Irrlicht.
It also compiles on Linux and runs well so no problems there nor warnings after that last bug report few posts up.
I used v1.4 and now latest revision and it works well with both versions of Irrlicht.
It also compiles on Linux and runs well so no problems there nor warnings after that last bug report few posts up.
