I'm a beginner to c++ game development. I tried to set up the sdl library on code block; I followed every tutorial I have found on Google, but can't get it to work. I also included SDL2_image-2.0.0 and SDL2_mixer-2.0.0 but it isn't working. The error is:
#include <winapifamily.h> ||=== Build: Debug in tut (compiler: GNU GCC Compiler) ===|
C:\mingw_dev_lib\SDL2-2.0.3\x86_64-w64-mingw32\include\SDL2\SDL_platform.h|121|fatal error: winapifamily.h: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
include <winapifamily.h>
What is wrong with my code?
I actually just set up SDL2 on Code::Blocks myself a day or two ago. Since I suspect your environment might not be configured correctly, here's how I did it, roughly following the tutorial here:
Download both a runtime binary and a development library from the SDL2 download page. Make sure the runtime binary is appropriate for your apps - in other words, if you're building 32-bit executables, get the 32-bit SDL, and if you're building 64-bit binaries, get the 64-bit SDL.
Unpack the development library into a folder of your choice, and do the same with the runtime binary. Remember what paths you used for these. I used "D:\Programming\C++\SDL\SDL2.dll" for my SDL runtime binary and "D:\Programming\C++\SDL\SDL2-2.0.3" for my development library.
Open your project in Code::Blocks.
Go to the Settings menu and click "Compiler..."
Switch to the "Search Directories" tab, then the "Compiler" subtab.
Click "Add" and browse to the folder for your development library. You'll need to pick whether you're developing for 32-bit apps or 64-bit apps here: if you're going for 32-bit, you'll want to add "\i686-w64-mingw32\include" ("D:\Programming\C++\SDL\SDL2-2.0.3\i686-w64-mingw32\include") and for 64-bit apps you'll want to add "\x86_64-w64-mingw32\include" ("D:\Programming\C++\SDL\SDL2-2.0.3\x86_64-w64-mingw32\include").
Go to the "Linker" tab right next to the "Compiler" tab.
Click "Add" and browse to your the folder for your development library. Once again, based on whether you're going for a 32-bit app or a 64-bit app, add "\i686-w64-mingw32\lib" ("D:\Programming\C++\SDL\SDL2-2.0.3\i686-w64-mingw32\lib") or "\x86_64-w64-mingw32\lib" ("D:\Programming\C++\SDL\SDL2-2.0.3\x86_64-w64-mingw32\lib") respectively.
Take the SDL runtime binary ("D:\Programming\C++\SDL\SDL2.dll") and copy & paste it into the folder your compiled EXE will end up in. Since you're using Code::Blocks, this will usually be %PROJECT_FOLDER%\Bin\%RELEASEMODE%, where %PROJECT_FOLDER% is the path to your project and %RELEASEMODE% is Debug or Release.
Build your project and verify that it works.
You can also set this up on a per-project basis rather than a global basis if you want. Just go into the Project menu and click "Build options..." instead of the Settings menu in step 4.
If SDL still doesn't work after this, I'd suggest getting an updated MinGW and making sure Code::Blocks is properly set up to use it.
Related
So I recently finished a VC++ console application I have been working on and I sent it to one of my friends to try out but he cant even open it because he keeps getting an error.
A box will open up with the title Bad - Image and then it shows the error and stuff, it says it cant find the file MSVCP140D.dll on my friends computer but when I start the program it runs fine.
Can anyone tell me why he cant play the program and how to fix it?
You have built your project in debug mode and you are using Multi-threaded Debug DLL (/MDd) RunTime library.
In Visual Studio main menu, select Project -> Properties
Go to "Configuration Properties" -> C/C++ -> Code Generation
In Runtime Library, select Multi-threaded Debug (/MTd) and rebuild your project.
Alternatively you can build your project in Release mode, then select Multi-threaded (/MT) Runtime library.
This will make a stand-alone executable file which uses standard windows libraries, you won't have to provide additional dlls with the *.exe file.
You need to ship your program with the Microsoft Visual C++ Redistributable package. That's MSVCP140D.dll.
As user4581301 pointed out, the D in MSVCP140D.dll means 'Debug'.
You shouldn't ship a debug-enabled executable. It makes reverse engineering, hacking, and other modifications easier.
You should instead compile a release build, and ship it with the redistributable.
Well you need to do one thing(the easy solution), you just go to your system32 directory at system where you have built the code and find out the file MSVCP140D.dll, put it with your executable(.exe) and give it to your friend, and tell him to keep the dll in same folder as the exe.
MSVCP140D.dll (redistributable pack) is one of the run time dependencies you need to provide to run your application.
Now it will get installed. Or you can copy the dll at system32 at target system and then try.
But you shouldn't provide the debug build if you are giving it to client, you should provide the release version of it.
I have tried to setup and create wxWidgets project using wxWindgets installer and code::block-mingw installations.
When I am trying to create a wx-widgets smith project, I have below problem
A matching Debug configuration cannot be found in the wxWidgets directory you specified.
This means Debug target of your project will not build
Are you sure you want to continue with these settings ?
does anybody have any idea about this and what is the recommended way to setup wxWidgets and code-block in Windows ?
Did you compile your wxWidgets as a debug build? I got the same error, because I only buitl wxWidgets as a release build. However, I didn't intend to use the debug build anyway, because I didn't want to debug it, just use it. So you can continue with your project and then you have to replace the library names with the correct ones. Mostly this means removing the d at the end of the library name.
If you want to use a debug build, you have to build wxWidgets as a debug as well.
To fix the library names, you'd have to right-click on your project and go to "Build options... -> Linker settings".
Update
To compile it using MingW you have to follow this guide.
You may also have to adjust the include paths in your build options:
D:\src\c\wxWidgets_3.0.0\lib\gcc_lib\msw
D:\src\c\wxWidgets_3.0.0\include
And for the linker:
D:\src\c\wxWidgets_3.0.0\lib\gcc_lib
Problem is solved by following the exact instruction provided in Compiling wxWidgets 3.0.0 to develop Code::Blocks (MSW) section. I couldn't build wxWidgets correctly in windows. After I build wxWidget the same alert message mentioned in the question was popped when creating wxWidgets project using Code::Block but I dismissed and continue to create the project. This time it was worked.
I have downloaded c++ open source application which was created using under Linux IDE/Editor (or maybe something NOT Windows) and its no longer supported.
This time I want to edit and recompile it using VS 2010.
Error(s) left (mostly prefixed with "wx") such as:
"wxString is undefined"
"wxStaticText expected a type specifier"
etc... makes me think that this is all about wxWidgets.
After successfully building wxWidgets, what to do next to integrate it to the actual c++ program for me to be able to edit and compile using VS 2010?
I use BorlandC++ last 2 years ago but not familiar with GUI packages.
The first step is to tell the compiler where to look for the wxWidgets include files.
So, you need to find out where these files are, which depends on where you installed and built wxWidgets.
On my system, this is C:\Program Files (x86)\wxWidgets-2.8.12
I consider the best way is to, instead of hard-coding the path in every project, create an environment variable WXROOT to store the path to your wxWidgets folder.
Control Panel | System | Advanced | Environment variables
Now you have to tell the compiler about this
Visual Studio | Project | Properties | C/C++ | Additional Include Directories
What you add here depends on what kind of build you are doing. If you are doing a unicode release build, then this will be a good start
"$(WXROOT)\lib\vc_lib\mswu";"$(WXROOT)\include"
Now you should have fixed your compiler errors.
Next you will get some linker errors ....
Maybe the errors are caused because you are using wxwidget 2.8 which is unsupported in VS 2010.
Try building wxwidgets 2.9 or use VS 2008. I had no problem building wxwidgets 2.9 on VS 2010.
Wxwidgets site home says "While this is still officially a development release because some API details are still not frozen, we believe that 2.9.3 can be used in production environment".
About what to do after successfully build it, take a look at this http://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide
You may want to use the tutorial of the section "Creating a new project from a sample" 'cause creating a project by hand is a little bit complicated as wxwidgets requires some extra configuration and not just to set and include and libs dir as most of the libs does.
Here is a video which shows how to start with Visual Studio.
Also you can take a look at samples directory and create your own project based on configuration of projects from that directory.
May be I am little bit late , But this will help newcomers to wxwidgets.
First of all Goto Wxwidgets directory(to download path) in my case it is "C:\Users\WxWidgets_all".
Now in that folder goto build directory.Now open Visual Studio Command prompt. If you have already installed Visual Studio then you can easily find it through start menu.
Now in command prompt go upto <Path to your wxWidgets>/build/msw/ . Now run Following Commands.
nmake /f makefile.vc--For Static Library and Debug Version
nmake /f makefile.vc SHARED=1--For SHARED Library and Debug Version
nmake /f makefile.vc BUILD=release--For SHARED Library and Release Version
After completing it , you will have dll or lib in "<path to wxwidgets>\lib\" depending on option provided in above commands.
Now include all files related to wxwidgets in your project.Mainly two paths are required to include "<path to wxwidgets>\inlcude\" and "<path to wxwidgets>\lib\vc_<lib\dll>".
After that link your wxwidgets generated library to your project.To do this inlcude "<path to wxwidgets>\lib\vc_<lib\dll>" to your project property in library section.
Now add below preprocessors to your project.
_WINDOWS
NDEBUG(For Release)
_DEBUG(For Debug)
_CRT_SECURE_NO_DEPRECATE=1
_CRT_NON_CONFORMING_SWPRINTFS=1
_SCL_SECURE_NO_WARNINGS=1
__WXMSW__
_UNICODE
After that add following library to your project from "<path to wxwidgets>\lib\vc_<lib\dll>"
wxbase30u_net
wxmsw30u_core
wxbase30u
wxtiff
wxjpeg
wxpng
wxzlib
wxregexu
wxexpat
wxmsw30u_adv
Based on your compiled options , library name can be little bit different.
I think I have covered all the steps to run wxWidgets.
Even if you got errors , You can check minimal project in "<path to wxwidgets>\samples"
directory. Try to run that project , and even if you got error then your wxwidgets is not built properly.
Hope this will help.
I'm Using MATLAB R2010a
I used this this tutorial in order to call matlab function from C++ and i did every thing said in the tutorial and i compiled the project successfully but when i tried to run it, it requires many dlls which i added them in windows 7 system32:
icudt24l.dll
icuin24.dll
icuio24.dll
icuuc24.dll
icuuc44.dll
libmx.dll
libut.dll
libz.dll
and I included these files ("libeng.lib" "libmex.lib" "libmx.lib" "libmat.lib") in the project by going to "project properties" -> "Linker" -> "Input" -> "Additional Dependencies"
and i run again it gives me an error "The procedure entry point mxCreateDoubleMatrix_730 could not be located in the dynamic link library libmx.dll"
So what is this error indicate? and how to solve it?
You don't need to put those files in the System32 directory. All you need to do is add the path
C:\Program Files\MATLAB\R2011a\bin\win64
to your system path (google how to do this for your version of windows -- it is subtly different between XP and Vista/7). If you aren't using the 64bit version of matlab, modify the above accordingly.
Also, make sure you are using the right architecture. If you have a 64bit version of Matlab you will need to be using a 64bit compiler.
I have been using Qt creator to make applications using the Qt libraries. I can run these applications by just clicking the play button, but I want to learn how to make applications run just by double clicking on a .exe. So how can I do this?
If you have built a 'release' version of your program, copy it and the following DLL's from qt\bin to a directory:
QtCore4.dll, QtGui4.dll and mingwm10.dll (if you are compiling with gcc and minGW).
If you are running a 'debug' build, you will need the debug versions of the Qt DLLs. They have the same name but with a 'd' at the end of the name.
There may be other Qt DLLs you will have to copy depending on Qt modules you are using in your program.
You can find out more from this page (Qt docs website) Deploying Qt Applications
I'm assuming you are running windows since you mention an .exe file extension. Look in the debug and/or release subdirectories of your project to find the produced binary. You can double-click on it to run the application. However, there are several DLL's that will be required. So, make sure they are in your PATH or copy them in the same directory. Dependency Walker is useful for finding out what you need.