GTK having issue with Visual Studio - c++

I am new in C++ stuff and visual studio. Somehow I managed to add GTK lib and includes in Additional Include Directory! here is how i added
C:\gtk\include\atk-1.0;C:\gtk\include;C:\gtk\include\gdk-pixbuf-2.0;C:\gtk\include\pango-1.0;C:\gtk\include\cairo;C:\gtk\lib\gtk-2.0\include;C:\gtk\lib\glib-2.0\include;C:\gtk\include\glib-2.0;C:\gtk\include\gtk-2.0;%(AdditionalIncludeDirectories)
all files set correctly and no error with linking.
But when I compiling code I got this errors!
here is image!
This is unrecognized error for me any one know what's the matter!
here is code (this is basic code i get from tutorial over internet)
#include<gtk\gtk.h>
int main(int argc,char* argv[]){
gtk_init(&argc,&argv);
GtkWidget* window;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
gtk_widget_show(window);
gtk_main();
return 0;
}
thanks for help! and your time

Related

SDL2_Image is throwing "The procedure entry point inflateReset2 could not be located" whenever i try to initialize SDL2_Image for png images

The file included in the error message is "libpng16-16.dll", I am using SDL2_Image version 2.0.4 with Visual C++ on Windows. No matter what I do, the message stays. i tried swapping out all libpng16-16.dll files with my version i got. I also tried including it into the system32 folder. Nothing works. I can initialize SDL2_Image for other formats, but as soon as i try to initialize it for png, it throws this message. all the time. Found few cases of this happening to others, but their way of fixing it doesn't work for me. at all. i am upset pls help. Here's my current code real quick:
#include "SDL.h"
#include "SDL_image.h"
int main(int argc, char* argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
IMG_Init(IMG_INIT_PNG);
SDL_Quit();
return 0;
}

Allegro 5 Visual studio 2017 linker errors occuring

I've got some problems getting up Allegro 5 library in Visual Studio 2017. In most cases i'm getting linker errors (unknown/unrecognized external types).
I said in most cases, because this code:
#include <stdio.h>
#include <allegro5/allegro.h>
int main(int argc, char **argv) {
ALLEGRO_DISPLAY *display = NULL;
if (!al_init()) {
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
display = al_create_display(640, 480);
if (!display) {
fprintf(stderr, "failed to create display!\n");
return -1;
}
al_clear_to_color(al_map_rgb(0, 0, 0));
al_flip_display();
al_rest(10.0);
al_destroy_display(display);
return 0;
}
source:https://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial/Displays
compiles as usual without errors and runs as expected.
But this code:
#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"
#include "allegro5/allegro_primitives.h"
int main(int argc, char **argv){
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_DISPLAY_MODE disp_data;
al_init(); // I'm not checking the return value for simplicity.
al_init_image_addon();
al_init_primitives_addon();
al_get_display_mode(al_get_num_display_modes() - 1, &disp_data);
al_set_new_display_flags(ALLEGRO_FULLSCREEN);
display = al_create_display(disp_data.width, disp_data.height);
al_rest(3);
al_destroy_display(display);
return 0;
}
source: the same, next tutorial.
gets me 3 errors in linker. Many other codes do as well with various numbers of errors in linker.
In this prticular case are the errors as folows:
Error code Description
LNK2019 Unrecognized external symbol __imp__al_init_image_addon reffered in function _main
LNK2019 Unrecognized external symbol __imp__al_init_primitives_addon reffered in function _main
LNK1120 Number of unrecognized external types:2
I've read that Allegro has some dependencies in freetype, so i installed it using NuGet(project pakage manager), the same way as Allegro.
I'm new to Visual Studio, so if you have a possible solution, please explain step by step (and, if you are capable of it, please explain, so I can learn something new)
If you need something to find the solution, just ask and explain how can i get it.
Thanks a lot in advance.
Yep, I'm just stupid.
I'm sorry for all the trouble I've caused.
It was because I didn't know that I have to enable the modules in project properties under Allegro 5 tab. Now I've got it up and running.
I'm very sorry for bothering you.
Glad you solved it. For the record, the addon libraries are not linked by default in the Nuget Package for VS. After installing the Allegro 5 Nuget package for your solution, right click on the project properties and select Allegro5 from the menu on the left. Go to addon libraries, and enable the addons you're using. Easy peasy.

C++ SDL (Visual Studio 2015): cannot open file stddef.h

I'm relatively new to c++ and have been following the Lazy Foo' tutorial for installing SDL2 in visual studio 2010 (But I am using visual studio 2015).
I have followed the guide a couple of times now, so pretty certain I have incuded the right files etc. Here is a screen shot of my VC++ Directories settings:
#include <SDL.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window *window = 0;
window = SDL_CreateWindow("SDL window",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
640, 480,
SDL_WINDOW_SHOWN);
SDL_Delay(1000);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
When compiled (32 bit) I receive this error:
......\documents\sdl\sdl2-2.0.4\include\sdl_stdinc.h(50): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory
I also have the error "cannot open source file stdio.h" when hovering over the include statement for stdio.h
I'm going to continue to look at it all, but if anyone has any suggestions that would be greatly appreciated. Failing that I'll probably just install on Linux :)
Cheers and thanks for your time.
Suggestions: Use the dropdown, (inherit from parent or project defaults) to repair the visual c++ directories which you shouldn't ever edit.
Don't add it to the c++ directories, That's a weird idea. Add it to Configuration Properties > c/c++ > additional include directories. If you had done that, then you couldn't have possibly messed up the compiler. It's a lot simpler too. Just paste the one directory in there. That's what it's meant for.
Also Lazy Foo seems to only to have a VS2010 guide. Maybe I just couldn't find the VS2015 guide...
The error message
fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory
tends to happen when you're building your program with a version of MSVC different from the one used to build the library.
You should find out which version the SDL binaries were built with, and try using that. A newer MSVC might work, an older one might not.
You can always try building SDL yourself.

