You are not logged in.

#1 2009-07-22 10:51:05

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

[Solved] C++ compile error

I'm playing with C++ today and I'm trying to stop xmms. This is my code

#include <iostream>
#include <xmms/xmmsctrl.h>

using namespace std;

int main()
{
    xmms_remote_stop;
    return 0;
}

and this is what happens when I try to compile it

[~/cpp ]$ g++ temp.cpp 
In file included from temp.cpp:2:
/usr/include/xmms/xmmsctrl.h:23:18: error: glib.h: No such file or directory
In file included from temp.cpp:2:
/usr/include/xmms/xmmsctrl.h:29: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:30: error: variable or field 'xmms_remote_playlist' declared void
/usr/include/xmms/xmmsctrl.h:30: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:30: error: 'gchar' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:30: error: 'list' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:30: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:30: error: 'gboolean' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:31: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:32: error: variable or field 'xmms_remote_playlist_add' declared void
/usr/include/xmms/xmmsctrl.h:32: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:32: error: 'GList' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:32: error: 'list' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:33: error: variable or field 'xmms_remote_playlist_delete' declared void
/usr/include/xmms/xmmsctrl.h:33: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:33: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:34: error: variable or field 'xmms_remote_play' declared void
/usr/include/xmms/xmmsctrl.h:34: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:35: error: variable or field 'xmms_remote_pause' declared void
/usr/include/xmms/xmmsctrl.h:35: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:36: error: variable or field 'xmms_remote_stop' declared void
/usr/include/xmms/xmmsctrl.h:36: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:37: error: 'gboolean' does not name a type
/usr/include/xmms/xmmsctrl.h:38: error: 'gboolean' does not name a type
/usr/include/xmms/xmmsctrl.h:39: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:40: error: variable or field 'xmms_remote_set_playlist_pos' declared void
/usr/include/xmms/xmmsctrl.h:40: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:40: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:41: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:42: error: variable or field 'xmms_remote_playlist_clear' declared void
/usr/include/xmms/xmmsctrl.h:42: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:43: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:44: error: variable or field 'xmms_remote_jump_to_time' declared void
/usr/include/xmms/xmmsctrl.h:44: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:44: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:45: error: variable or field 'xmms_remote_get_volume' declared void
/usr/include/xmms/xmmsctrl.h:45: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:45: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:45: error: 'vl' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:45: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:45: error: 'vr' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:46: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:47: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:48: error: variable or field 'xmms_remote_set_volume' declared void
/usr/include/xmms/xmmsctrl.h:48: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:48: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:48: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:49: error: variable or field 'xmms_remote_set_main_volume' declared void
/usr/include/xmms/xmmsctrl.h:49: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:49: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:50: error: variable or field 'xmms_remote_set_balance' declared void
/usr/include/xmms/xmmsctrl.h:50: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:50: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:51: error: expected constructor, destructor, or type conversion before '*' token
/usr/include/xmms/xmmsctrl.h:52: error: variable or field 'xmms_remote_set_skin' declared void
/usr/include/xmms/xmmsctrl.h:52: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:52: error: 'gchar' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:52: error: 'skinfile' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:53: error: expected constructor, destructor, or type conversion before '*' token
/usr/include/xmms/xmmsctrl.h:54: error: expected constructor, destructor, or type conversion before '*' token
/usr/include/xmms/xmmsctrl.h:55: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:56: error: variable or field 'xmms_remote_get_info' declared void
/usr/include/xmms/xmmsctrl.h:56: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:56: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:56: error: 'rate' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:56: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:56: error: 'freq' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:56: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:56: error: 'nch' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:57: error: variable or field 'xmms_remote_main_win_toggle' declared void
/usr/include/xmms/xmmsctrl.h:57: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:57: error: 'gboolean' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:58: error: variable or field 'xmms_remote_pl_win_toggle' declared void
/usr/include/xmms/xmmsctrl.h:58: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:58: error: 'gboolean' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:59: error: variable or field 'xmms_remote_eq_win_toggle' declared void
/usr/include/xmms/xmmsctrl.h:59: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:59: error: 'gboolean' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:60: error: 'gboolean' does not name a type
/usr/include/xmms/xmmsctrl.h:61: error: 'gboolean' does not name a type
/usr/include/xmms/xmmsctrl.h:62: error: 'gboolean' does not name a type
/usr/include/xmms/xmmsctrl.h:63: error: variable or field 'xmms_remote_show_prefs_box' declared void
/usr/include/xmms/xmmsctrl.h:63: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:64: error: variable or field 'xmms_remote_toggle_aot' declared void
/usr/include/xmms/xmmsctrl.h:64: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:64: error: 'gboolean' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:65: error: variable or field 'xmms_remote_eject' declared void
/usr/include/xmms/xmmsctrl.h:65: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:66: error: variable or field 'xmms_remote_playlist_prev' declared void
/usr/include/xmms/xmmsctrl.h:66: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:67: error: variable or field 'xmms_remote_playlist_next' declared void
/usr/include/xmms/xmmsctrl.h:67: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:68: error: variable or field 'xmms_remote_playlist_add_url_string' declared void
/usr/include/xmms/xmmsctrl.h:68: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:68: error: 'gchar' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:68: error: 'string' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:69: error: 'gboolean' does not name a type
/usr/include/xmms/xmmsctrl.h:70: error: variable or field 'xmms_remote_toggle_repeat' declared void
/usr/include/xmms/xmmsctrl.h:70: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:71: error: variable or field 'xmms_remote_toggle_shuffle' declared void
/usr/include/xmms/xmmsctrl.h:71: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:72: error: variable or field 'xmms_remote_toggle_advance' declared void
/usr/include/xmms/xmmsctrl.h:72: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:73: error: 'gboolean' does not name a type
/usr/include/xmms/xmmsctrl.h:74: error: 'gboolean' does not name a type
/usr/include/xmms/xmmsctrl.h:75: error: 'gboolean' does not name a type
/usr/include/xmms/xmmsctrl.h:76: error: variable or field 'xmms_remote_get_eq' declared void
/usr/include/xmms/xmmsctrl.h:76: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:76: error: 'gfloat' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:76: error: 'preamp' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:76: error: 'gfloat' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:76: error: 'bands' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:77: error: 'gfloat' does not name a type
/usr/include/xmms/xmmsctrl.h:78: error: 'gfloat' does not name a type
/usr/include/xmms/xmmsctrl.h:79: error: variable or field 'xmms_remote_set_eq' declared void
/usr/include/xmms/xmmsctrl.h:79: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:79: error: 'gfloat' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:79: error: 'gfloat' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:79: error: 'bands' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:80: error: variable or field 'xmms_remote_set_eq_preamp' declared void
/usr/include/xmms/xmmsctrl.h:80: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:80: error: 'gfloat' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:81: error: variable or field 'xmms_remote_set_eq_band' declared void
/usr/include/xmms/xmmsctrl.h:81: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:81: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:81: error: 'gfloat' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:83: error: variable or field 'xmms_remote_quit' declared void
/usr/include/xmms/xmmsctrl.h:83: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:85: error: variable or field 'xmms_remote_play_pause' declared void
/usr/include/xmms/xmmsctrl.h:85: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:86: error: variable or field 'xmms_remote_playlist_ins_url_string' declared void
/usr/include/xmms/xmmsctrl.h:86: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:86: error: 'gchar' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:86: error: 'string' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:86: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:88: error: variable or field 'xmms_remote_playqueue_add' declared void
/usr/include/xmms/xmmsctrl.h:88: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:88: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:89: error: variable or field 'xmms_remote_playqueue_remove' declared void
/usr/include/xmms/xmmsctrl.h:89: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:89: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:90: error: variable or field 'xmms_remote_playqueue_clear' declared void
/usr/include/xmms/xmmsctrl.h:90: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:91: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:92: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:93: error: 'gint' does not name a type
/usr/include/xmms/xmmsctrl.h:101: error: variable or field 'xmms_remote_play_files' declared void
/usr/include/xmms/xmmsctrl.h:101: error: 'gint' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:101: error: 'GList' was not declared in this scope
/usr/include/xmms/xmmsctrl.h:101: error: 'list' was not declared in this scope
temp.cpp: In function 'int main()':
temp.cpp:8: error: 'xmms_remote_stop' was not declared in this scope
[~/cpp ]$

