Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Moved] Compile Errors while using a standard C++ Library
I am programming in QT Creator with C++. I have a standard library for barcode encoding that i require to use along with the software I am writing. However, when I include the library in my software and compile, I get a lot of errors... Do I need to make changes to the standard C++ Library for using with Qt?
Welcome to The Forum.
What kind of errors are you getting? How does your pro file look like?
The following is the list of errors and warnings..
I had to delete a lot of warnings as the post was too large... but the errors are included...
../serterminal/iec16022-n.h: In function 'char ecc200encode(unsigned char*, int, unsigned char*, int, char*, int*)':
../serterminal/iec16022-n.h:372: warning: comparison between signed and unsigned integer expressions
../serterminal/iec16022-n.h:380: warning: suggest parentheses around '&&' within '||'
../serterminal/iec16022-n.h:411: warning: array subscript has type 'char'
../serterminal/iec16022-n.h:412: warning: array subscript has type 'char'
../serterminal/iec16022-n.h:414: error: invalid conversion from 'const char*' to 'char*'
../serterminal/iec16022-n.h:416: warning: array subscript has type 'char'
../serterminal/iec16022-n.h:423: warning: array subscript has type 'char'
../serterminal/iec16022-n.h:424: warning: array subscript has type 'char'
../serterminal/iec16022-n.h:426: error: invalid conversion from 'const char*' to 'char*'
../serterminal/iec16022-n.h:428: warning: array subscript has type 'char'
../serterminal/iec16022-n.h:429: warning: array subscript has type 'char'
../serterminal/iec16022-n.h:432: error: invalid conversion from 'const char*' to 'char*'
../serterminal/iec16022-n.h:434: warning: array subscript has type 'char'
../serterminal/iec16022-n.h:436: warning: array subscript has type 'char'
../serterminal/iec16022-n.h:449: warning: array subscript has type 'char'
../serterminal/iec16022-n.h: At global scope:
../serterminal/iec16022-n.h:600: warning: missing braces around initializer for 'unsigned char '
../serterminal/iec16022-n.h: In function 'char* encmake(int, unsigned char*, int*, char)':
../serterminal/iec16022-n.h:634: warning: deprecated conversion from string constant to 'char*'
../serterminal/iec16022-n.h:910: warning: array subscript has type 'char'
and my pro file is as follows:
Project created by QtCreator 2011-12-21T12:53:54
QT += core gui
TARGET = serterminal
TEMPLATE = app
SOURCES += main.cpp
HEADERS += mainterm.h
FORMS += mainterm.ui
And where are your libraries?
@LIBS += @
iec16022.h is the only file provided for the library..
This file contains all the functions that I need to call.
It has not been specified as a library..
Ok. you can try to cast 'const char*' to 'char* . As you know const char* and char* are not exactly same.
lgeyer last edited by
This doesn't sound like a Qt Creator related problem. As far as I can judge from the errors and warnings you've posted the library or header file you've got does not fully respect the C++ standard, and the compiler rightly complains about it.
On analysis, I also feel the same way... Now in order to use the library, I am planning to try compile the library using the Linux GCC and the use the same in my program.
Do you feel this approach would be right.. the library that I have is in OpenSource and has been used by many... in fact you can also load the command line utility of the same library in your Linux.
Moreover, I dont know at present how to use a library compiled for Linux with QT.
lgeyer last edited by
It depends. There is no (technical) problem in using the library directly by linking your application against it, but you may run into licensing issues (for example GPL requires you to go GPL or alike for your application as well) which might be avoided by calling it as an external binary.
A proper .pro file is all that needs to be done for linking against external libraries, QProcess can be used to call external binaries.
INCLUDEPATH += <path-to-library-include-files>
LIBS += -L<path-to-precompiled-library>
LIBS += -l<name-of-precompiled-library>
Just make sure you use the same compiler to compile the library and your application.