Code::Blocks, MinGW, libsdl, and GNU C++ compiler: undefined reference to `WinMain#16

I have been trying to compile the most basic SDL application, but no matter what I do I keep getting this error:
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../libmingw32.a(main.o):main.c:(.text+0xd2): undefined reference to `WinMain#16'
I searched for solutions for this, but they all had to do with either Visual C++ or a missing main. I am not using Visual C++, and I have defined main.
Here's my code:
#include "SDL/SDL.h"
int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
//Quit SDL
SDL_Quit();
return 0;
}
Don't use "Other linker options". Use the "Link libraries" section. Add the following items.
mingw32
SDLmain
SDL
You can put -mwindows in the "Other linker options" section.
In case someone else comes across this, I put -lmingw32 after -lSDLmain and -lSDL which caused this issue for me. Putting -lmingw32 first fixed it.
I encountered the same error in a project of mine that I want to compile both on linux and windows.
I use a makefile to compile the project.
A solution that has worked for me, although I admit it is a bit of a hack is adding this to main.cpp (wherever your main function would be)
extern "C" {
int WinMain(int argc, char** argv)
{
return main(argc, argv);
}
}
This makes the linker find WinMain and use it as the entry point in the program. I can also hope that this solution doesn't break linux compilability, hopefully it will be considered just an unused function.

Qt4.8.1 undhandled exception at QMdiArea::addSubwindow

I compiled Qt 4.8.1 with these instructions:
http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/
for my system (Visual Studio 2010, x64). The compilation worked and everything seemed Ok.
While compiling there is a lot of output, but it's very fast and therefore I can't read it so i suppose that shouldn't be a problem.
After I compiled succesfully my current project I got an unhandled runtime exception. After a while I discovered that it comes from the QMdiArea::addSubwindow function, which seems to throw the exception (I'm not able to catch it with overriden notify function though). So I searched for an example project to see if it's my code or something else. I found this example here:
http://www.codeprogress.com/cpp/libraries/qt/qMdiAreaAddSubWindow.php
And it works fine in 32bit mode as well as debug mode of x64, but again at the
QMdiArea::addSubwindow function there is an unhandled exception. Has anyone an idea what's wrong or had the same problem?
Currently I'm recompiling Qt to get the debug information again (i cleaned it beforehand).
But maybe someone had the same problem and a solution for me.
//Update:
The code is here (the exact same as in the link)
#include <QApplication>
#include <QMainWindow>
#include <QMdiArea>
#include <QMdiSubWindow>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow window;
window.setFixedSize(800,600);
window.setWindowTitle(QString::fromUtf8("My QMdiWindow"));
QMdiArea* area = new QMdiArea();
area->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
//Create QMdiSubWindow
QMdiSubWindow* subWindow = new QMdiSubWindow();
subWindow->setFixedSize(200,100);
//Add subWindow to Main QMdiWindow here
area->addSubWindow(subWindow);
window.setCentralWidget(area);
window.show();
return app.exec();
}
//Update2:
I opened another discussion here.
Ok, I found the problem. It is a bug in the MSVC++ compiler. Installing the service pack and recompiling Qt again helps.