错误 LNK2005 “public: __cdecl std::basic_ifstream<char,struct std::char_traits<char> >::basic_ifstream

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();
在这里插入图片描述
在这里插入图片描述

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值