Help with some C++ compilation stuff

I’m doing some experimenting with incorporating the MySQL api into a standard win32 console C++ project. I’m using the MSVC++ IDE.

I have two projects: One is the “Example” project that demonstrates the api. This project compiles just fine under Release mode but won’t work under Debug mode.

My second project is a “Test” project I created myself. Similarly, it will compile under Release but not under Debug.

Here are the compile options set for each project:


/nologo /MD /GX /O2 /I “e:/mysql++/include” /I “e:/mysql++/mysql/include” /D “WIN32” /D “NDEBUG” /D “_CONSOLE” /D “_MBCS” /Fp"Release/examples.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c

EXAMPLE DEBUG (no works)

/nologo /MLd /Gm /GX /ZI /Od /I “e:/mysql++/include” /I “e:/mysql++/mysql/include” /D “WIN32” /D “_DEBUG” /D “_CONSOLE” /D “_MBCS” /Fp"Debug/examples.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c


/nologo /ML /W3 /GX /O2 /I “e:/mysql++/include” /I “e:/mysql++/mysql/include” /D “WIN32” /D “NDEBUG” /D “_CONSOLE” /D “_MBCS” /Fp"Release/BasicSQL.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c

TEST DEBUG (no works)

/nologo /MLd /W3 /Gm /GX /ZI /Od /I “e:/mysql++/include” /I “e:/mysql++/mysql/include” /D “WIN32” /D “_DEBUG” /D “_CONSOLE” /D “_MBCS” /Fp"Debug/BasicSQL.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
I’m wondering if someone can look at these combinations and perhaps explain what might be happening?

(PS. In both cases my code is good, since they’ve both been successfully compiled and executed – just under weird settings that I don’t understand)

What’s the error message when it doesn’t work?

One idea: make sure you haven’t forgotten to include the proper libraries for both Debug and Release builds (it should still compile if that’s the problem, but the linker will complain).

Look at the project settings under Debug and Release - not all those settings are reflected in the command line compiler switches. My bet would be, the include paths are set differently for Debug than they are for Release (VC++ allows this).

DarrenS has a good point. The same happens with Borland too…

Sorry, yes, in both cases the file compiles; its linking that’s the problem.

The errors (there’s 40 of them) all consist of “(whatever) already defined in (something)”. (Something) being various LIBs and DLLs.

I’m looking under the C/C++ ==> Preprocessor dialogue and the settings (aside from the compile options, seen above) are identical. Where else should I look?

Check the linker settings, in particular what libraries you are linking with. Exact error messages will make it easier to narrow down the problem because they will show what symbols are leading to the problem (the first few errors should be enough).

I’d also check that you are linking to the appropriate C-Runtime in the debug build.(Since that can cause a whole hell alot of trouble in VC.)