i install libgtkmm-3.0-dev in ubuntu 12.04 and i try to learn and write program with c++ and gtkmm 3
i go to this link "http://developer.gnome.org/gtkmm-tutorial/unstable/sec-basics-simple-example.html.en" and try to compile simple example program :
#include <gtkmm.h>
int main(int argc, char *argv[])
{
Glib::RefPtr<Gtk::Application> app =
Gtk::Application::create(argc, argv,
"org.gtkmm.examples.base");
Gtk::ApplicationWindow window;
return app->run(window);
}
my file name is "basic.cc" and i open terminal and type following command to compile:
g++ basic.cc -o basic `pkg-config gtkmm-3.0 --cflags --libs`
compile completed without any error but when i try to run program with type ./basic in terminal i get following error :
~$ ./simple
./simple: symbol lookup error: ./simple: undefined symbol:_ZN3Gtk11Application6createERiRPPcRKN4Glib7ustringEN3Gio16ApplicationFlagsE
~$
how can i solve this problem ?
i can cimpile any gtkmm 2.4 code with this command : " g++ basic.cc -o basic pkg-config gtkmm-3.0 --cflags --libs "
and this command : " g++ basic.cc -o basic pkg-config gtkmm-2.4 --cflags --libs "
thanks
I think you hit this gtkmm bug, apparently triggered by more recent versions of GTK+, and now fixed:
https://bugzilla.gnome.org/show_bug.cgi?id=681323
I have asked Ubuntu to update their package, but they are usually slow about that if they do it at all:
https://bugs.launchpad.net/ubuntu/+source/gtkmm3.0/+bug/1046469
You might want to try reinstalling libgtkmm-3.0-dev. The code compiles fine for me but I get a Seg Fault. It does work when I change Gtk::ApplicationWindow to Gtk::Window.
there is nothing wrong with your install. that code is bad.
try it again, using
Gtk::Window window;
instead of the ApplicationWindow. When the GNOME documentation for a given class has a description of "TODO", that's a bad thing.
Related
I am having trouble installing a dependency for a program that itself depends on pcre.h. I have this installed to /opt/local/include, but the C compiler does not see it and thus gives me:
error: pcre.h: No such file or directory
I have confirmed this by writing a hello world program that tries to include it:
#include <pcre.h>
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
return 0;
}
This also gives the error unless I specify the path as </opt/local/include/pcre.h>.
I would like the C compiler to find this by default but I do not know where this is configured. Tab completion hasn't revealed any HEADER_PATH environment variables and I cannot find anything like it that isn't specific to XCode. I am, however, using Mac OSX Snow Leopard on the off chance that makes a difference.
Use -I /opt/local/include on the command line or C_INCLUDE_PATH=/opt/local/include in the environment.
Use the pcre-config utility to get the right flags:
$ pcre-config --libs --cflags
-L/opt/local/lib -lpcre
-I/opt/local/include
If you're compiling via the command line,
$ gcc -Wall -g `pcre-config --libs --cflags` main.c
I'm trying to compile my GTK+ 3 (using gtkmm3) program under windows.
After setting everything up, I now get the following error:
Error: Aggregate »GStatBuf sbuf« has incomplete type and cannot be defined
GStatBuf sbuf;
The same code compiles fine under linux.
Here is the Code that causes the trouble:
GStatBuf sbuf;
if(g_stat(some_c_string, &sbuf) == 0) {
some_var = sbuf.st_mtim.tv_sec;
I'm compiling my program using the following command:
/usr/bin/g++ Patte.cpp -o Patte -L/opt/lib `pkg-config gstreamer-1.0 gstreamer-video-1.0 gtkmm-3.0 --cflags --libs`
I would appreciate any help on this issue :)
Edit: The error occurs pretty deep into the program, so I am pretty sure that nothing that is included is missing.
As of late I have been getting the following error whenever I try to compile any program that uses the open cv libraries, I use g++ to compile:
g++ Example.cpp -o Ex `pkg-config opencv --cflags --libs`
No matter the content of the file (I have checked with programs that worked a couple of weeks ago) I always get the following error:
/usr/lib64/libX11.so.6: undefined reference to `xcb_poll_for_reply64'
/usr/lib64/libX11.so.6: undefined reference to `xcb_wait_for_reply64'
Do you have any idea of what might be the cause? (and how to fix it)
An example program that fails to compile:
#include "path/opencv2/highgui/highgui.hpp"
#include "path/opencv/highgui.h"
using namespace cv;
int main (int argc, char * argv[])
{
Mat image = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE) ;
return 0;
}
Add -lxcb to your command line (this will instruct the linker linking w/ the xcb library). Please make sure the 64b version of xcb is in the linker path (you can always put it explicitly via the -L switch)
The error was caused by some changes done to the libX11.so.6, talked with the FE machines support and they fixed it.
what I'm including wrong ?
I am using codeblocks + allegro5 + ubuntu 11.10
and getting this 2 errors
undefined reference to 'al_init_image_addon'
undefined reference to `al_init_primitives_addon'|
I did install allegro5 correctly with all the dependencies. The first tutorial on loading the allegro.h works fine, it creates a normal window apart from the xterm window.
I am following the "show in fullscreen tutorial" from the allegro wiki
#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"
#include <allegro5/allegro_primitives.h>
#include "allegro5/allegro_native_dialog.h"
int main()
{
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_DISPLAY_MODE disp_data;
al_init();
al_init_image_addon(); // <---------ERROR HERE
al_init_primitives_addon();// < --------ERROR HERE TOO
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;
}
In the event anyone has this issue, the fix is adding allegro_image-5.0 to your pkg-config path e.g.:
gcc game.c -o game $(pkg-config --cflags --libs allegro-5.0 allegro_image-5.0)
well, after doing a little google search and posting at allegro's homepage I got the correct answer,
I was missing the .so files in the linker section under TOOLS > Compiler&DEbugger > LINKER.
I had to add these lines
/usr/lib/liballegro_dialog.so
/usr/lib/liballegro_color.so
/usr/lib/liballegro_audio.so
/usr/lib/liballegro_image.so
/usr/lib/liballegro_physfs.so
/usr/lib/liballegro.so
/usr/lib/liballegro_font.so
/usr/lib/liballegro_acodec.so
/usr/lib/liballegro_main.so
/usr/lib/liballegro_memfile.so
/usr/lib/liballegro_primitives.so
/usr/lib/liballegro_ttf.so
and `pkg-config --libs allegro-5.0`
see this post for the screenshot.
http://hongouru.blogspot.com/2012/02/solved-allegro5-undefined-reference-to.html
What flags do I need to add to g++ in order to compile code using allegro 5? I tried
g++ allegro5test.cpp -o allegro5test `allegro-config --libs`
but that is not working. I'm using ubuntu 11.04. I installed allegro 5 using the instructions at http://wiki.allegro.cc/index.php?title=Install_Allegro5_From_SVN/Linux/Debian
I tried:
g++ allegro5test.cpp -o allegro5test `allegro-config --cflags --libs`
And it also gives a bunch of undefined errors, like: undefined reference to `al_install_system'
allegro-config --cflags --libs outputs:
-I/usr/local/include
-L/usr/local/lib -lalleg
So you successfully installed allegro5 on your system from the SVN. One thing you should know is that this build doesn't come with allegro-config. If you have it on your system it means you have previously installed allegro4.
allegro5 brings many changes, including different initialization procedures, library and function names.
Here's a hello world application for new version:
#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;
}
Notice how the command to compile this application refers to another include directory and library names, which are different from the previous version of allegro:
g++ hello.cpp -o hello -I/usr/include/allegro5 -L/usr/lib -lallegro
Allegro 5 uses pkg-config.
pkg-config --libs allegro-5.0 allegro_image-5.0
And so on for each library you are using.