2

I use id3Tag library for my project. I set headers and libraries successfully on Linux and compiled without troubles, but I have some troubles with moving code to Windows. (I only started to study Windows, so sorry in advance for my possible ignorance). My environment is Qt Creator

The problem is with headers from id3 tag library (there are no such problems on Linux!) My .pro file is: enter image description here

My errors are: enter image description here

It's compiled perfectly if I don't include that header "id3/tag.h". What can be a reason? Actually I never programmed for Windows yet.
My steps are:
1. I complied part of code for Linux
2.Copied folder with source code that was successful compiled under Linux to Windows (headers are lying in the current folder).
3. Compiled code without that header ("id3/tag.h").
4. Added that header ("id3/tag.h")
5. And got a ton of complains from compiler

Thanks in advance, for any tips!

3
  • Just a guess: Shouldn't it be LIBS += -lid3 instead of -id3? Because it's LIBS += -l<libraryname> -L<librarypath> Commented Aug 14, 2012 at 22:51
  • no no, it doesn't even reach link stage. It fails on compilation stage. By the way I tried- unfortunately no Commented Aug 14, 2012 at 23:15
  • There are two important hints in the compile errors: You should read win32.readme.first.txt and you should add a preprocessor definition to your .pro file (with DEFINES +=) Commented Aug 14, 2012 at 23:42

3 Answers 3

2

You should read the compiler's messages more carefully. It says to read win32.readme.first.txt, so I suggest you to read it and set your build environment to the way you want to link the library.

It fails to compile because you have not set ID3LIB_LINKOPTION, resulting in the header not defining ID3_CPP_EXPORT. However, this is required to initialize ID3_Frame. See id3\globals.h for more details.

Sign up to request clarification or add additional context in comments.

Comments

1

There is perhaps a problem with the separator ('\' on Windows and '/' on Linux) on your .pro file. So try this in your project file :

#TEMPLATE, CONFIG, HEADERS, ...

win32 { # For Windows
    # Leave an empty line because of the backslash at the end of the variable
    SEPARATOR = \\

}

linux-g++ { # For Linux
    SEPARATOR = /
}

ID3_FOLDER = .$${SEPARATOR}idlib$${SEPARATOR}id3lib-3.8.3$${SEPARATOR}

LIBS += -id3 -L$${ID3_FOLDER}src$${SEPARATOR}.libs

INCLUDEPATH += $${ID3_FOLDER}include $${ID3_FOLDER}src$${SEPARATOR}.libs

Edit : it is about the flag of your library. If the file containing it is called myLib.dll on Windows (or myLib.so on Linux), you should write -lmyLib. In your project file , I don't see somthing like -lsthg but -id3.

Comments

0

Thanks you for responses! I marked one of the answers as appropriate and I add this answer for clarifying what kind of problem I had exactly.

All that I did to fix problem:

I defined in the main.cpp (main file with source code from that all programme is controlled)

    #define ID3LIB_LINKOPTION 3
    #define ID3_CPP_EXPORT 1

After that I got near 42 errors, but fortunately, they were new. enter image description here

I found what's wrong only thanks to intuition (maybe), because internet is overloaded with such type errors, but they don't throw any light at the cause of the problem.

I defined header windows.h in the main.cpp (but it has to be before any other header, otherwise zillions of errors, who could think about! )

So, the first lines of your main.cpp file should look like:

    #define ID3LIB_LINKOPTION 3
    #define ID3_CPP_EXPORT 1
    #include <windows.h>
    #include "id3/tag.h"

And it works fine. Hope this will help someone at one day.

DON"T TRY TO USE THAT LIBRARY FROM QtCREATOR !!!! only VS studio c++, I spent many time trying to compile it with Mingw compiler,but source code that is compiled with Mingw can't be linked with libraries generated by microsoft visual studio because of different ABIs

1 Comment

Although you can place this definitions in the source code, the more common way is to use compiler options to add definitions. If you are using gcc this can be specified by -D option, msvc has /D option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.