You are not logged in.
Pages: 1
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 ]$
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
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
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
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
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
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
edit, to slow.
Last edited by kakTuZ (2009-07-22 12:21:44)
Offline
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
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.
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
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
I can't find that library, I looked everywhere! Why they made C++ so hard...
Offline
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
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
Looks like the library should be called libxmms.
Offline
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
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
It worked!!
Offline
Please edit the topic of this thread to [SOLVED] C++ compile error.
Thanks.
Offline
Pages: 1