Re: [osg-users] osgDB ifstream / ofstream conflict

305 views
Skip to first unread message

Florian Kolbe

unread,
Sep 26, 2013, 11:56:49 AM9/26/13
to osg-...@lists.openscenegraph.org
Hi,

I am now running against the same issue.
I checked to see that everything is compiled with /MD.
I'm trying to build osg 3.2.0 x64 with VS2012

- 3rd-Party Binaries from: www.helleboreconsulting.com/index.php/open-source/openscenegraph
- OSG built by myself
- my project runs into:


Code:
4>* CIL library *(* CIL module *) : error LNK2005: "public: void __cdecl std::basic_ifstream<char,struct std::char_traits<char> >::close(void)" (?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ) already defined in osgDBrd.lib(osg100-osgDBrd.dll)
4>* CIL library *(* CIL module *) : error LNK2005: "public: void __cdecl std::basic_ofstream<char,struct std::char_traits<char> >::close(void)" (?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ) already defined in osgDBrd.lib(osg100-osgDBrd.dll)
4>..\..\..\setup\bin\sphinx-api3d-lib.dll : fatal error LNK1169: one or more multiply defined symbols found



Interestingly - it is again osgDB...

Regards,
Florian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56501#56501





_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Sebastian Messerschmidt

unread,
Sep 26, 2013, 4:20:30 PM9/26/13
to osg-...@lists.openscenegraph.org, Florian Kolbe
Hi Florian,

You can get around the fatal error by adding /FORCE: MULTIPLE to your
linker options.
This seems to be some odd VS2010 and beyond conformance problem.

Basically I get this error in almost any application linking to osgDB
and using fstream. It is somehow related to the derived stream class and
its virtual functions.

cheers
Sebastian

Braden Edmunds

unread,
Sep 26, 2013, 4:17:58 PM9/26/13
to osg-...@lists.openscenegraph.org
I had the same problem with VS2010 and there are two ways to get around it.

1. Use /FORCE:multiple
2. Create a typdef:


Code:

#pragma once

// Compatibility layer for VS2010 bug. The compiler tries to link the same
// multiple symbols in for the OSG fstream classes which inherit from the STL
// classes. The workaround is to use OSG fstream classes in all places rather
// than STL.

#ifdef WIN32

// Replace STL fstream with OSG fstream
#include <osgDB/fstream>
#define ifstream osgDB::ifstream
#define ofstream osgDB::ofstream

#else

#include <fstream>
#define ifstream std::ifstream
#define ofstream std::ofstream




Cheers,
Braden

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56510#56510

Florian Kolbe

unread,
Oct 1, 2013, 5:14:03 AM10/1/13
to osg-...@lists.openscenegraph.org
Hi,

so far, "/FORCE:multiple" has worked for me.

Thank you!

Cheers,
Florian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56555#56555
Reply all
Reply to author
Forward
0 new messages