Visual Studio 2015 + libtcod - Unexpected exit - c++

I am having an odd issue getting libtcod to work with Visual Studio 2015.
I have followed all the steps found on this blog post to get everything linked.
The problem is that during debugging or running it inside Visual Studio the application will always close at initRoot with exit code 1, no other information or errors.
Running the produced EXE outside of Visual Studio has no issues whatsoever - starts up and works as expected!
The only information I could find related to this was a forum post that turned ugly in 2012
I did make a modification to the blog post's code to include a setCustomFont as well, which did not change anything.
Does anyone have any ideas on what might be going on?
Code:
#include <cstdio>
#include "libtcod.hpp"
// Hide the console window
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
int main()
{
TCODConsole::setCustomFont("terminal12x12_gs_ro.png", TCOD_FONT_LAYOUT_ASCII_INROW | TCOD_FONT_TYPE_GRAYSCALE);
TCODConsole::initRoot(80, 50, "C++ libtcod tutorial");
TCODConsole::root->printEx(40, 25, TCOD_BKGND_NONE, TCOD_CENTER, "Hello world");
TCODConsole::flush();
TCODConsole::waitForKeypress(true);
return 0;
}

For anyone that stumbles upon this later, the above blog post is correct for setting up the vast majority of the application - if you run into the same issue I did (crashing / exiting in initRoot) make sure you have the terminal png in the source directory, this is what fixed it for me.

Related

LINK : fatal error LNK1181: cannot open input file 'opencv_world341d.lib'

I have found two similar questions this and this .
But they both use opencv, and opencv indeed provide the corresponding lib. I don't use opencv, and my project is very simple, just hello world.I have changed project default configuration like this
except for these configurations, others all take defaults
I just want to test my project configuration,that works find for win32 debug and release. But not work for x64 debug and release, they all tell me LINK : fatal error LNK1104: cannot open file 'opencv_world341d.lib'
I indeed know my project does not use any opencv lib, but why they tell me I need to use opencv_world341d.lib
my code
#include<iostream>
using namespace std;
int main()
{
cout << "hello world" << endl;
}
Thanks for everyone who comments on the question. I have solved the problem, although this problem not relevant to OpenCV to much, but I think the solution to the problem may be helpful to others. When I build project, visual studio 2019 tell me cannot link opencv_world341d.lib, so I go to Project->Properties->Linker->Input->Additional Dependencies , and I found opencv_world341d.lib. So I need to remove it, but it's readonly. From this we know visual studio using settings file (Microsoft.cpp..users.props) to control global settings including Global search path. These files are located at $(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0 directory. Then I reedit Microsoft.cpp.<Platform>.users.props, delete opencv_world341d.lib, reboot visual studio, problem solved.

identifier "DDRB" is undefined - VS code / Visual studio

I am getting the following error when using the identifier DDRB:
identifier "DDRB" is undefined
But, when I click “go to definition”, the IDE does shows that it can find them. The code also compiles without any problem. I was using VScode first and setting intellisense to "tag parser" did work, but it also got rid of the error checking. So, I switched over to Visual Studio, but the issue remains. In both cases I included the AVR library.
I have googled quite a bit and found some solutions, but most were outdated or did not work. What can I do to resolve this issue?
"minimal reproducible example:"
#include <avr\io.h>
int main() {
DDRB |= (1 << DD3);
}
I can reproduce same issue in VS2017, and this one can be resolved by adding the #define __AVR_ATmega32U4__ above the #include <avr\io.h> like this:
#define __AVR_ATmega32U4__
#include <iostream>
#include <avr/io.h>
int main()
{
DDRB |= (1 << DD3);
}
After adding the macro definition, VS Intellisense option can recognize them well and the issue goes away. More details refer to Kissiel's reply. Thanks to him!
If you don't want to paste this definition into almost every file:
press f1
find C/C++; Edit configurations (UI)
paste your mcu name in Defines section e.g __AVR_ATmega32U4__
It worked for me in vs code.

