This is an example of Go code calling to a C++ library with a C wrapper.
go build # this only ensures it compiles| //FROM | |
| //https://stackoverflow.com/a/34571089/5155484 | |
| typedef unsigned char uchar; | |
| static const std::string b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";//= | |
| static std::string base64_encode(const std::string &in) { | |
| std::string out; | |
| int val=0, valb=-6; | |
| for (uchar c : in) { |
| #!/bin/bash | |
| # For Mac OS X version (md5) | |
| MD="md5 -r" | |
| # For Linux version (md5sum) | |
| MD="md5sum" | |
| for i in ./*; do | |
| mv "${i}" "./$($MD "$i" | awk '{print $1}').${i##*.}" |
| // To compile with gcc: (tested on Ubuntu 14.04 64bit): | |
| // g++ sdl2_opengl.cpp -lSDL2 -lGL | |
| // To compile with msvc: (tested on Windows 7 64bit) | |
| // cl sdl2_opengl.cpp /I C:\sdl2path\include /link C:\path\SDL2.lib C:\path\SDL2main.lib /SUBSYSTEM:CONSOLE /NODEFAULTLIB:libcmtd.lib opengl32.lib | |
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <assert.h> | |
| #include <SDL2/SDL.h> | |
| #include <SDL2/SDL_opengl.h> |
| // = Requirements: freetype 2.5, libpng, libicu, libz, libzip2 | |
| // = How to compile: | |
| // % export CXXFLAGS=`pkg-config --cflags freetype2 libpng` | |
| // % export LDFLAGS=`pkg-config --libs freetype2 libpng` | |
| // % clang++ -o clfontpng -static $(CXXFLAGS) clfontpng.cc $(LDFLAGS) \ | |
| // -licuuc -lz -lbz2 | |
| #include <cassert> | |
| #include <cctype> | |
| #include <iostream> | |
| #include <memory> |