SDL2 possible linking issue in VS2017 - c++

I'm using Visual Studio 2017 with OpenGLESApp template and I'm trying to put SDL2 into my project. I linked it by clicking Android.NativeActivity properties and in there I selected include folder and in linking part I linked against pre-compiled x86 binary which I downloaded from official SDL2 webpage.
Now since I'm using emulator with x86 base image I'm assuming that those things are compatible. Is my assumption wrong?
When I try to use SDL2 functions in my code compiler is complaining with the following error message:
Error MSB6006 "clang.exe" exited with code 1.
And when I delete all usages of SDL2 functions code compiles just fine. Now this would perhaps indicate that architectures are not compatible and that my initial assumption is wrong.
Can somebody help me to understand this? Is there any way I can see more information from the compiler to validate what the actual issue is?
Also, any help on how to get SDL2 to run in my project would be helpful.

You probably have undefined references in your output before the error you are showing.
You are trying to link windows libraries with Android binaries, which cannot work, they are not the proper type. Even if they both can be executed on a x86 machine, they have a different structure.

Related

When I execute an .exe (compiled on my machine) on another computer it give me this error

It's my first time using Visual Studio 2017. I built a simple program in C++ on my PC. I was curious to see if my program works on another PC. I tried to execute the .exe on the other computer and it gave me this kind of error:
vs(some letters and numbers).dll is missing.
I assume that the .dll in question is part of Visual Studio.
I tried on a third PC, and this time the cmd stops working and becomes unresponsive after I execute my .exe.
I also have this problem when I compile with MinGW using the g++ compile feature in the cmd. When I execute the program compiled with MinGW on another PC, it gives me the same error, but this time it says something like
gw...dll is missing
Is there a way to avoid this error without installing the Visual Studio (or MinGW at this point) on any other PC I want my program to run on?
If you're interested in the code, I can put it here, but I don't think it's the problem here because I have the same issue for every other .exe compiled on my PC.
Here's a picture of the error:
In case of Visual Studio, you need to install Visual C++ Redistributable libraries or provide the libraries that are required by your application with .exe file (I am not sure if it violates license or not though).
In case of MinGW, you need to provide required DLL as well. I guess that you need libgcc_s_dw2-1.dll and libstdc++-6.dll, but you would better check it yourself. And remember about the license.
You may use Dependency Walker to analyse dependencies of your application.
UPDATE (2017-12-12):
I've missed the time you posted the screenshot. As far as I see from it the problem is that you are trying to run debug version of your executable: ucrtbased.dll is the debug version of the ucrtbase library and is only available (from what I know) from Visual Studio distribution. If you want to run your application on the computers that do not have installed Visual Studio, then you should use the Release version of your application.
In order to understand your problem you need to understand the concept of DLL.
Dynamic-link library(DLL) - As described by Microsoft:
A DLL is a library that contains code and data that can be used by
more than one program at the same time. For example, in Windows
operating systems, the Comdlg32 DLL performs common dialog box related
functions. Therefore, each program can use the functionality that is
contained in this DLL to implement an Open dialog box. This helps
promote code reuse and efficient memory usage.
So to put it simply, DLL is basically a bunch of compiled code, which is being linked to your code at load (or even run-time). Now, of course if your system is missing the DLL, your progrem will fail to work. To make things even worse, DLL are sensitive to the compiler that was used. So each DLL might have multiple version, so you will need to right DLL.
Now to the problem itself, the error message are the best way to start. They guide you what DLL are missing, and what is their name. For instance in your case "vs*.dll" is most likely related to Visual C++ runtime redistributable.
Finally, please note you have another consideration to make in addition to make your own system work: Every one that will use your code might face the exact same problem. So if you actually intend to share your .EXE with other people, you will need to understand how to guide them, or even automate their installation process.

OpenCV in Code::Blocks: The application was unable to start correctly (0xc00000be)

