LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-18-2012, 04:13 AM   #1
sanehussain
LQ Newbie
 
Registered: Feb 2012
Posts: 1

Rep: Reputation: Disabled
Compiling a C program with openGL, GLEW and GTK in ubuntu.


I am writing a C program, which uses openGL and GTK for the GUI(There are 2 separate windows). It also uses GLEW. Currently I am using the following command to compile it:

gcc `pkg-config --cflags --libs gtk+-2.0` main.cpp -o hello -lglut -lGL -lGLEW

And these are the errors I am getting:

/tmp/cca4mYJB.o: In function `initGuiWindow()':
main.cpp:(.text+0xf8): undefined reference to `gtk_builder_new'
main.cpp:(.text+0x11a): undefined reference to `gtk_builder_add_from_file'
main.cpp:(.text+0x11f): undefined reference to `gtk_widget_get_type'
main.cpp:(.text+0x136): undefined reference to `gtk_builder_get_object'
main.cpp:(.text+0x142): undefined reference to `g_type_check_instance_cast'
main.cpp:(.text+0x15c): undefined reference to `gtk_builder_connect_signals'
/tmp/cca4mYJB.o: In function `show()':
main.cpp:(.text+0x175): undefined reference to `gtk_widget_show'
/tmp/cca4mYJB.o: In function `on_btn_color_color_set(_GtkColorButton*, void*)':
main.cpp:(.text+0x9b6): undefined reference to `gtk_color_button_get_color'
/tmp/cca4mYJB.o: In function `on_circ_segments_value_changed(_GtkSpinButton*, void*)':
main.cpp:(.text+0xb9a): undefined reference to `gtk_spin_button_get_value'
/tmp/cca4mYJB.o: In function `guiSetStatusbarText(char const*)':
main.cpp:(.text+0xc29): undefined reference to `gtk_statusbar_push'
/tmp/cca4mYJB.o: In function `get_statusbar()':
main.cpp:(.text+0xc4b): undefined reference to `gtk_builder_get_object'
/tmp/cca4mYJB.o: In function `get_message_context_id(_GtkStatusbar*)':
main.cpp:(.text+0xc66): undefined reference to `gtk_statusbar_get_context_id'
/tmp/cca4mYJB.o: In function `clear_statusbar_text_private(_GtkStatusbar*, int)':
main.cpp:(.text+0xc94): undefined reference to `gtk_statusbar_remove'
/tmp/cca4mYJB.o: In function `guiInit(int*, char**)':
main.cpp:(.text+0xcb8): undefined reference to `gtk_init'
/tmp/cca4mYJB.o: In function `guiMainIteration()':
main.cpp:(.text+0xccc): undefined reference to `gtk_main_iteration_do'
/tmp/cca4mYJB.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0xcef): undefined reference to `operator new[](unsigned int)'
collect2: ld returned 1 exit status


I don't know what mistake I am making. Can somebody please help me out?
 
Old 02-18-2012, 09:07 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Well, because nobody else has responded...

Quote:
gcc `pkg-config --cflags --libs gtk+-2.0` main.cpp -o hello -lglut -lGL -lGLEW
Quote:
Code:
main.cpp:(.text+0xcef): undefined reference to `operator new[](unsigned int)'
I don't use gcc to compile C++ code. When I say "gcc" I mean the specific executable--not the compiler collection.

I always use g++ to compile C++ code. The g++ executable should come with your gcc install. And, given that the linker is complaining about the "new" operator (a fundamental C++ operator), it seems like there's a basic/fundamental issue (e.g. using an incorrect compiler).

Try with g++ and see where it gets you.

There may be some relationship between gcc and g++ (apart from being in the same compiler collection). For instance, g++ may simply be gcc with a specific set of command line options automatically applied. Though, I'm not familiar enough with them to say there is or is not such a relationship.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Compiling a program both for Fedora and Ubuntu mrJones Linux - Software 13 08-02-2010 12:36 PM
Problems Compiling/Running a Program on Ubuntu 8.10 Akinjide Linux - Software 1 09-24-2009 02:22 PM
GTK-Critical error compiling a smart program (with menu) clarci Programming 1 06-18-2009 03:58 PM
Missing header GLTK in compiling an openGL program BorgAssimilator Programming 1 01-23-2006 09:07 PM
compiling kino, gtk test program cant run vance Linux - Software 1 06-02-2003 04:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration