[Moved] Compile Errors while using a standard C++ Library
-
wrote on 14 Jan 2012, 08:47 last edited by
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?
-
wrote on 14 Jan 2012, 09:13 last edited by
Welcome to The Forum.
What kind of errors are you getting? How does your pro file look like?
-
wrote on 14 Jan 2012, 09:45 last edited by
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 [6]'
../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 = appSOURCES += main.cpp
mainterm.cpp
portmaster.cpp
markmachine.cpp
globalvar.cppHEADERS += mainterm.h
include/serialportinfo.h
include/serialport.h
portmaster.h
markmachine.h
globalvar.h
iec16022-n.hinclude(src/src.pri)
FORMS += mainterm.ui
OTHER_FILES +=
-
wrote on 14 Jan 2012, 10:13 last edited by
And where are your libraries?
@LIBS += @ -
wrote on 14 Jan 2012, 10:23 last edited by
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.. -
wrote on 14 Jan 2012, 10:45 last edited by
Ok. you can try to cast 'const char*' to 'char* . As you know const char* and char* are not exactly same.
-
wrote on 14 Jan 2012, 19:15 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.
-
wrote on 14 Jan 2012, 19:44 last edited by
Hi Lukas
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. -
wrote on 15 Jan 2012, 14:30 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.
@
// .proINCLUDEPATH += <path-to-library-include-files>
LIBS += -L<path-to-precompiled-library>
LIBS += -l<name-of-precompiled-library>// .cpp
#include "iec16022-n.h"
@
Just make sure you use the same compiler to compile the library and your application.
1/9