Hello

I'm trying to use taglib in my Qt-program but it won't work. With this code, it doesn't compile although it should because I just changed the parameter a from the example included with the source.

void Test(){
    const char* a = std::string("song.mp3").c_str();
    TagLib::FileRef f(a);
}

When I drop the parameter in the creation of f. it does compile.

What's wrong?

Thanks,

Jasper

is f() defined?
also i recommend checking the arguements to see if you meet all of the required ones like jonsca said.

Edited 6 Years Ago by Anarionist: n/a

From: http://developer.kde.org/~wheeler/taglib/api/classTagLib_1_1FileRef.html

I've never used this library but it seems like you need a file pointer (FILE * like from fopen) for the constructor taking 1 argument. The 3 argument constructor seems to take a filename. When you eliminate the parameter from FileRef you are evoking the default, so itwould go through without a hitch.

This may not be the problem but I figured it was worth noting.

Thank you for your reply but according to the documentation, the last 2 parameters have a default value.
But what I find odd is that the error says it can't find a constructor with a char const* but isn't it supposed to be const char*?

But what I find odd is that the error says it can't find a constructor with a char const* but isn't it supposed to be const char*?

It's a case where the pointer is const but the value of the char is not.
See http://www.daniweb.com/forums/post1094084.html#post1094084 and in fact the whole thread is good. Bad news is, I'm not sure what that means for your filename variable necessarily but try defining the filename variable as char const *

I had thought about the default values thing and as I study it more closely it seems like you are correct about that.

Edited 6 Years Ago by jonsca: n/a


I'm trying to use taglib in my Qt-program but it won't work. With this code, it doesn't compile

<snip>

What's wrong?

Difficult to say, maybe even your compiler is faulty. In this kind of cases, rather post the actual compiler error message(s) along with the offending piece of code.

But what I find odd is that the error says it can't find a constructor with a char const* but isn't it supposed to be const char*?

Those are equivalent, hence you cannot compile e.g. the following

class nocando
{
    nocando(const char * p) 
    {}
    nocando(char const * p) 
    {}
};

By the way, which compiler/version are you using?

Edited 6 Years Ago by mitrmkar: question

Now I've tried the same with the id3lib which actually does the same and I get exactly the same error. I installed it with ./configure then did make and finally sudo make install. No problem there, everything compiled and got installed without errors. (Btw, I'm using mac osx 10.6)

Somewhere on the web I found someone with the same problem and his solution was to add this to the .pro file:

LIBS += /usr/local/lib/libid3.a

But no luck I still get this error:

Running build steps for project ButtonTest...
Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make -w 
make: Entering directory `/Users/jaspermaes/ButtonTest'
g++ -c -pipe -g -gdwarf-2 -arch i386 -Wall -W -DQT_PHONON_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/Library/Frameworks/phonon.framework/Versions/4/Headers -I/usr/include/phonon -I/usr/include -I/usr/include/phonon_compat/phonon -I/usr/include/phonon_compat -I/usr/include/phonon/Phonon -I. -I. -F/Library/Frameworks -o audioplayer.o audioplayer.cpp
g++ -headerpad_max_install_names -arch i386 -o ButtonTest.app/Contents/MacOS/ButtonTest main.o MainWindow.o button.o movebox.o audioplayer.o moc_MainWindow.o moc_movebox.o moc_audioplayer.o -F/Library/Frameworks -L/Library/Frameworks /usr/local/lib/libid3.a -framework phonon -framework QtGui -framework QtCore
ld: warning: in /usr/local/lib/libid3.a, file is not of required architecture
Undefined symbols:
"ID3_Tag::~ID3_Tag()", referenced from:
test() in audioplayer.o
"ID3_Tag::ID3_Tag(char const*)", referenced from:
test() in audioplayer.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [ButtonTest.app/Contents/MacOS/ButtonTest] Error 1
make: Leaving directory `/Users/jaspermaes/ButtonTest'
Exited with code 2.
Error while building project ButtonTest
When executing build step 'Make'

When compiling this code:

void test(){

    const char * a = "/Users/jaspermaes/song.mp3";
    ID3_Tag myTag(a);
}

I don't think I can make a more simple test procedure.
There are 2 lines in the compiler output I don't understand. That is line 7, there it says my architecture isn't right but I compiled the source with this machine and on the website it states osx is supported.
And line 11, I define a as a const char* but why does it get passed as a char const*?

EDIT: I've checked the source and the constructor I call is defined with const char* so it makes even less sense it gets converted to a char const*

Edited 6 Years Ago by Japus: n/a

double check to make sure the version you have is the one for mac i got a similar error the first time i tried to install blender3d using a version made for solaris.

if you know its not the library try to statically link it. and double check to see if your enviroment variables arent interferring with anything.
and try using strings instead of char char takes each character at a time string is more flexible. though your library may not support passing a string there. if the latter is the case then put the mp3 file next to the exectuable and get rid of the levels example /home/name/desktop/beatit.mp3 to beatit.mp3 since its in the same level as the executable all it has to look for is the file name not which level is on it or what permissions you have. sorry if i mess you up. :)

Edited 6 Years Ago by Anarionist: n/a

This article has been dead for over six months. Start a new discussion instead.