Use your own built library?!
I built my library "name" -> libname.a
QT -= gui
TARGET = name
TEMPLATE = lib
CONFIG += staticlib
(Also trying with dynamic -> libname.so ... )
This library contains a class
#include <...>
class NAMESHARED_EXPORT ClassName
{
public:
ClassName();
~ClassName();
QString getAttrVal( const int a,
const int b,
const char *data,
QString *description );
...
private:
...
};
NOW IN AN OTHER PROJECT I NEED TO CALL THE FUNCTIONS implemented in this library:
Eg.
.pro
LIBS += -Llib/ -lname
.h
class xxx
{
private:
ClassName *CN;
public:
xxx();
}
.cpp
xxx::xxx(){
CN = new ClassName();
QString test = CN->getAttrVal( 1, 2, "ciao", "bau" );
}
BUT WHEN COMPILE:
/xxx.h:188: error: ISO C++ forbids declaration of ‘ClassName’ with no type
Any suggestion? :confused:
Re: Use your own built library?!
Did you include the header of "ClassName" definition in "other project" ?
Re: Use your own built library?!
I try to include
ClassName.h
and lib/ClassName.h
But no headers found...
Re: Use your own built library?!
Did you set INCLUDEPATH in project pro file ?
Re: Use your own built library?!
ok, thanks! Now it compiles but when trying to run:
error while loading shared libraries: libname.so.1: cannot open shared object file: No such file or directory
Re: Use your own built library?!
If your library is dynamic link you should remove "CONFIG += staticlib" from project file. Also if library is static link, remove NAMESHARED_EXPORT from class definition if this define is __declspec(dllexport)