目录
异常弹窗
- 且有时弹窗后点击中止,程序并不会停止运行
问题定位
- 打断点debug缩小范围,然后发现是一句调用spdlog库生成log文件的代码引发:
- 百度得到了一些解析,这个问题是因为对象在析构时不正确的释放内存导致,且该问题只在使用了动态库才会有
解决办法
- 但spdlog内的代码显然不好去碰,而且这个问题是因为我们链接了spdlog的动态库才会有,那么我们可以使用它的header-only,也就是仅头文件,直接静态编译进入我们的程序,不使用它的动态库了。
- 由于我的项目是用cmake构建,在CMakeLists.txt中,将原来的 spdlog::spdlog 改为 spdlog::spdlog_header_only 即可。
- 然后就发现fmt也来这个问题,我真是吐了
- 那就再加一句,fmt::fmt-header-only 也使用静态编译的方式引入fmt库
最后
- 回顾这个问题,百度上也有博客说应当注意,编译生成动态库应尽量使用 /MD 和 /MDd,避免/MT和/MTd。动态库中避免函数传入参数或返回值使用 std::string 类型,应当使用 std::string& 或 [const] char*。
- 其次,这个问题和编译时的选项有关
- 如果程序和动态库都使用 /MD 编译,则不会有问题
- 如果动态库使用/MT编译,则程序和动态库各自有一个堆,假设我们的程序调用了一个动态库中的一个函数 std::string get(); 而这个string的内存是由动态库分配,但我们的程序并不能区分这个内存是程序的还是动态库的,当对象生命周期结束,就会由程序调用析构函数去释放内存,因此出错。
- 因此解决办法还可以是避免我们的程序去析构动态库返回的string。比如动态库中的函数返回全局变量。
What’s up to every one, the contents existing at this web page are truly remarkable for people knowledge,
well, keep up the nice work fellows.
Hi, the whole thing is going sound here and ofcourse every one is sharing data, that’s
actually excellent, keep up writing.
It’s awesome designed for me to have a web page, which is valuable in favor of my knowledge.
thanks admin
Hello there! This post couldn’t be written any better! Reading through this post reminds me of
my good old room mate! He always kept chatting about this.
I will forward this write-up to him. Pretty sure he will have a good read.
Thanks for sharing!
I every time emailed this weblog post page to all my associates, since if like to
read it next my friends will too.
My relatives all the time say that I am wasting my time here at web, but I know
I am getting experience all the time by reading such nice articles.
What’s up, every time i used to check webpage posts here in the early hours in the dawn, for the reason that i love to
find out more and more.
Your style is so unique compared to other folks I have read stuff from.
I appreciate you for posting when you have the opportunity, Guess I’ll just bookmark this site.
Sweet blog! I found it while surfing around on Yahoo News.
Do you have any tips on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!
Thanks
Highly energetic blog, I enjoyed that a lot. Will there be a
part 2?
There is certainly a great deal to find out about this issue.
I like all of the points you made.
I just could not depart your site before suggesting
that I extremely loved the usual info an individual provide on your guests?
Is gonna be back incessantly to check up on new
posts
I was suggested this blog by my cousin. I am not sure
whether this post is written by him as no one else know such detailed about my difficulty.
You are wonderful! Thanks!
Greetings from Carolina! I’m bored at work so I decided to check out your website on my iphone during lunch break.
I enjoy the information you provide here and can’t wait to take a look when I
get home. I’m shocked at how fast your blog loaded on my phone ..
I’m not even using WIFI, just 3G .. Anyhow, wonderful blog!
I love what you guys are usually up too. This kind of clever work and
exposure! Keep up the fantastic works guys I’ve included you guys to blogroll.
Hello there! I could have sworn I’ve been to
this site before but after checking through some of the post I realized it’s
new to me. Anyways, I’m definitely happy I found it and I’ll be bookmarking and checking back often!
You really make it seem so easy with your presentation but I find this matter to be really something that I
think I would never understand. It seems too complicated and very broad for me.
I’m looking forward for your next post, I’ll try to get the
hang of it!
Hello! This post could not be written any better! Reading through this post
reminds me of my old room mate! He always kept chatting about this.
I will forward this write-up to him. Pretty sure he will
have a good read. Thank you for sharing!
Excellent, what a web site it is! This webpage
provides helpful information to us, keep it up.
This blog was… how do you say it? Relevant!! Finally I
have found something that helped me. Thanks a lot!
Hello There. I found your weblog the use of msn. This is a very neatly written article.
I’ll make sure to bookmark it and return to learn extra of your helpful info.
Thank you for the post. I will definitely comeback.
This post will help the internet viewers for building up new blog or even a weblog
from start to end.
of course like your web site but you need to check the spelling on quite a few of your posts.
A number of them are rife with spelling issues and I
in finding it very bothersome to tell the truth nevertheless I’ll surely come back again.
Thank you for the auspicious writeup. It in fact usedto be a amusement account it. Glance advanced to more brought agreeable from you!However, how could we keep in touch?
Have you ever considered publishing an e-book or guest authoring on other blogs?
I have a blog based upon on the same topics you discuss and would love to have you
share some stories/information. I know my subscribers would appreciate your work.
If you’re even remotely interested, feel free to
send me an e-mail.
Woah! I’m really digging the template/theme of
this blog. It’s simple, yet effective. A lot of times it’s very hard
to get that “perfect balance” between superb usability and appearance.
I must say you’ve done a great job with this. In addition, the
blog loads extremely quick for me on Internet explorer.
Excellent Blog!
Great beat ! I would like to apprentice while you amend your web site, how could i subscribe for a blog website?
The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear concept
Hello there, I found your website by way of Google whilst looking for a similar topic, your website came up,
it appears to be like good. I have bookmarked it
in my google bookmarks.
Hi there, just became aware of your weblog through Google, and located
that it’s really informative. I am gonna be
careful for brussels. I will be grateful in the event you
proceed this in future. Lots of other people will probably be benefited out
of your writing. Cheers!
Hmm is anyone else encountering problems with the pictures on this blog loading?
I’m trying to figure out if its a problem on my end or if it’s the blog.
Any suggestions would be greatly appreciated.
My brother recommended I would possibly like this blog.
He was totally right. This post actually made my day.
You cann’t believe simply how much time I had
spent for this info! Thanks!
What’s Taking place i’m new to this, I stumbled upon this I have found It positively useful and it has
helped me out loads. I hope to give a contribution & assist other users like its helped me.
Good job.
Wow that was strange. I just wrote an extremely long comment but after
I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all
that over again. Anyway, just wanted to say wonderful blog!
It’s an remarkable article in support of all the online people; they will take benefit from it I am sure.
An intriguing discussion is definitely worth comment.
I think that you ought to write more on this issue, it may not be
a taboo matter but usually people do not speak about such
issues. To the next! Best wishes!!
Tremendous issues here. I’m very glad to peer your
post. Thanks so much and I’m looking forward to contact you.
Will you please drop me a e-mail?
Good way of telling, and pleasant post to get data about my presentation subject,
which i am going to convey in university.
I savor, cause I discovered just what I was looking for.
You have ended my 4 day long hunt! God Bless you man. Have a nice day.
Bye
Excellent post. I was checking continuously this blog and I am impressed!
Extremely useful info particularly the last part 🙂 I care for such information much.
I was looking for this certain information for a long time.
Thank you and best of luck.
Hi it’s me, I am also visiting this web site regularly,
this web page is actually good and the users are in fact sharing pleasant thoughts.
My programmer is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the costs.
But he’s tryiong none the less. I’ve been using WordPress on a variety of websites for about a year and am nervous about switching to another platform.
I have heard great things about blogengine.net. Is there a way I can transfer all my wordpress posts into
it? Any kind of help would be greatly appreciated!
Very good article. I will be facing many of these issues as
well..
Howdy just wanted to give you a brief heads up and let you know a few of
the pictures aren’t loading properly. I’m not sure why but I think its a linking issue.
I’ve tried it in two different web browsers and both
show the same outcome.
great points altogether, you simply received a
emblem new reader. What could you suggest in regards to your put
up that you just made some days ago? Any certain?
Asking questions are really pleasant thing if you are not understanding something completely, except this article offers fastidious understanding even.
I was more than happy to find this page. I want to to thank you for ones time just for this wonderful read!!
I definitely enjoyed every little bit of it and I have you book marked to
check out new stuff on your web site.
I’m excited to discover this great site. I need to to thank you for ones time for this particularly fantastic
read!! I definitely really liked every part of it and i also have you book marked
to check out new stuff on your blog.
We stumbled over here coming from a different web page and thought I may as
well check things out. I like what I see so now i’m following you.
Look forward to finding out about your web page repeatedly.
Hello, Neat post. There’s an issue with your web site in web explorer, would check this?
IE nonetheless is the market leader and a big portion of
other people will miss your fantastic writing due
to this problem.
Thanks a bunch for sharing this with all people you actually
realize what you are talking approximately! Bookmarked.
Please also consult with my site =). We could have a link alternate agreement among
us
Hi! Quick question that’s entirely off topic.
Do you know how to make your site mobile friendly?
My web site looks weird when viewing from my iphone 4.
I’m trying to find a theme or plugin that might be able to resolve this problem.
If you have any suggestions, please share. Thanks!