lol
Why? How do I do that? I'm just beginning to learn C++, so don't laugh at me.

Last edited by Boris Bolgradov (2009-07-22 20:03:23)

Offline

#2 2009-07-22 11:21:35

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,400
Website

Re: [Solved] C++ compile error

The errors all stem from this:

/usr/include/xmms/xmmsctrl.h:23:18: error: glib.h: No such file or directory

This is provided by glib2 so you want to use something like

g++ `pkg-config --cflags --libs glib-2.0` code.cpp

Offline

#3 2009-07-22 11:39:54

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: [Solved] C++ compile error

Thanks for the reply.
It compiled successfully, but when i run it nothing happens

[~/cpp ]$ g++ `pkg-config --cflags --libs glib-2.0` temp.cpp
[~/cpp ]$ ./a.out 
[~/cpp ]$

Why is that? Am I calling the "xmms_remote_stop" function wrong?

Offline

#4 2009-07-22 11:44:19

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,400
Website

Re: [Solved] C++ compile error

I'm guessing it is supposed to be a function so it should be at least "xmms_remote_stop();", but it may need parameters.  You will need to look that up.

Offline

#5 2009-07-22 12:05:04

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: [Solved] C++ compile error

Hm... It needs a session as parameter. Calling it without parameters returns:

/usr/include/xmms/xmmsctrl.h:36: error: too few arguments to function 'void xmms_remote_stop(gint)'

