views:

121

answers:

1

Hello!

I'm trying to compile a PHP extension in VS2008. It is dependent on 3 other projects which I link statically. It used to work fine when I had all my code in one .cpp file. I separated the code into several files to make it more manageable and now it won't compile.

I'm getting several (~100 per file) linker errors, LNK2005 (already defined). All of them are runtime library related I think.

So far I've tried

  • Clean rebuild.
  • Made sure the /MTd flag is the same on all 4 projects.
  • Made sure that all headers are guarded.

Any ideas?

EDIT: Here are some of the errors: Some errors:

MPQBlock.obj : error LNK2005: _getwchar already defined in MPQArchive.obj
MPQBlock.obj : error LNK2005: _putwchar already defined in MPQArchive.obj
MPQBlock.obj : error LNK2005: _acosl already defined in MPQArchive.obj
MPQBlock.obj : error LNK2005: _asinl already defined in MPQArchive.obj
etc.
MPQFile.obj : error LNK2005: _asinf already defined in MPQArchive.obj
MPQFile.obj : error LNK2005: _atanf already defined in MPQArchive.obj
MPQFile.obj : error LNK2005: _atan2f already defined in MPQArchive.obj
MPQFile.obj : error LNK2005: _ceilf already defined in MPQArchive.obj
MPQFile.obj : error LNK2005: _cosf already defined in MPQArchive.obj
etc.
PHPExtension.obj : error LNK2005: _acosl already defined in MPQArchive.obj
PHPExtension.obj : error LNK2005: _asinl already defined in MPQArchive.obj
PHPExtension.obj : error LNK2005: _atanl already defined in MPQArchive.obj
PHPExtension.obj : error LNK2005: _atan2l already defined in MPQArchive.obj
etc.
zlibd.lib(zutil.obj) : warning LNK4217: locally defined symbol _malloc imported in function _zcalloc
zlibd.lib(zutil.obj) : warning LNK4217: locally defined symbol _free imported in function _zcfree
D:\Server\PHP\ext\php_mpq_library.dll : fatal error LNK1169: one or more multiply defined symbols found
A: 

change the order of the link libraries that might help... can you post the some errors... it will make picture more clearer...

  1. click Settings.
  2. click to select the project configuration that is getting the link errors.
  3. On the Link tab, click to select Input in the Category combo box.
  4. In the Ignore libraries box, insert the library names (for example, Nafxcwd.lib;Libcmtd.lib).

    Note The linker command-line equivalent in /NOD:.

  5. In the Object/library modules box, insert the library names. You must make sure that these are listed in order and as the first two libraries in the line (for example, Nafxcwd.lib Libcmtd.lib).
mihirpmehta
I edited the question and included some errors.
Zeta Two