OSG系列文章目录
前言
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 LNK2005 “public: __cdecl std::basic_ifstream<char,struct std::char_traits >::basic_ifstream<char,struct std::char_traits >(void)” (??0?
b
a
s
i
c
i
f
s
t
r
e
a
m
@
D
U
?
basic_ifstream@DU?
basicifstream@DU?char_traits@D@std@@@std@@QEAA@XZ) 已经在 osgDB.lib(osg141-osgDB.dll)
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 LNK2005 “public: void __cdecl std::basic_ifstream<char,struct std::char_traits >::open(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,int,int)” (?open@?
b
a
s
i
c
i
f
s
t
r
e
a
m
@
D
U
?
basic_ifstream@DU?
basicifstream@DU?char_traits@D@std@@@std@@QEAAXAEBV?
b
a
s
i
c
s
t
r
i
n
g
@
D
U
?
basic_string@DU?
basicstring@DU?char_traits@D@std@@V?$allocator@D@2@@2@HH@Z) 已经在 osgDB.lib(osg141-osgDB.dll)
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 LNK2005 “public: void __cdecl std::basic_ifstream<char,struct std::char_traits >::`vbase destructor’(void)” (??_D?
b
a
s
i
c
i
f
s
t
r
e
a
m
@
D
U
?
basic_ifstream@DU?
basicifstream@DU?char_traits@D@std@@@std@@QEAAXXZ) 已经在 osgDB.lib(osg141-osgDB.dll) 中定义
一、错误原因
因为在工程中使用了osgDB.lib库,osgDB.lib库中已经包含了basic_ifstream类,而我在工程中又包含了iostream,重复包含iostream头文件
include<Windows.h>
#include<iostream>
#include<fstream>
#include<map>
#include<omp.h>
#include<string>
#include<vector>
#include<algorithm>
#include<sstream>
#include<gdiplus.h>
#pragma comment(lib,"gdiplus.lib")
#include <osg/io_utils>
#include <osg/Node>
#include <osg/Geode>
#include <osg/Geometry>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osg/Vec3>
#include <osgViewer/Viewer>
#include <osgGA/TrackBallManipulator>
#include <osg/Texture2D>
#include <osg/Camera>
#include <direct.h>
#include <locale>
#include <codecvt>
#include "Ground_Calculate.h"
#include "MeshAnalyzer.h"
#include "myFindNodeVisitor.h"
#include "MyStruct.h"
#include "Shadow_mapping.h"
#include "SolarDirection.h"
#include "Scene_Calculate.h"
#include <math.h>
using namespace std;
using namespace Gdiplus;
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
二、解决办法
明确使用osgDB中的ifstrean和ofstream读写文件
osgDB::ifstream fin;
Color color;
osgDB::ofstream fout(outfilename.c_str());
fout.close();