I set up OpenCV with Code::Blocks as per this tutorial: http://kevinhughes.ca/tutorials/opencv-install-on-windows-with-codeblocks-and-mingw/.
I've got as far as building the test program at the end successfully, but when I try to run it I get the following error: "The application was unable to start correctly (0xc00000be). Click OK to close the application."
The one thing that is certainly different from the tutorial for me is that I'm working with OpenCV 3.0.0, Code::Blocks 13.12 and the latest version of mingw (number not obvious from their website or the installer).
I found that other people had had this problem in the past, e.g. The application was unable to start correctly (0xc00000be)
However, it has been a long time since that thread was active, I'm working with newer versions of the software and, most importantly, the answer given there didn't help (I compiled openCV with the same mingw that I'm using with Code::Blocks), so I thought this question would be worth asking (sorry if it's not, I'm rather new to this).
Could anybody suggest a fix that might get rid of this error?
A few other things to note:
I didn't download the Code::Blocks that came with mingw as I was advised against it, I got them separately as per the tutorial
I have installed OpenCV and Code::Blocks on my E: drive, though mingw is still on my C:.
I have added both mingw and OpenCV to my PATH variable, and mingw to my Path variable
I have linked the libraries in both the main compiler settings for Code::Blocks and the Build Options of my project.
I'm working from a 64-bit Windows 7 Laptop, but I have done everything 32-bit style as advised in the tutorial.
Thanks in advance!
So, one solution I've found to this problem is to copy all the .dll files from "...\opencv\build\x86\mingw\bin" to the project file (build directory).
Having done that, the project will run fine. This still doesn't (directly) explain why it wont run without those files (at least, several sources including the tutorial imply it should), and so isn't really optimal. I will continue to look for a solution for this so I don't have to clutter every opencv project I make with the .dlls.
However, for anyone simply wanting to get stuck into coding who is having this problem, I recommend that solution.

Kinect for windows program in VisualC++ can't find freeglut.dll even though freeglut has been installed. Why?

This is my first post to this site. I'm hoping that someone can help me out.
I am doing some work with the Microsoft Kinect for Windows and I am trying to set up visual studio to use GLUT. The code builds successfully, but I keep getting the following error message when I try to run the program in Visual Studio:
The program can't start because freeglut.dll is missing from your
computer. Try reinstalling the program to fix this problem.
I have installed the Microsoft SDK and Developer Toolkit for the Kinect and I am using Visual Sutdio 2010. I followed the instructions on this tutorial, Kinect SDK C++, in order to set everything up, including downloading the freeglut 2.8.1 MSVC Package and copying the appropriate files into various folders as per the tutorial instructions. I have tried renaming freeglut.dll to glut32.dll as the tutorial suggests and leaving it unchanged.
The code I'm using is the sample code from the second page of the tutorial. I've also tried the source code provided in this tutorial: Programming KINECT in C++ and OpenGL — Color Stream Rendering. Both build fine, but yield the same error when run.
I tried deleting the freeGLUT files and replacing them, rearranging their folder structure in the SDK folders (and changing the corresponding filepaths in my project properties) as well as following the solution presented in this post: compiled program cannot find freeglut.dll. So far nothing is working and that last solution actually caused the both codes I'm using to fail building with error MSB3073.
I would appreciate any insight you might have into this issue.
Thank you!

Setting up OpenCV with Windows 7 and Code Blocks

I have successfully built OpenCV and I have come to the point where code::blocks recognizes the OpenCV syntax and successfully builds the program. However when I run I get this error
"The procedure entry point_gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll."
I am using Code::Blocks v 12.11 and minGW (the most recent, I can't remember the version number) along with OpenCV-2.4.8 Has anyone ever seen this problem? Help if you can, anything right now might work since I am so close.
https://stackoverflow.com/questions/3895879/installing-opencv-on-windowsw32-to-be-used-with-code-blocks?rq=1
Using this link to the other question I was able to locate a hint for my problem. I had everything correct and the hint to change the build to a GUI Application solved the issue. The programs build and then run as they should.

SDL2.DLL missing

I'm following this tutorial to setup the SDL template but when I try and run the program I get the following error.
I have gone over the tutorial several times but cannot see what mistake I am making.
I copied the SDL2.DLL into the Release Directory and then ran it and I got a different error.
but I imagine that I shouldn't have to do this?
Anyone see what mistake I could be making?
I am using windows 8 + MS Visual Studio 2012
There are two different versions of SDL2.DLL, one is x86 and another is x64. A common mistake is to use the x64 one when in fact you are compiling your code as x86. Try both of them to make sure you aren't making that mistake.