This is line 36 in xmmsctrl.h:

void xmms_remote_stop(gint session);

I passed "gint 0" as parameter and tried to compile. This is what I get:

temp.cpp:5: error: expected primary-expression before numeric constant

And also, what is gint? I know what int is, but gint?

Offline

#6 2009-07-22 12:14:58

scio
Member
From: Buffalo, NY
Registered: 2008-08-05
Posts: 366

Re: [Solved] C++ compile error

Just do:

xmms_remote_stop(0);

I believe in most situations ginit is:

typedef int gint;

but always use a gint if you are passing it into a function that requires one.

Offline

#7 2009-07-22 12:21:17

kakTuZ
Member
From: Hannover, Germany
Registered: 2007-10-20
Posts: 86

Re: [Solved] C++ compile error

edit, to slow.

Last edited by kakTuZ (2009-07-22 12:21:44)

Offline

#8 2009-07-22 12:25:15

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: [Solved] C++ compile error

With xmms_remote_stop(0);

[~/cpp ]$ g++ `pkg-config --cflags --libs glib-2.0` temp.cpp
/tmp/ccsJ8V8N.o: In function `main':
temp.cpp:(.text+0x19): undefined reference to `xmms_remote_stop'
collect2: ld returned 1 exit status
[~/cpp ]$

This function requires gint, no? Not sure if I'm using gint right:

#include <xmms/xmmsctrl.h>

int main()
{
    typedef int gint;
    gint session = 0;

    xmms_remote_stop(session);
    return 0;
}

This returns same as xmms_remote_stop(0)

Last edited by Boris Bolgradov (2009-07-22 12:27:17)

Offline

#9 2009-07-22 12:28:35

scio
Member
From: Buffalo, NY
Registered: 2008-08-05
Posts: 366

Re: [Solved] C++ compile error

Boris Bolgradov wrote:

With xmms_remote_stop(0);

