Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How build this project in CMake for Visual Studio 2019 #111

Open
klasik16 opened this issue May 8, 2019 · 13 comments
Open

How build this project in CMake for Visual Studio 2019 #111

klasik16 opened this issue May 8, 2019 · 13 comments

Comments

@klasik16
Copy link

klasik16 commented May 8, 2019

Hello I tried build that framework and use it in my c application but actually I don't know how to build it and implement it in my visual studio project.

Cmake throwing an error about mussing libruary. i'm on windows 64bit

@babelouest
Copy link
Owner

Hello,

I don't work with Visual Studio so I will need more information in order to help you.

You mention a missing library, so you must first install all dependencies (except for libsystemd which isn't available on Windows).
At least libmicrohttpd is required.

I suggest you go through the install documentation, to make sure you have all the required dependencies you need, and setup the build options to fit your needs, like when using cmake to build Ulfius, you must use at least the following options: -DWITH_JOURNALD=off -DWITH_WEBSOCKET=off

If you still have problems to build Ulfius, then answer with at least a print screen of your error messages, and other information that might be useful.

@klasik16
Copy link
Author

klasik16 commented May 8, 2019

Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
The C compiler identification is MSVC 19.20.27508.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Looking for GNU_LIBRARY
Looking for GNU_LIBRARY - not found
Looking for _GNU_SOURCE
Looking for _GNU_SOURCE - not found
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
Could NOT find GnuTLS (missing: GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR)
CMake Error at C:/Program Files/CMake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find GnuTLS (missing: GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.14/Modules/FindGnuTLS.cmake:55 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:90 (find_package)

Configuring incomplete, errors occurred!
See also "C:/Users/PC/Desktop/ulf/CMakeFiles/CMakeOutput.log".
See also "C:/Users/PC/Desktop/ulf/CMakeFiles/CMakeError.log".

@babelouest
Copy link
Owner

The message you emphasize is not an error message, it's more an information that GNU_LIBRARY and _GNU_SOURCE are not present, which seems normal for a windows system.
I'd focus more on the following error message:

 Could NOT find GnuTLS (missing: GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR)

So, as I said earlier, you must install all the required libraries first:

  • libmicrohttpd (mandatory)
  • gnutls (optional)
  • libjansson (optional)
  • libcurl (optional)

Or disable the optional libraries you don't have/want in cmake build options.

@klasik16
Copy link
Author

klasik16 commented May 8, 2019

Okay i got that i need libs to use framework... Any idea how install them on windows? Im really new in application development so please don't rush on me... thank you for yours explanation. I'm learning every day maybe you can point me where to look? What for google...?

@babelouest
Copy link
Owner

I suggest you install libmicrohttpd only for starters: https://www.gnu.org/software/libmicrohttpd/
Section Downloading Libmicrohttpd/Windows

Then build Ulfius with the following cmake options: -DWITH_JOURNALD=off -DWITH_WEBSOCKET=off -DWITH_JANSSON=off -DWITH_CURL=off -DWITH_GNUTLS=off

Although I don't know if it will work, because i don't use Visual Studio and haven't had any feedback from VS users, if I recall correctly.

In any case, let me know if you succeed or not

@klasik16
Copy link
Author

klasik16 commented May 9, 2019

Ok stil looking for solution how to use this framework in my project.
i downloaded Libmicrohttpd from Section Downloading Libmicrohttpd / Windows
confused about how to install it on windows.
on Linux its easy you just use

sudo apt-get update
sudo apt-get install libmicrohttpd-dev

but what about windows?

i'm using cmake graphic. i porose to change functions from on to off becouse when compiling with cmake each time you bust uncheck evry option you dont need becouse you not added the required lib...
UPDATE:
Okay i figurate that i need add libmicrohttpd.lib to C:\Program Files (x86) directory then use CMake without any selections and projects is builded. Now i have VS project.
now i need figurate how compile it and attack in my project to future use... working on that.

Compiling with VS:

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	E1696	cannot open source file "pthread.h"	ulfius	C:\Users\ScadaAdmin\Desktop\ulfius-master\include\ulfius.h	48	
Error (active)	E1696	cannot open source file "orcania.h"	ulfius	C:\Users\ScadaAdmin\Desktop\ulfius-master\include\ulfius.h	60	
Error (active)	E1696	cannot open source file "pthread.h"	ulfius	C:\Users\ScadaAdmin\Desktop\ulfius-master\src\ulfius.c	28	
Error	D8021	invalid numeric argument '/Werror'	ulfius	C:\Users\ScadaAdmin\Desktop\ulfius\cl	1	
Error	D8021	invalid numeric argument '/Werror'	ulfius_static	C:\Users\ScadaAdmin\Desktop\ulfius\cl	1	

@babelouest
Copy link
Owner

The error log says you need to install orcania. In this case, you must pass this option to CMake: -DWITH_JANSSON=off.

You also need to install a pthread library, something like that may help.

I'm can't be very helpful with Visual Studio because I'm not familiar with it to build C projects on Windows, sorry.

I would suggest to find help in the Visual Studio community to help you with the install.

@webfolderio
Copy link
Contributor

@klasik16 You could use my sample project to compile ulfius on Windows & Visual Studio 2017 which requires vcpkg.

@babelouest
Copy link
Owner

@webfolderio , this is awesome!

Would it be possible to provide a documentation to help MSVC users to use Ulfius with vcpkg? I'd add it to the INSTALL.md file.

@webfolderio
Copy link
Contributor

webfolderio commented May 10, 2019

I added required steps to README.md to install ulfius with vcpkg.
Example application works quite well except GnuTLS and WebSocket.
I also added required yaml configuration file to integrate ulfius with Appveyor CI.

I am going to add GnuTLS, WebSocket support and will be run ulfius test cases on CI. When i will be done, we might update the INSTALL.md.

@babelouest
Copy link
Owner

I have thought about the MSVC documentation and I have another approach to offer:
Instead of merging the whole Ulfius with MSVC documentation in ulfius project, I'd add a smaller paragraph describing the basic requirements, and a link pointing to your sample project where the documentation would be complete.

So if you improve your sample project or put more detailed documentation after some time, you will have more power and freedom to change the MSVC documentation.

But adding GnuTLS and websockets support is a great idea I'll be happy to merge to my project!

The reason why websockets are not included with Windows build in the first place is mostly because poll() isn't available (or at least wasn't when the people adapting Ulfius in the first place did the job).

AFAIK, GnuTLS is available on Windows so the https:// support and client credential certificate wouldn't cause any problems.
GnuTLS is required for websocket support though, that's why I would check GnuTLS first, then websockets.

@SpareSimian
Copy link

Here's someone who's forked gnutls to build it with VS. See the SMP directory for the Windows build instructions.

https://github.com/ShiftMediaProject/gnutls

@sfhacker
Copy link

sfhacker commented Aug 3, 2020

@klasik16 Any news/update on this long standing issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants