Allegro load_bitmap not working - c

i'm trying to load bitmap like this:
BITMAP *image = load_bitmap("picture.bmp", NULL);
when I test it:
if (image == NULL)
printf("No image loaded\n");
it prints No image loaded so load_bitmap doesn't work ... i have also tried absolute path but still nothing.
Im using Ubuntu and allegro 4.2
Some suggestions?

Did you try placing the image on the same location as the executable? After that is solved check this things also if still getting the error:
Is really a *.bmp file? A file of a different type can not be converted by just renaming it.
Is the file you are trying to read actually called like that? Check for spelling both in code and in the file explorer.
Does the program run correctly if executed from the file explorer or command-line but not from the IDE? If that is the case, then you should change the configuration of the workspace or project you are currently using so that the execution directory is the same as the one where the image file is located.
If all else fails then try following the steps of the tutorial again, perhaps you made something wrong. By the way, if this is your first C++ project I recommend you that instead go to more basic stuff and stick to the command-line for a while until you get the hang of the facilities the language and its libraries have to offer.

Related

adding multiple executables C-Lion

im pretty new in C-programming. I use CLion from JetBrains to program my stuff. I would like to know how to add multiple c files in the makelist.
i would like to just open a program and to execute it..if its possible
my ide works just for one file. so i always have to change the name of the c. file in the makelist
i have already tried a lot of combinations of the makelists file but nothing worked.
does somebody have an idea how to fix this problem?
I have edit two new pictures
In this example I have two c files which i would like to execute.
My goal is to add the whole c file tree on the left side to the CMakeList
Here are the pictures
!enter image description here
Here is the error log
enter image description here
Here is the solution. Thanks to your response someprogramerdude
I just added executables and i changed the project in the beginning. the reason why i use picture is that you can see the source files on the left side
enter image description here

CodeBlocks - How to add an icon to a C program?

I have a small C console program and I want to add an .ico file to it, so that the executable looks nice.
How can I do this in CodeBlocks with MinGW/gcc?
I could not find relevant help via google that a total beginner (like me for C) could follow, so I will Q&A this topic.
First of all you need an .ico file. Put it in the folder with your main.c file.
In CodeBlocks go to File -> New -> Empty File and name it icon.rc. It has to be visible in the Workspace/Project otherwise CodeBlocks will not be aware of this file. It will show up there in a project folder called Resources .
Put the following line in it: MAINICON ICON "filename.ico". MAINICON is just an identifier, you can choose something different. More info 1 & More info 2.
Save the files and compile - CodeBlocks will do everything else for you
What will happen now, is windres.exe (the Resource Compiler) compiling the resource script icon.rc and the icon to an object binary file to obj\Release\icon.res. And the linker will add it to the executable.
It's so easy yet it took me quite a while to find it out - I hope I can save someone else having the same problem some time.

wpf localization - locbaml - file is being used by another process

