Closed PhoebeHui closed 5 years ago
Hello,
As your install/build process you can put the headers anywhere you want to. Preferably in uSockets folder like you say.
Note that the installation process should only copy libusockets.h, libusockets_new.h and interfaces folder. All other files are internal and should not be exposed to uses (the library is completely opaque).
Later on libusockets_new.h will become libusockets.h but never mind that for now
Copy src/*.h and src/interfaces
That should be future proof
Build with LIBUS_USE_LIBUV
@alexhultman, thank you for your quick response!
About 'Build with LIBUS_USE_LIBUV', do you mean building with LIBUS_NO_SSL?
I try to build without 'LIBUS_NO_SSL', it failed with link issue which same issue https://github.com/uNetworking/uSockets/issues/30 mentioned.
Does that mean 'Compile with LIBUS_USE_OPENSSL' doesn't work now? please let me know if I misunderstand something. thank you in advance!
About my suggestion, sorry for the confuse! Give more explanation:
VCPKG installed many pkgs header to installed\x86-windows\include\pkgname, and include installed\x86-windows\include to path, then users can find the headers and dependency headers correctly. If our project dependent on many pkgs, we might do similar thing.
The problem here is: if I put headers to installed\x86-windows\include\usockets, it can’t find the headers under interfaces, since it only include installed\x86-windows\include to path, if I put the interfaces, libusockets.h and libusockets_new.h into .\include folder directly, it might cause conflict with other pkg, they may have same file name.
We expected the structure: ./include/usockets ./include/usockets/interfaces
Add the prefix ‘usockets’ in libusockets.h,
Change
to
In libusockets_new.h Change
to
There's a difference between #include "something"
and #include <something>
.
What you describe would only be a problem if libusockets.h used the #include <>
way of reaching interface/headers, which it doesn't do.
You can read about the rules for MSVC here: https://docs.microsoft.com/en-us/cpp/preprocessor/hash-include-directive-c-cpp?view=vs-2019
Syntax Form | Action |
---|---|
Quoted form | The preprocessor searches for include files in this order:1) In the same directory as the file that contains the #include statement.2) In the directories of the currently opened include files, in the reverse order in which they were opened. The search begins in the directory of the parent include file and continues upward through the directories of any grandparent include files.3) Along the path that's specified by each /I compiler option.4) Along the paths that are specified by the INCLUDE environment variable. |
Angle-bracket form | The preprocessor searches for include files in this order:1) Along the path that's specified by each /I compiler option.2) When compiling occurs on the command line, along the paths that are specified by the INCLUDE environment variable. |
To make extra sure, I tested this in a new VS2017 project. The problem you describe, and the solution to it is correct if I change to the #include <>
way in libusockets.h but does not make sense as is. I could properly include and compile the headers the way you want to:
#include <src/libusockets.h>
int main() {
}
with include directory: C:\Users\Alex\uWebSockets.js\uWebSockets\uSockets
(You would replace "src" folder with whatever prefix you want, such as uSockets)
@alexhultman, thanks for your great library!
Would you mind putting the headers into .\ include\usockets\?
We want to support Usockets in VCPKG for users, we installed the headers to \inlcude\usockets, and the test project couldn’t find related headers since they doesn’t have prefix ‘usockets’ for used headers. If we put the headers directly to .\include, it works, however we have many packages installed, so this might be conflict for some packages.