SergiusTheBest / plog

Portable, simple and extensible C++ logging library
MIT License
2.21k stars 391 forks source link

Please add instruction how to run samples #277

Closed repl-shenoy-sukumaran closed 10 months ago

repl-shenoy-sukumaran commented 10 months ago

Can you please give some instruction how to run samples e.g. Demo? Sorry i am new to C++ cmake etc

i have cloned the repo and tried within folder samples\Demo

Do we need to copy the include/plog manually somewhere?

image

paule32 commented 10 months ago

Hi, you don't need cmake. PLOG is logging comes with header only usage. So, you only need to give the path to plog/include with the g++ Option -I source code (test.cc):

// -----------------------------------------------------------------
// standard header stuff ...
// -----------------------------------------------------------------

# include <stdio.h>
# include <stdlib.h>        // for _countof
# include <string.h>        // for strcpy_s

// -----------------------------------------------------------------
// c++ header prototype's/signature's:
// -----------------------------------------------------------------
# include <iostream>        // std c++ signatures
# include <string>
# include <cstdlib>
# include <cstring>

// -----------------------------------------------------------------
// loggin specified header files ...
// -----------------------------------------------------------------
# include <plog/Log.h>
# include <plog/Initializers/RollingFileInitializer.h>

namespace plog;
namespace std;

int main(int argc, char **argv)
{
    // ----------------------------------
    // initialize logging stuff ...
    // ----------------------------------
    plog::init(plog::debug, "app.log");
    PLOGI << "start application";;

    return EXIT_SUCCESS;
}

console: g++ -O2 -std=c++20 -Wno-write-strings -I../plog/include -o test.exe test.cc -L. -lz

SergiusTheBest commented 10 months ago

@repl-shenoy-sukumaran Oh, you need to run cmake from the root folder and not from the samples\Demo. It will build the samples by default.

repl-shenoy-sukumaran commented 10 months ago

Thank you :)