# Help with some C++ compilation stuff

**URL:** https://boards.straightdope.com/t/help-with-some-c-compilation-stuff/196785
**Category:** Factual Questions
**Created:** [August 21, 2003, 10:12pm UTC](https://boards.straightdope.com/t/help-with-some-c-compilation-stuff/196785 "2003-08-21T22:12:52Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Trigonal\_Planar](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@Trigonal\_Planar](https://boards.straightdope.com/u/Trigonal_Planar)
#### Post date: [August 21, 2003, 10:12pm UTC](https://boards.straightdope.com/t/help-with-some-c-compilation-stuff/196785/1 "2003-08-21T22:12:52Z")

</div>

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:

EXAMPLE RELEASE (works)

/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

* * *

TEST RELEASE (works)

/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)

---

<div class="post-metadata">

### Author: ![ForbiddenFruitsalad](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@ForbiddenFruitsalad](https://boards.straightdope.com/u/ForbiddenFruitsalad)
#### Post date: [August 21, 2003, 10:22pm UTC](https://boards.straightdope.com/t/help-with-some-c-compilation-stuff/196785/2 "2003-08-21T22:22:48Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![DarrenS](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@DarrenS](https://boards.straightdope.com/u/DarrenS)
#### Post date: [August 21, 2003, 10:37pm UTC](https://boards.straightdope.com/t/help-with-some-c-compilation-stuff/196785/3 "2003-08-21T22:37:46Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![Krillan](https://avatars.discourse-cdn.com/v4/letter/k/5fc32e/32.png) [@Krillan](https://boards.straightdope.com/u/Krillan)
#### Post date: [August 21, 2003, 10:43pm UTC](https://boards.straightdope.com/t/help-with-some-c-compilation-stuff/196785/4 "2003-08-21T22:43:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Trigonal\_Planar](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@Trigonal\_Planar](https://boards.straightdope.com/u/Trigonal_Planar)
#### Post date: [August 21, 2003, 11:02pm UTC](https://boards.straightdope.com/t/help-with-some-c-compilation-stuff/196785/5 "2003-08-21T23:02:33Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ForbiddenFruitsalad](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@ForbiddenFruitsalad](https://boards.straightdope.com/u/ForbiddenFruitsalad)
#### Post date: [August 21, 2003, 11:54pm UTC](https://boards.straightdope.com/t/help-with-some-c-compilation-stuff/196785/6 "2003-08-21T23:54:12Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![Dave\_D](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@Dave\_D](https://boards.straightdope.com/u/Dave_D)
#### Post date: [August 22, 2003, 1:24pm UTC](https://boards.straightdope.com/t/help-with-some-c-compilation-stuff/196785/7 "2003-08-22T13:24:06Z")

</div>

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.)
