View Full Version: Code Compilation

ivan >>Programming >>Code Compilation


<< Prev | Next >>

TheFallenOne222- 04-05-2005
Code Compilation
This is frustrating me to no end. I know it's something simple, but I just can't get it. I'm sure I'll figure it out as soon as I actually get some sleep, but until then... Help! :P Anyways, I'm attempting to get the code to compile in Microsoft Visual Studio 6 (.NET doesn't like the code too much, and I prefer VS over other compilers. Still not completely sure why.), and I keep getting these linking errors: Linking... charset.obj : error LNK2001: unresolved external symbol "public: static void __cdecl databasecreator<class character>::InstallDataBase(class character *,int)" (?InstallDataBase@?$databasecreator@Vcharacter@@@@SAXPAVcharacter@@H@Z) charset.obj : error LNK2001: unresolved external symbol "public: static int __cdecl databasecreator<class character>::CreateDivineConfigurations(class characterprototype const *,struct characterdatabase * *,int)" (?CreateDivineConfigurations@?$datab asecreator@Vcharacter@@@@SAHPBVcharacterprototype@@PAPAUcharacterdatabase@@H@Z) charsset.obj : error LNK2001: unresolved external symbol "public: static void __cdecl databasecreator<class character>::FindDataBase(struct characterdatabase const * &,class characterprototype const *,int)" (?FindDataBase@?$databasecreator@Vcharacte r@@@@SAXAAPBUcharacterdatabase@@PBVcharacterprototype@@H@Z) itemset.obj : error LNK2001: unresolved external symbol "public: static void __cdecl databasecreator<class item>::InstallDataBase(class item *,int)" (?InstallDataBase@?$databasecreator@Vitem@@@@SAXPAVitem@@H@Z) itemset.obj : error LNK2001: unresolved external symbol "public: static int __cdecl databasecreator<class item>::CreateDivineConfigurations(class itemprototype const *,struct itemdatabase * *,int)" (?CreateDivineConfigurations@?$databasecreator@Vite m@@@@SAHPBVitemprototype@@PAPAUitemdatabase@@H@Z) levelset.obj : error LNK2001: unresolved external symbol "protected: class glterrain * __thiscall contentscripttemplate<class glterrain>::BasicInstantiate(int)const " (?BasicInstantiate@?$contentscripttemplate@Vglterrain@@@@IBEPAVglterrain@@H@Z) levelset.obj : error LNK2001: unresolved external symbol "public: static void __cdecl databasecreator<class olterrain>::InstallDataBase(class olterrain *,int)" (?InstallDataBase@?$databasecreator@Volterrain@@@@SAXPAVolterrain@@H@Z) levelset.obj : error LNK2001: unresolved external symbol "public: static void __cdecl databasecreator<class glterrain>::InstallDataBase(class glterrain *,int)" (?InstallDataBase@?$databasecreator@Vglterrain@@@@SAXPAVglterrain@@H@Z) levelset.obj : error LNK2001: unresolved external symbol "public: static int __cdecl databasecreator<class olterrain>::CreateDivineConfigurations(class olterrainprototype const *,struct olterraindatabase * *,int)" (?CreateDivineConfigurations@?$data basecreator@Volterrain@@@@SAHPBVolterrainprototype@@PAPAUolterraindatabase@@H@Z) materset.obj : error LNK2001: unresolved external symbol "public: static void __cdecl databasecreator<class material>::InstallDataBase(class material *,int)" (?InstallDataBase@?$databasecreator@Vmaterial@@@@SAXPAVmaterial@@H@Z) materset.obj : error LNK2001: unresolved external symbol "public: static void __cdecl databasecreator<class material>::FindDataBase(struct materialdatabase const * &,class materialprototype const *,int)" (?FindDataBase@?$databasecreator@Vmaterial@@@ @SAXAAPBUmaterialdatabase@@PBVmaterialprototype@@H@Z) Main/Release/Main.exe : fatal error LNK1120: 11 unresolved externals Error executing link.exe. I'm pretty sure I've included all needed libraries and other important files, but I just can't figure out what's wrong. I've tried almost everything. Help?

Atomic- 04-05-2005

You're right, .NET doesn't like it. I'm having issues too; in a certain file (not sure which one) a variable is redeclared. Also it has issues with overloading all kinds of math functions, mostly fabs() and sqrt(). The redeclared varible is blatant: something like for(int c; c < /*something*/; c++) { /*some code*/ int x, c; /*more code*/ }

TheFallenOne222- 04-05-2005

I know. I switched to VS 6 and it didn't give me that error though, so I'm not sure what's going on. Something is... strange. :P

holybanana- 04-06-2005

This is most puzzling. VS 5 and gcc compile IVAN fine, and these errors seem odd, as these template functions are explicitly instantiated, for instance the errors about InstallDataBase should be avoided by these lines at the end of database.cpp: #define INST_INSTALL_DATABASE(type)\ template void databasecreator<type>::InstallDataBase(type*, int) INST_INSTALL_DATABASE(material); INST_INSTALL_DATABASE(character); INST_INSTALL_DATABASE(item); INST_INSTALL_DATABASE(glterrain); INST_INSTALL_DATABASE(olterrain); Without these lines I get the same errors. Is dataset.cpp surely compiled? Well, most likely if not, much more errors would be caused. Are we doing the explicit instantiation somehow wrong? :( You could try trial and error, removing or altering these lines somehow, or moving them to database.h. This may cause only yet more errors, however. It is problematic I don't have access to VS 5. It is truly annoying the C++ standard about templates is not perfectly supported in any major compiler, there are always bugs, for instance the export keyword is never supported. :(

TheFallenOne222- 04-06-2005

Well, it seems that the newer the Microsoft compiler is, the more problems it causes, so I'll try just using GCC to compile it and hope it works. Microsoft has never been too good for making problem-free code. :P And yes, dataset.cpp is compiled, and I've tried modifying all sorts of possible problem-causing code, but nothing helped. Hopefully GCC fixes things.

holybanana- 04-06-2005

