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

Commit

Permalink
mingw sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Turupawn committed Apr 23, 2018
1 parent c791188 commit 1ee455c
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Expand Up @@ -22,7 +22,13 @@ IF (UNIX AND NOT APPLE)
ENDIF ()

IF (MINGW)
target_link_libraries(modio ${CMAKE_SOURCE_DIR}/lib/MinGW/libcurl.a ${CMAKE_SOURCE_DIR}/lib/MinGW/libz.a wldap32 ws2_32 ssl eay32 crypto)
target_link_libraries(modio
${CMAKE_SOURCE_DIR}/lib/MinGW/libcurl.a
${CMAKE_SOURCE_DIR}/lib/MinGW/libz.a
${CMAKE_SOURCE_DIR}/lib/MinGW/libcrypto.dll.a
${CMAKE_SOURCE_DIR}/lib/MinGW/libeay32.dll
${CMAKE_SOURCE_DIR}/lib/MinGW/libssl.dll.a
wldap32 ws2_32)
ENDIF()

IF (MSVC)
Expand Down
Binary file added lib/MinGW/libcrypto.dll.a
Binary file not shown.
Binary file added lib/MinGW/libeay32.dll
Binary file not shown.
Binary file added lib/MinGW/libssl.dll.a
Binary file not shown.
Binary file added lib/MinGW/ssleay32.dll
Binary file not shown.
2 changes: 2 additions & 0 deletions samples/windows-mingw/.gitignore
@@ -0,0 +1,2 @@
.modio
*.dll
5 changes: 5 additions & 0 deletions samples/windows-mingw/Makefile
@@ -0,0 +1,5 @@
CC=g++
CFLAGS=-Wall -std=c++11

all: main.cpp
$(CC) $(CFLAGS) main.cpp -o example -I ../../include ../../build/libmodio.dll.a
20 changes: 20 additions & 0 deletions samples/windows-mingw/Readme.md
@@ -0,0 +1,20 @@
# Setup

1. Install the MinGW compiler provided by the [MinGW Installer](https://sourceforge.net/projects/mingw/files/)
2. Download the ´mingw32-gcc-c++´ package
3. Add your MinGW binary folder to the path environment variable. By default it's `C:\MinGW\bin`.

# Compile

Open a command prompt and run:

´´´bash
mingw32-make
´´´

# Run


´´´bash
example.exe
´´´
59 changes: 59 additions & 0 deletions samples/windows-mingw/main.cpp
@@ -0,0 +1,59 @@
#include "modio.h"

int main(void)
{
modio::Instance modio_instance(MODIO_ENVIRONMENT_TEST, 7, "e91c01b8882f4affeddd56c96111977b");

volatile static bool finished = false;

auto wait = [&]()
{
while (!finished)
{
modio_instance.sleep(10);
modioProcess();
}
};

auto finish = [&]()
{
finished = true;
};

// Before requesting mods, let's define the query filters
modio::FilterCreator filter;
filter.setLimit(7);
filter.setCacheMaxAgeSeconds(100);

std::cout <<"Getting mods..." << std::endl;

// Now we finished setting up the filters we are ready to request the mods
modio_instance.getMods(filter, [&](const modio::Response& response, const std::vector<modio::Mod> & mods)
{
std::cout << "On mod get response: " << response.code << std::endl;
if(response.code == 200)
{
std::cout << "Listing mods" << std::endl;
std::cout << "============" << std::endl;
for(auto& mod : mods)
{
std::cout << "Id: \t" << mod.id << std::endl;
std::cout << "Name:\t" << mod.name << std::endl;
}

// Additionally, we can access pagination data to ease future browsing queries
std::cout << std::endl;
std::cout << "Cursor data:" << std::endl;
std::cout << "Result count: " << response.result_count << std::endl;
std::cout << "Result limit: " << response.result_limit << std::endl;
std::cout << "Result offset: " << response.result_offset << std::endl;
}
finish();
});

wait();

std::cout << "Process finished" << std::endl;

return 0;
}

0 comments on commit 1ee455c

Please sign in to comment.