Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Create c++ library with QT Creator #1

Closed
EuleHaken opened this issue Jul 4, 2022 · 2 comments
Closed

Create c++ library with QT Creator #1

EuleHaken opened this issue Jul 4, 2022 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@EuleHaken
Copy link
Owner

EuleHaken commented Jul 4, 2022

So I made two projects for this example. The first one, lets say this is my project I want to work on, is named here example_for_libraries. The other project, which should become a shared library, which I can then use in my example_for_libraries project, is called asdXdShared (ignore the naming, it's all just supposed to be a simple example).

Here is the asdXdShared.pro file:
image
It is located inside the asdXdShared project folder (ignore the path at the top)

Here is the asdXdShared.pri file, which is located inside example_for_libraries/libs/asdXdShared.pri:
image

I include this .pri file in my project (example_for_libraries) like this:
image

This is the file example_for_libraries.pro located in the project path of the project example_for_libraries.

This is how the build tree looks like for the example_for_libraries project:
image

And this is the build tree for the asdXdShared project:
image

These are the same trees just as type file system I think:
(example_for_libraries)
image

(asdXdShared)
image

Now, in my project (example_for_libraries) I can do this, in, e.g. file main.cpp:
image

Note the include path! It contains libs/asdXdShared and then the actual AsdXdShared.hpp file

That is exactly what I dont want.

I want to be able to include the files like this:
#include "AsdXdShared.hpp"

What do I need to to, or what do I need to specifiy, so that I am able to do this?



I took some inspiration from the communi/libcommuni project, for which you can just do:
#include "IrcConnection.hpp"
For example, and not:
#include "libs/libcommuni/src/core/IrcConnection.hpp"

By adding a file like, e.g. libs/libcommuni.pri containing this into your project folder (or project/libs folder):
image

@EuleHaken EuleHaken added the help wanted Extra attention is needed label Jul 4, 2022
@EuleHaken
Copy link
Owner Author

Ok, I did this in the asdXdShared.pro file:
image

Now, I am able to include the headers file from this project like this, for example, which I want:
image

The build tree as file system looks like this for project asdXdShared:
image

However, now, when I want to add new files to the project, I have to change the path for the header/source files in the asdXdShared.pro file and I have to prepend them with a $$PWD/ like this:
image

Is this really the right way? Or am I on a completely different path? :/

@EuleHaken EuleHaken transferred this issue from another repository Jul 6, 2022
@EuleHaken
Copy link
Owner Author

EuleHaken commented Jul 6, 2022

This issue was transfered to here.

Basically, the project asdXdShared is now supposed to be this WebSocket project.

As said, I prepended the paths to Sources and Headers files with $$PWD, but still, I am unsure if this is the correct way.

Any feedback, whether this is right or wrong, would be appreciated.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant