As DizzyDon advised, I removed
and inserted
#include <string> #include <vector> #include <list> and #include <cstddef> |
into libBasexCpp.h. This solved many error messages.
After I read somewhere else that you should first create an object file using the command gcc -I ./include -c src/libBasexTest.cpp I saw that all remaining error messages were related to missing object types defined in the local header files. For example Class names (like QueryObject in line 11) or types defined with typedef are missing.
The original source code compiled in Eclipse without error messages. So I assume in the cpp. and h. files there are no errors.
After copying the source code to a new directory I was able to create an so. file without problems using CMake --build and cmake --install.
Compiling libBasexTest.cpp gives error messages all stemming from errors in libBasexCpp.h
So creating libBasexCpp.h is clearly more complicated than copying the public declarations from the local header files into 1 overarching API file.
Therefore, in my response to DizzyDon's answer, I asked where I can find instructions on creating such an API header file.
Ben
Jonnin and seeplus are thanked for the explanation, by the way.
EDIT
After adding the missing #includes <> and adding these typedefs
1 2
|
typedef std::vector<std::vector<std::byte>> VectOfByteVect;
typedef std::vector<std::byte> ByteVect;
| |
all <missing type> errors are gone.
The remaing errors are all related to missing class objects.
My project uses 5 classes: Base, BasexSocket, BasexClient, OueryObject and ResponseObject. Most classes have public and private methods.
This is part of the header file for Base:
1 2 3 4 5 6
|
class Base {
public:
Base(const std::string&, const std::string&, const std::string&, const std::string&);
Base(BasexSocket * socket);
virtual ~Base();
...
| |
.
And this is part of the header file for BasexClient:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
using namespace std;
class BasexClient : public Base {
public:
BasexClient (const std::string&, const std::string&, const std::string&, const std::string&);
virtual ~BasexClient();
void Command(const std::string & command);
void Create(const std::string & dbName, const std::string & content = "");
private:
ResponseObj Response;
...
};
| |
I only want to add to add the public methods from BasexClient, QueryObject and ResponseObject to the library header.
I created a new libBasexCpp.h, copied all the class definitions from the local header files to libBasexCpp.h and deleted all the private members.
I have been experimenting a lot but no mather what I do, every time that a function returns of uses an instance of one of my classes, the compiler still complains about missing types.
How can I define the classes in the API? Is using the Pimpl idiom really the only way to solve this?