I have been looking hours for a solution, but I donĀ“t find it.
I want to generate a satellite assembly with following command.
locbaml.exe /generate de/App.UI.resources.dll /trans:MeineRess_de.csv /out:de /cul:de
After executing I get following error:
The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
Can anybody help me, Thx
Output to a separate folder try for example c:\ this would work
locbaml.exe /generate de/App.UI.resources.dll /trans:MeineRess_de.csv /out:c:\ /cul:de
For posterity:
The file name without any command line flag is the original input assembly. So you're reading in de/App.UI.resources.dll and then /out:de is trying to write to the same file in the same folder.
Probably you want to change de/App.UI.resources.dll to [UiCulture]/App.UI.resources.dll where [UiCulture] is the <UICulture> from your project file, which should match the NeutralResourcesLanguage attribute in your assembly (AssemblyInfo.cs normally).
Perhaps you legitimately want to overwrite the original DLL (though I don't think that makes sense), but this will not be possible as-is because locbaml will load the assembly from file, which holds the file handle open until the application exits. (Technically until the AppDomain is destroyed.)

How to make .txt files visible to Visual C

I'm writing a program to that needs to read 32-bit binary numbers in as strings from a text file (notepad). The file contents look like this:
11111111111111110111100011111110
11111111111111111111111111110101
00000000100001011010101011110101
00000000000000000000000010010001
Every time I try to run the code I get the error message saying that the debug assertion failed because the (stream != NULL) condition was not satisfied. I assume that this comes from an error with the fscanf part of the code. I have looked at similar questions with the solution usually being to move the text file to the current working directory, but I am not sure what this means. I am using visual studio Express 2013, and have the text file saved under resource files in my console application. I also have the console application and the text file saved in a single folder on my desktop. Neither of these seem to have had any effect in resolving the error. Here is my source code if it helps at all:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
void main()
{
char str[34];
FILE *binnz;
binnz = fopen("binns.txt", "r");
while (fscanf(binnz,"%s",str) != EOF)
{
printf("%s\n", str);
}
fclose(binnz);
}
If the problem is where the text file is stored, where -exactly- do I put it?
Thanks in advance.
I have looked at similar questions with the solution usually being to move the text file to the current working directory, but I am not sure what this means.
The working directory of a program basically allows it to open files by a relative path. Typically, the working directory of a program will be wherever the executable file resides (so it can easily reference files in the same directory); however, when debugging in Visual Studio, it'll use the project directory as the working directory by default. You can change this under the "Debugging" page of your project settings, or you can just put binns.txt in your project directory.
The resource directory is the wrong place. Add a system("dir") to your program, and it will show you where your program is running. Put your file in there, and you should be good to go.

fopen fails mysteriously under Windows

Maybe I just have another black out but, this one line is giving me a lot of troubles:
FILE *fp = fopen("data/world.data", "rb");
This works fine under Linux when compiled with GCC. But when I compile it with Visual Studio, it crashes. fp is always NULL. Both the BIN and the EXE are in the exact same directory. Now, to make things even crazier, when I run the EXE using Wine under Linux... it... works...
I have absolutely not a god damn clue what's going on here. Maybe it's some insanely stupid mistake on my side, but I cannot get this thing to run under Windows :/
Also, I have another program which works just fine, there the data files are also contained in a sub directory named data.
EDIT:
To make it clear neither / NOR `\ * do work.
EDIT 2:
OK I've given up on this, maybe someone has fun trying to figure it out, here's ZIP containing the EXE, Debug Data for VS etc.:
https://dl.dropbox.com/u/2332843/Leaf.zip
EDIT 3:
Compiled it with CodeBlocks and MinGW, works like a charm. Guess it has to do something with MSVC or the Project Settings in VS.
It sounds like data isn't a subdirectory of your current directory when you run the program. By default (for x86 targets) VS will build and run your program from either a DEBUG or RELEASE subdirectory of the base directory you've created for the project. You can modify the directory that will be "current" when it runs though (e.g., project | properties | configuration properties | debugging for VS 2008).
Edit: While Windows requires that you use a backslash as a directory separator at the command line, a forward slash works fine in code -- this is not the source of your problem.
In windows you have to write the following:
FILE *fp = fopen("data\\world.data", "rb");
This is like that because the backslash is a special character (so a backslash in a string is written using \ and a quotation symbol is \" and so with other special characters).
Since this issue happens only on windows. I doubt whether the file is really named "world.data". As you know, the default setting for windows hides the file extention. Is its real name world.data.xxx?
Include a line to GetCurrentDirectory(), to see if you are running from the directory you expected.
When I develop in C#/ C++ on visual studio, I normally get to run it from the debug folder. I don't think it matters if forward slash is used in place of backslash in .net.
I happened to have the same problem, and suddenly i figured it out.
That should be your windows fault.
Let's say, FILE *fp = fopen("data/world.data", "rb"); in windows, if you hide the extensions, then you can see the file data/world.data, but actually it maybe /data/world.dat.txt or somewhat.
So please check the extensions.
Hope it helps!
I ran into this today, and it happened because I used "br" instead of "rb" on that mode argument.
The underlying fopen is throwing an exception of some kind, which only registers as a crash. It's not bothering to return the standard NULL response or set the associated error values.
I'm not sure but it may be because you're using slash instead of (an escaped) backslash in the path?

Resources