opencv_world341d.dll was not found error

I am trying to run OpenCV on Visual Studios 2017. I built the libraries and bin with CMake, so far it is working good. However, when I try to run the code it says this:
This is the error code message that shows when I launch the "local windows debugger":
For some reason, it says that it can't find the DLL. I already assign the Aditional Dependencies in properties also I linked the "Included Directories" and "Included Libraries" to openCV in Visual Studios, the project is set to run in x64, and there are no errors on the programming it's just that error of DLL that shows.
The DLL can be found in a separate folder made by the compiler in a bin folder. However, it still says it can't be found.
This is the locations of the DLL files:
Is there a solution for this?
I tried to add pictures I'm new in the forum it doesn't let me post them yet. I am not sure if the ones I upload will show.
This is the code I tried to run and bring the error message. The same happen with any other code.
I will add more images that may help to understand what I did so far and thanks in advance for the help.
This are the Visual Studios C/C++ Directories:
This is the Linked section in Visual Studios properties:
This is the environment PATH from Environment Variables:
This is all I did so far in the process to install OpenCV in Visual Studios.
#include "stdafx.h"
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
int main() {
cv::Mat image;
std::cout << "This image is" << image.rows << "X" << image.cols << std::endl;
image = cv::imread("puppy.bmp");
if (image.empty()) {
}
cv::Mat result;
cv::flip(image, result, 1);
cv::waitKey(0);
return 0;
}
For me, restart to Visual Studio solved the problem, I guess that's because when I added the OpenCV to Environment Variable the Visual Studio was open
Just copy opencv_world341d.dll to the x64 debug folder, and run it.
I also restart my computer after I add it to PATH. So the solution is just restart your computer when you add to PATH for the first time
I've also faced this issue and solved it simply by adding the OpenCV bin path to the environment variable.

"Project out of date" in VS community 2017

I recently changed from Microsoft Visual Studio Community 2015 (which worked fine) to the 2017 version, and at first, it was working fine. I save my projects in C:/_Dev/C++/My projects/. However, after using 2017 for less than 3 hours, I now get this message whenever I try to run a project:
"This project is out of date:
[insert file name]-Debug Win32"
Then I have the option to build it or not, and building does still work, but I don't like that something is going slightly wrong.
Note that since I got this error, I went back to my first C++ program to see if it now displays the message too, which it does. The code is as follows:
#include <iostream>
using namespace std;
void main()
{
cout << "Hello World!";
system("pause");
}
...So I'm fairly confident it's not my code causing the issue. It's been a couple of days since I started getting the error, and I've tried re-installing VSC 2017, deleting the *tlog files, cleaning, and rebuilding the project. I have not moved the project to a new file directory since its creation.
Does anyone know if this will turn into a big problem, or is it just something I have to put up with? If anyone knows more, I'd appreciate the advice.

Windows error while writing graphic codes in Code Blocks. How to fix it?

I am having trouble using graphics.h in code blocks.
I have installed winbgi.
Edited 302nd line.
Linked lib file and all that stuff is done. So, I don't have any error regarding graphics header file.
But whenever I run/build any code involving graphics functions, windows gives an error ".. has stopped working". How to fix this?
I am using Codeblock v16. Windows 7ultimate - 64bit.
Here is my code:
#include<graphics.h>
int main() {
int gd = DETECT,gm;
initgraph(&gd, &gm, "c:\\tc\\bgi");
line(80, 100, 100, 100);
getch();
//return 0;
}
screenshots:
[SOLVED]
Unfortunately, it was all about 'bad' library files. I think, many have downloaded same(with bug) files in internet. Now I have bug-free files shared in google drive. And also Code::Blocks 16.01 (latest version)
Here's link. Replace old files with these new ones.
I have explained those steps and few FAQs here on this topic with links and test codes.
use of DosBox for emulate MS-DOS in Windows7.
just i can help you with bellow link, its useful.
See : How use of DOSBox in Windows 7