Re: VS10 and gtkmm



2013/2/4 Doesnt Stop <DoesntStop mail com>:
> Folowing the advice found in:
> https://live.gnome.org/gtkmm/MSWindows/UsingMSVC
> I created a small app to test gtkmm outside GCC, well, even with the help
> from the webpage above I get this error:
>
> 1>------ Build started: Project: MyApp, Configuration: Debug Win32 ------
>
> 1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol
> _WinMain 16 referenced in function ___tmainCRTStartup
> 1>{DRIVE}\myDir\dev\MyApp\Debug\MyApp.exe : fatal error LNK1120: 1
> unresolved externals
> ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Windows has a distinction between console applications and windowed
applications. When compiling a windowed application, you need to
define the function WinMain(). Regular main() will only work for
console applications. The best way to work around this idiotic brain
damage in a portable way is to provide an additional file with the
following content, which is only compiled on Windows:


#include "stdafx.h"

extern int main(int argc, char *argv[]);

int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
   return main(__argc, __argv);
}


Also add <stdlib.h> and <windows.h> to your includes in stdafx.h.

> Code
> ====
> stdafx.h
> ~~~~~
> #ifndef MY_APP
> #define MY_APP
>
> #define WIN32_MEAN_AND_LEAN

This should be WIN32_LEAN_AND_MEAN, otherwise it won't do anything.

> #include <iostream>
> #include <gtkmm.h>
> #endif //MY_APP
> -------------------
>
> main.h
> ~~~~

main.h? This should be main.cpp, and you should #include "stdafx.h".

> int main(int argc, char* argv[]){
>  Gtk::Main kit(argc, argv);
>  Gtk::Window app;
>  Gtk::Main::run(app);
>
>  return 0;
> }

Regards, Krzysztof


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]