[~/cpp ]$ g++ `pkg-config --cflags --libs glib-2.0` temp.cpp
/tmp/ccsJ8V8N.o: In function `main':
temp.cpp:(.text+0x11): undefined reference to `xmms_remote_stop'
collect2: ld returned 1 exit status
[~/cpp ]$

You need to add the xmms library to your list of libs, I don't know what it is but that is why you are getting the link errors.

Boris Bolgradov wrote:

This function requires gint, no? Not sure if I'm using gint right:

#include <xmms/xmmsctrl.h>

int main()
{
    typedef int gint;
    gint session = 0;

    xmms_remote_stop(session);
    return 0;
}

This returns same as xmms_remote_stop(0)

Nope, just try this:

#include <xmms/xmmsctrl.h>

int main()
{
    gint session = 0;

    xmms_remote_stop(session);
    return 0;
}

the gint type is already defined for you, I was just saying what it most likely actually is.

Offline

#10 2009-07-22 13:14:28

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: [Solved] C++ compile error

scio wrote:

You need to add the xmms library to your list of libs, I don't know what it is but that is why you are getting the link errors.

How to do that?

edit: oh, wait... stupid question

Last edited by Boris Bolgradov (2009-07-22 13:19:54)

Offline

#11 2009-07-22 14:07:40

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: [Solved] C++ compile error

I can't find that library, I looked everywhere! sad Why they made C++ so hard... sad

Offline

#12 2009-07-22 14:35:49

majiq
Member
Registered: 2009-03-06
Posts: 259

Re: [Solved] C++ compile error

I might suggest in this case to do some reading up: http://library.gnome.org/devel/gtk-tutorial/stable/. It'll help you to understand what is "gint" and how to find the session id properly, I think (you can ignore all the graphical stuff if you're not interested). Also, maybe you should use an intermediary so you don't have to go digging around for the xmms api: http://modplug-xmms.sourceforge.net/. In fact, I cannot find an xmms api. You could also try seeing how other plugins use xmms  and how they're compiled to figure out how to compile your program.

Offline

#13 2009-07-22 15:07:06

alienman
Member
From: Mexico
Registered: 2008-07-08
Posts: 106

Re: [Solved] C++ compile error

And C++ isn't that hard really. But you may need some more background if you're coming from other languages such as Java or C#. At the beginning I also thought it was complicated, but at the end it resulted that I was so blind trying to code Java style.


ISC - Ignacio Marmolejo
ArchLinux & GNOME User.

Offline

#14 2009-07-22 16:07:58

scio
Member
From: Buffalo, NY
Registered: 2008-08-05
Posts: 366

Re: [Solved] C++ compile error

Looks like the library should be called libxmms.

Offline

#15 2009-07-22 16:31:15

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: [Solved] C++ compile error

scio wrote:

Looks like the library should be called libxmms.

Yes, I found that too. Adding #include <libxmms> says file is missing and #include "/usr/lib/libxmms.so" prints many errors about "null character(s) ignored". I don't know how to add that library.

Offline

#16 2009-07-22 16:38:43

wuischke
Member
From: Suisse Romande
Registered: 2007-01-06
Posts: 630

Re: [Solved] C++ compile error

There's a difference between including and linking.

Including basically replaces the line "#include <file.h>" with the content of the file, i.e. changes the source code.

Linking on the other hand combines machine code. 'ld' is the linker program, so the error comes from a missing library when linking.

Please try the following:

g++ `pkg-config --cflags --libs glib-2.0` -lxmms temp.cpp

Offline

#17 2009-07-22 16:45:21

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: [Solved] C++ compile error

It worked!! big_smile

Offline

#18 2009-07-22 19:45:51

scio
Member
From: Buffalo, NY
Registered: 2008-08-05
Posts: 366

Re: [Solved] C++ compile error

Please edit the topic of this thread to [SOLVED] C++ compile error.

Thanks.

Offline

Board footer

Powered by FluxBB