C Code How to add sounds to .exe using resource folder? - c

I am using windows, codeblocks. I have managed to include an icon for the exectable using a .rc file and including it there using this line of code:
MAINICON ICON "trees_XZ1_icon.ico"
How to do in the same manner with a .wav file (sound)?

Related

Is the "CMakeList.txt" file autogenerated or do I have to download it somewhere?

CMake error:
`CMake Error: The source directory "C:/Users/Computer/Desktop/ACCESS/OpenGl" does not appear to contain CMakeLists.txt.`
Specify --help for usage, or press the help button on the CMake GUI.
I trying to learn the basics of OpenGL using C programming language. I am using MinGW as compiler and SublimeText3 as text editor. I have just installed CMake and read the instructions in the help section, but they do not make clear where to find "CMakeList.txt". Is this file automatically generated?
I am using the GUI CMake interface:
Folder of sorce code: C:/Users/Computer/Desktop/ACCESS/OpenGl.
Inside the folder there is a file called: window.c
Folder to build the binaries: C:/Users/Computer/Desktop/ACCESS/OpenGl/build.
The generator is: MingGW Makefiles.

How to make atom the default program when opening .cpp files?

I just started using ubuntu 16.04 and I want to make atom my default program when working with .cpp files but I don't know how to yet. For example when I click on a .cpp file in one of my folders I want it to open with atom instead of with gedit.
Open any directory with the file type .cpp in the file explorer, right click on the file and go to properties, there you will find a tab open with. In that tab choose the application you want to open that type of files and hit "Set as Default".

How to ship .dll files with the .exe file

I have an application that depends on some .dll files.
I know if I just make them in the same folder as the .exe file, it would work, but I don't want to leave 30 .dll files with my .exe file. Is there a way I can put them in a folder with my .exe file ?
Or even better, is it possible to compile them and link them with the .exe file to have a standalone file? And no I don't have the static version of these dynamic libraries.
(p.s. the application is written with c, compiled with gcc, mingw win64, and the .dll are from gtk3 libs)
Thank you for reading my question
You have a number of options.
A) get hold of the library files, .lib on windows and statically link with these libraries.
B) It is a bit of a hack but you can attach resources into a Windows executable. This is usually used for strings, icons, that sort of thing, but you could even attach in a binary file. But if you do this you would probably need to generate the dll binaries at program startup and save to eg same folder as your executable. So no point in doing this really, simply distribute in the same folder as your exe. What is the problem doing that? (lookup LoadResource, FindResource, MAKEINTRESOURCE, etc)
C) If you don't want to put the dlls is the same path as your exe you will need to store them in a folder in your system's path env variable. Eg you could copy them to C:\Windows - but due to security that will be harder. You could create your own dll_path and add this path to the env variable as part of the installation of your program.
D) One other variation on C) is that you copy to for example a subdirectory of you exe location, called eg dll_files. Then you use a startup script to launch your program like this:
#echo off
set PATH=%PATH%;<path to dll files>
myprogram.exe
Let's make is simple
download winrar from www.rarlab.com/download.htm A) create standalone winrar executable pack your file in archive and execute your main program.
no idea how to create standalone installer guide for you
http://www.groovypost.com/howto/howto/how-to-make-your-own-offline-installers-using-winrar/

CodeLite static library does not find include file

I've created a simple project to learn how to create a static library. I've created a new workspace in CodeLite and a new project and a new static library.
In the static library I've got, inside a "include" folder a .h file called helloworld.h and inside a "src" folder a .c file called helloworld.c. The output files are generated in a folder inside the workspace in a folder called lib (../lib).
Inside the same workspace I have a project with a file .c where the helloworld is called with #include "helloworld.h". Finally, the settings of the project are:
linker menu:
Libraries search path: ../lib
Libraries:
General Menu:
When I compile the project I got the following error:
fatal error: 'helloworld.h' file not found
The only way that the project compiles without problems is to get the relative path to the file within the include parameter:
#include "../HelloWorldLib/include/helloworld.h"
I wonder if there is a way to work without having to add the path to the file. I'm using CodeLite in MAC OS 10.9.5. The same problem occurs in Ubuntu.
My teacher explained that this does not occur in CodeLite Windows, but he doesn't know what could be happening in Mac. Moreover, it should not be necessary to use the path within the include parameter.
If you go to the "Compiler" tab instead of the "Linker" tab, try adding your 'include' directory under the "Include Paths" option.

What is the correct way to add .dll file in a MSVC 2010 project

I need to use the library libMPSSE.dll in my win32 console application project in MSVC 2010. After writing the code I just copied the dll in the folder where my .cpp file is present. I am able to compile successfully but the issue is I am having linking error:
libMPSSE.dll : fatal error LNK1107: invalid or corrupt file: cannot
read at 0x308
Is it really a problem with the dll itself or is there any problem with the dll path. How do we add dll to projects?
They have not provided any .lib file. The complete code is here
These are the usual steps to link to a DLL:
Include the DLL's header file in any of your source files that need to use functions from the DLL. You'll typically need to make sure that your build environment's include path contains the location of the header file. In the IDE you can do this using the Additional Include Directories configuration setting.
Pass the DLL's .lib file to the linker. In the IDE you do this by adding the .lib file to the Additional Dependencies setting. And you'll typically need to add the path to the .lib file to the Additional Library Directories setting.
Having done that, your program should compile and link. To make it run, you'll need to ensure that the DLL itself can be found at runtime. The simplest way to make that happen is to put it in the same directory as the executable file.
My guess, looking at your error message, is that in step 2 you passed the .dll to the linker rather than passing the .lib file.
As said here earlier you can't link to .dll files with C linker directly.
There're win32 APIs that can load the .dll file and return to you pointers to function.
Usually, .dll file is accompanied with .lib file contains code that does this burden for you and provides the API .dll file exposes. All you need is to link to this .lib file and put .dll file near the .exe file created.
Specifically regarding libMPSSE, it's said in its release notes that you can rename the provided .a file to .lib file to link to it in Visual Studio (Project properties->configuration properties->Linker->Input). I tried it and it works as supposed.

Resources