Gentlemen, I have a serious and important question, over which I have been fighting my head on the keyboard for over a week now. I am even ready to discuss the remuneration of someone who will help me. The question is: I need to be taught how to correctly tick the linker settings for VS 2015, so that my libevent library links to the project in c ++ (and, possibly, build this library correctly).
Background: I read a couple of motivating articles about the libevent library (for example, this one: https://habrahabr.ru/post/217437/ ). I started with the fact that I made a development machine for Ubuntu 16 LTS, where I put g ++ and compiled a library of source codes for instructions from the github. ( https://github.com/libevent/libevent ) Then I wrote a simple program test.cpp, in which I tried to initialize the library:
#include <memory> #include <cstdint> #include <iostream> #include <evhttp.h> #include <string> #include <fstream> using namespace std; int main(){ cout<< "Hi!" << endl ; if ( !event_init()) cout << "Failed to init libevent." << endl; else cout << "libevent init successfully!" << endl; return 0; } After a bit of confusion, I normally assembled this program with the g ++ -std = c ++ 11 -o test.ex test.cpp -levent command and started it. ./test.ex Everything works. This is great. Then I rewrote a slightly more complicated example from the examples ... But as soon as I started writing myself, I needed debugging. And my own system in this sense is Windows. Well, you understand ... relatives do not choose ...
And under Windows everything is not so smooth. First, you need to build a library from source. According to the instructions, I do this with CMake:
"CMake (Windows) Install CMake: http://www.cmake.org $ md build && cd build $ cmake -G "Visual Studio 10" .. # Or whatever generator you want to use $ start libevent.sln" Cmake at assembly swears at the lack of OpenSSL, and no dances with tambourines help any more: in order to use OpenSSL under Windows, it is necessary to define three magic environment variables
OPENSSL_ROOT_DIR OPENSSL_INCLUDE_DIR OPENSSL_CRYPTO_LIBRARY and how to define these variables is not written anywhere. Fortunately, if the door is closed - you can check the window ... libevent allows you to assemble yourself without OpenSSL support, by adding the key -DEVENT__DISABLE_OPENSSL = on, that is, using the cmake -DEVENT__DISABLE_OPENSSL = on -G "Visual Studio 14 2015" command Some warnings that this command wrote to me, its output can be seen here:
But the * .sln file is being created, and after running the compilation, I received a set of * .lib files in the Debug directory: event.lib, event_core.lib, event_extra.lib.
But then the problems started. No dancing with a tambourine allows me to link these libraries to a C ++ project. For the sake of completeness: in my system, the path to these * .lib files is C: \ Programs \ includes \ libevent \ lib \ Debug; I got them here:
and here:
and here:
and even here: 
The last attempt created the illusion that something happened. that is, the project is properly assembled. But when I started, I instantly got an error: 
Then I made two more pathetic attempts to understand: linking (because the assembly of the obj-file passes without errors, note) under Windows from the command line (the result is the same, does not see the library)
and try to compare the contents of obj files using the nm utility under Linux and the dumpbin under Windows with the / symbols option. But the difference is too great, I just see in the Windows object file that _event_init is UNDEFined.
In general, I did not succeed. Please help me, for example, by suggesting how to determine the magic variables for OpenSSL (maybe the library just refreshed itself properly assembled?), Or by trying to build this project with this library, perhaps you can.
Thanks in advance for the tips.