Making Visual C++ Express code work (was whirly particles)

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
User avatar
Mr Dom
Baaaaa!
Baaaaa!
Posts: 1375
Joined: Fri Dec 03, 2004 3:03 pm 0
Location: Cardiff

Post by Mr Dom »

These errors are due to the way the runtime is compiled into the code...

msvcrt.lib = stub for the Multi-threaded DLL version
libcmt.lib = static multitheaded runtime lib

Unlike other libs, the compiler tags eachobject file/library with the runtime version. if you try linking several libs which use different runtime versions, then they clash.

The solution is to make sure ALL the libs you build with use the same settings.

However, when linking to pre-built libs you canot chage the settings. This is what the NODEFAULTLIB stting is for.

Try '/NODEFAULTLIB:msvcrt.lib' which should let it use the LIBCMT.lib version (static) only.

PS: From the errors it looks like you have the run-time type info setting on. Unless you use dynamic_cast (which is naughty) then you can disable this in all the various builds.
- Dom
Play Games
<Haircuts are for wimps!>
User avatar
kel
Baaaaaa!
Baaaaaa!
Posts: 2461
Joined: Thu Oct 02, 2003 1:29 pm 0
Location: england

Post by kel »

I'd tried that already, I added msvcrt.lib to the ignore specific library field and got this:

Code: Select all

Generating Code...
Linking...
SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol _exit imported in function _main
SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol _strrchr imported in function _main
SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol __iob imported in function _ShowError
SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol _fgetc imported in function _cleanup_output
SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol _fclose imported in function _cleanup_output
SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol _setvbuf imported in function _WinMain@16
SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol __pctype imported in function _ParseCommandLine
SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol ___mb_cur_max imported in function _ParseCommandLine
SDLmain.lib(SDL_win32_main.obj) : warning LNK4217: locally defined symbol __isctype imported in function _ParseCommandLine
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__strncpy referenced in function _main
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__remove referenced in function _cleanup_output
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__fopen referenced in function _cleanup_output
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__setbuf referenced in function _WinMain@16
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp__freopen referenced in function _WinMain@16
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp___getcwd referenced in function _WinMain@16
C:\Documents and Settings\blah\.exe : fatal error LNK1120: 7 unresolved externals
Mr Dom wrote: PS: From the errors it looks like you have the run-time type info setting on. Unless you use dynamic_cast (which is naughty) then you can disable this in all the various builds.
I've looked through the settings and can't find any info about that.
User avatar
Mr Dom
Baaaaa!
Baaaaa!
Posts: 1375
Joined: Fri Dec 03, 2004 3:03 pm 0
Location: Cardiff

Post by Mr Dom »

That looks like its not linking any run time lib at all.
Make sure all the projects have the multithreaded flag set (/MT), the only lib in the ignore list is the msvcrt.lib (NOT libcmt.lib)

If you have the SDL source then try rebuilding this.

For debug builds, you need /MTd, release builds /MT.
To specify the DLL version in command line, it is /MDd (debug) and /MD
(release). make sure you dont have both though!

The Run time type stuff (RTTI) is the flag /GR in VC6, so probably the same for the express. If its there, you should be able to remove it with few problems.
- Dom
Play Games
<Haircuts are for wimps!>
User avatar
kel
Baaaaaa!
Baaaaaa!
Posts: 2461
Joined: Thu Oct 02, 2003 1:29 pm 0
Location: england

Post by kel »

Cheers Dom, I'll have to get the Direct X sdk to compile SDL but I'll give it a go as soon as I can.

Thanks again for clearing up the /MT /MD stuff.
Post Reply