I believe la-*test*-('") VC versions have no prob in compiling normal function and class templates which are fully defined in headers, but member function templates have never worked, and this problem shows they don't fully support templates declared in a header but defined and instantiated only in a compilation unit. The la-*test*-('") MinGW should be a good GCC choice for everyone using Windows whatever. You can still use VS for project handling and editing, if you like it... If I ever get access to VC6, I'll do my best to fix these problems, but until then stick to GCC.

TheFallenOne222- 04-07-2005

I downloaded MinGW and tried it out, and am still running into this problem as it's compiling the .exe: ../lib/gcc/mingw32/3.4.2/../../..\SDLmain.lib(./Release/SDL_win32_main.obj)(.tex t<_main>+0x0):C:\public_cvs\SDL-: multiple definition of `main' ../lib/gcc/mingw32/3.4.2/../../../libmingw32.a(main.o)(.text+0x0): first defined here Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MS VCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized ../lib/gcc/mingw32/3.4.2/../../..\SDLmain.lib(./Release/SDL_win32_main.obj)(.tex t<_main>+0x55):C:\public_cvs\SDL-: undefined reference to `_alloca_probe' ../lib/gcc/mingw32/3.4.2/../../..\SDLmain.lib(./Release/SDL_win32_main.obj)(.tex t<_WinMain@16>+0x162):C:\public_cvs\SDL-: undefined reference to `_alloca_probe' ../lib/gcc/mingw32/3.4.2/../../..\SDLmain.lib(./Release/SDL_win32_main.obj)(.tex t<_WinMain@16>+0x1a5):C:\public_cvs\SDL-: undefined reference to `_alloca_probe' collect2: ld returned 1 exit status mingw32-make: *** Error 1 Looks like something is wrong with my SDL install. I'll try to fix it myself, but if anyone else can give me pointers in the right direction, I'd appreciate it. Not sure why I can't figure these problems out on my own, I'm usually good at this kind of thing. :?

Atomic- 04-07-2005

My current problems with MVCN is with math.h functions. I tired of the redeclaring of int c; just changed that to a 'b' and it ignored it. However it's also going nuts on math functions: every call to fabs() or sqrt() are called "ambigous calls to overloaded operators". I don't konw a whole lot about error messages because I usually don't get them, so I don't know what that means. Everything I can see though points at everything being right in the calls... An example: void wsquare::CalculateLuminance() { double T = log(1. + [b]fabs(GetWorldMap()->GetAltitude(Pos)) / 500.)[/b]; int Element = Min((128 - int(37.5 * T)), 255); Luminance = MakeRGB24(Element, Element, Element); } Error I get: c:\Documents and Settings\Support\My Documents\Visual Studio Projects\ivan-0.50\Main\Source\wsquare.cpp(171): error C2668: 'fabs' : ambiguous call to overloaded function I'd like to get this to compile for me so I can code at school, and -*test*-('") my code...

holybanana- 04-07-2005

If the parameter is an integer like in the code you pasted, replace fabs by abs. If this doesn't work, replace fabs(something) with fabs(double(something)) and so on for other functions. Let's hope it compiles. :?

Atomic- 04-07-2005

I changed everything to fabs(double(etc)) in the entire code, and it fixed a lot of warnings and errors. Hoewver I've got one left: Main fatal error LNK1181: cannot open input file 'SDL.lib'

TheFallenOne222- 04-07-2005

I changed everything to fabs(double(etc)) in the entire code, and it fixed a lot of warnings and errors. Hoewver I've got one left: Main fatal error LNK1181: cannot open input file 'SDL.lib' You need to install the SDL library. http://libsdl.org And once you fix that one, I'm pretty sure you'll end up with a bunch more warnings/errors. Fun stuff. :P

Atomic- 04-07-2005

Downloading SDL was the first thing I did.... Hmm. I geuss i could try again. I downloaded the source files, not the .dll, becaues I saw that SDL.h was included in some of the IVAN source. Do I need to get the .dll or something?

TheFallenOne222- 04-07-2005

Downloading SDL was the first thing I did.... Hmm. I geuss i could try again. I downloaded the source files, not the .dll, becaues I saw that SDL.h was included in some of the IVAN source. Do I need to get the .dll or something? You need the source files. Did you remember to add the needed directories to the VS include/lib directories?

Atomic- 04-07-2005

Of course. It finds SDL.h and all the other stuff; only issue is that SDL.lib seems to be missing. I can't even find it when I hunt for myself. What version of SDL do I need? I d/led 1.2.8.

TheFallenOne222- 04-07-2005

Not completely sure. Either way, it doesn't look like it's going to work without a bunch more major code changes. I tried setting it up in .NET, and fixed up everything you did, and now I'm back to linking errors. Linking... charset.obj : error LNK2019: unresolved external symbol "public: static int __cdecl globalwindowhandler::GetKey(int)" (?GetKey@globalwindowhandler@@SAHH@Z) referenced in function "protected: void __thiscall character::GetPlayerCommand(void)" (?GetPlayerCommand@character@@IAEXXZ) game.obj : error LNK2001: unresolved external symbol "public: static int __cdecl globalwindowhandler::GetKey(int)" (?GetKey@globalwindowhandler@@SAHH@Z) FeLib.lib(felist.obj) : error LNK2001: unresolved external symbol "public: static int __cdecl globalwindowhandler::GetKey(int)" (?GetKey@globalwindowhandler@@SAHH@Z) FeLib.lib(feio.obj) : error LNK2001: unresolved external symbol "public: static int __cdecl globalwindowhandler::GetKey(int)" (?GetKey@globalwindowhandler@@SAHH@Z) charset.obj : error LNK2019: unresolved external symbol "public: static int __cdecl globalwindowhandler::ReadKey(void)" (?ReadKey@globalwindowhandler@@SAHXZ) referenced in function "public: virtual void __thiscall character::Be(void)" (?Be@character@@UAEXXZ) FeLib.lib(feio.obj) : error LNK2001: unresolved external symbol "public: static int __cdecl globalwindowhandler::ReadKey(void)" (?ReadKey@globalwindowhandler@@SAHXZ) FeLib.lib(felist.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl graphics::BlitDBToScreen(void)" (?BlitDBToScreen@graphics@@SAXXZ) FeLib.lib(feio.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl graphics::BlitDBToScreen(void)" (?BlitDBToScreen@graphics@@SAXXZ) game.obj : error LNK2019: unresolved external symbol "public: static void __cdecl graphics::BlitDBToScreen(void)" (?BlitDBToScreen@graphics@@SAXXZ) referenced in function "public: static void __cdecl game::BusyAnimation(class bitmap *)" (?BusyAnimation@game@@SAXPAVbitmap@@@Z) igraph.obj : error LNK2001: unresolved external symbol "public: static void __cdecl graphics::BlitDBToScreen(void)" (?BlitDBToScreen@graphics@@SAXXZ) levelset.obj : error LNK2001: unresolved external symbol "public: static void __cdecl graphics::BlitDBToScreen(void)" (?BlitDBToScreen@graphics@@SAXXZ) FeLib.lib(bitmap.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl graphics::BlitDBToScreen(void)" (?BlitDBToScreen@graphics@@SAXXZ) iconf.obj : error LNK2019: unresolved external symbol "public: static void __cdecl graphics::SwitchMode(void)" (?SwitchMode@graphics@@SAXXZ) referenced in function "private: static void __cdecl ivanconfig::FullScreenModeChanger(struct truthoption *,int)" (?FullScreenModeChanger@ivanconfig@@CAXPAUtruthoption@@H@Z) igraph.obj : error LNK2019: unresolved external symbol "public: static void __cdecl graphics::SetMode(char const *,char const *,struct v2,int)" (?SetMode@graphics@@SAXPBD0Uv2@@H@Z) referenced in function "public: static void __cdecl igraph::Init(void)" (?Init@igraph@@SAXXZ) main.obj : error LNK2019: unresolved external symbol "private: static int (__cdecl* globalwindowhandler::QuitMessageHandler)(void)" (?QuitMessageHandler@globalwindowhandler@@0P6AHXZA) referenced in function "public: static void __cdecl globalwindowhandler::SetQuitMessageHandler(int (__cdecl*)(void))" (?SetQuitMessageHandler@globalwindowhandler@@SAXP6AHXZ@Z) SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main .\Main/Release/Main.exe : fatal error LNK1120: 7 unresolved externals If I could get it compiled in at least ONE program (Even MinGW doesn't seem to be working for me...), I'd be set.

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.