Coder Social home page Coder Social logo

gmic-sharp-native's Introduction

gmic-sharp-native

The native support library for gmic-sharp. This provides the native interface between gmic-sharp and libgmic.

Building the library

Linux

Building with the installed version of G'MIC

This version dynamically links to the installed version of the G'MIC library.

Assuming that you are building a 64-bit library with libgmic located in the system search path, you would run the following commands from the shell:

gcc -shared -fPIC src/GmicSharpNative.cpp -o bin/x64/libGmicSharpNative.so -lgmic -lpthread -lX11 -lstdc++ -lm

Building with a local copy of G'MIC

This version uses the G'MIC source code when building the library.

First clone the G'MIC repository into <root>/gmic.

Next create a build directory and run CMake to setup the build environment.

mkdir build && cd build
cmake ..

Once CMake has finished configuring the library can be built by running make.

Windows

Using MSYS2:

This is the preferred method as it allows all G'MIC features to be used. Assuming that you are building the 64-bit DLL you would run the following commands from the MSYS2 64 shell:

First create the build folder: mkdir build64 && cd build64
Second generate the MingGW makefiles: cmake -G "MinGW Makefiles" ..
Third build the library: mingw32-make

This should result in libGmicSharpNative.dll being generated in the buil64 folder.

You will need to copy it and the native dependencies to the folder of your choice. Assuming your target folder is the bin/x64 folder in the GmicSharpNative root, you can use the following commands:

Copy libGmicSharpNative.dll to the bin/x64 folder:

cp ./libGmicSharpNative.dll ../bin/x64/libGmicSharpNative.dll

Copy the required dependences from the /mingw64/bin folder:

cd /mingw64/bin/ && cp libgcc_s_seh-1.dll libwinpthread-1.dll libgomp-1.dll libstdc++-6.dll libcurl-4.dll libbrotlidec.dll libbrotlicommon.dll libcrypto-1_1-x64.dll libidn2-0.dll libiconv-2.dll libintl-8.dll libunistring-2.dll libnghttp2-14.dll libpsl-5.dll libssh2-1.dll zlib1.dll libssl-1_1-x64.dll libzstd.dll libfftw3-3.dll libjpeg-8.dll libpng16-16.dll libtiff-5.dll liblzma-5.dll <GmicSharpNative_ROOT>/bin/x64

The above list was taken from the Windows build instructions for the G'MIC CLI on the G'MIC download page. Depending on the library versions that you have installed there may be additional dependencies that are not listed above.

Using Visual Studio 2019:

This should only be used for debugging the gmic-sharp Managed <--> Native transitions. The Visual C++ 2019 compiler does not currently support all of the features of the GCC build.

Turn off all CMake options except the static library and configure CMake to build G'MIC with Visual Studio. Then open the libgmicstatic project, change the CRT runtime to static and build it.

Note that you may have to fix some parts of the G'MIC code to work with the Visual C++ compiler.

After building libgmicstatic open the project in the msvc folder. Update the include and library paths, then you should be able to build the project.

License

This project is dual-licensed under the terms of the either the CeCILL v2.1 (GPL-compatible) or CeCILL-C v1 (similar to the LGPL).
Pick the one you want to use.

See COPYING for more information.

This was done to match the licenses used by libgmic.

gmic-sharp-native's People

Contributors

0xc0000054 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

gmic-sharp-native's Issues

How to do this?

I decided to do this on my main computer again as I already managed to save a lot of space. However, I have this problem:

User@MM-DESKTOP MINGW64 /c/gmic-pdn/gmic-sharp-native/build64
$ cmake -G "MinGW Makefiles" ..
-- The CXX compiler identification is GNU 7.3.0
-- The C compiler identification is GNU 7.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: C:/msys64/mingw64/bin/pkg-config.exe (found version "1.8.0")
Found G'MIC repository
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Found ZLIB: C:/msys64/mingw64/lib/libz.dll.a (found version "1.2.11")
-- Found CURL: C:/msys64/mingw64/lib/libcurl.dll.a (found version "7.79.1")
-- Checking for module 'fftw3>=3.0'
--   Package 'fftw3', required by 'virtual:world', not found
-- Checking for module 'opencv'
--   Package 'opencv', required by 'virtual:world', not found
-- Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR)
-- Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR)
-- Checking for module 'OpenEXR'
--   Package 'OpenEXR', required by 'virtual:world', not found
-- The following OPTIONAL packages have been found:

 * OpenMP
 * CURL
 * ZLIB

-- The following OPTIONAL packages have not been found:

 * TIFF
 * PNG
 * JPEG

-- Configuring done
-- Generating done
-- Build files have been written to: C:/gmic-pdn/gmic-sharp-native

User@MM-DESKTOP MINGW64 /c/gmic-pdn/gmic-sharp-native/build64
$ mingw32-make
mingw32-make: *** No targets specified and no makefile found.  Stop.

There's nothing in build64

User@MM-DESKTOP MINGW64 /c/gmic-pdn/gmic-sharp-native
$ dir
CHANGELOG.md    CMakeLists.txt  README.md  cimg                 gmic-qt  zart
CMakeCache.txt  COPYING         bin        cmake_install.cmake  msvc
CMakeFiles      Makefile        build64    gmic                 src

What to do with gmic library inside C:\gmic-pdn\gmic-sharp-native\gmic\src?

Hi, I had managed to build libgmic. However, I received this error when building. Here's the log.

$ g++ -shared -DGMICSHARPNATIVE_EXPORTS -I../gmic/src ./GmicSharpNative.cpp ./version.o -o ../bin/x64/libGmicSharpNative.dll -L../gmic/gcc64 -Wl,--stack,16777216 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -static -lgmic -lfftw3 -lcurl -ltiff -lz -lzstd -llzma -lgomp -ljpeg -lpng
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgmic
collect2.exe: error: ld returned 1 exit status

There are some files within gmic/src, and I don't know what to do with it. If you can clarify on what to do on this step, I may be able to build gmic-sharp-native.

As a sidenote, there's no instructions on building gmic-sharp, but I'll ask after I build gmic-sharp-native.

Some files that has been created, or copied from another directory.

CImg.h (I think this was moved as the date modified shows the earliest date in the folder I'm looking at)
gmic_stdlib.gmic
gmic_stdlib.h
libgmic.a
libgmic.o
libgmic.so
use_libgmic.cpp
use_libgmic.exe

I know I have to do something about those, but not sure what to do.

New build attempted. This error shows up.

After following along instruction within the last issue report. This is what happened. Yes, I updated to latest gmic.

 MINGW64 /c/gmic-pdn/gmic-sharp-native/src
$ g++ -shared -DGMICSHARPNATIVE_EXPORTS -I../gmic/src ./GmicSharpNative.cpp ./version.o -o ../bin/x64/libGmicSharpNative.dll -L../gmic/src -Wl,--stack,16777216 -lkernel32 -luser32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -static -lgmic -lfftw3 -lcurl -ltiff -lz -lzstd -llzma -lgomp -ljpeg -lpng -lgdi32
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x24d): undefined reference to `WebPPictureFree'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x31e): undefined reference to `WebPIDelete'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x32a): undefined reference to `WebPFreeDecBuffer'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x395): undefined reference to `WebPPictureFree'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x4f7): undefined reference to `WebPPictureImportRGB'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x511): undefined reference to `WebPEncode'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x581): undefined reference to `WebPPictureImportRGBA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x804): undefined reference to `WebPPictureInitInternal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x82c): undefined reference to `WebPConfigInitInternal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x84d): undefined reference to `WebPValidateConfig'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x8a8): undefined reference to `WebPIDelete'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0x8b4): undefined reference to `WebPFreeDecBuffer'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0xa44): undefined reference to `WebPIAppend'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0xaad): undefined reference to `WebPIDecGetRGB'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0xc4b): undefined reference to `WebPIDelete'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0xc53): undefined reference to `WebPFreeDecBuffer'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0xc75): undefined reference to `WebPInitDecBufferInternal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_webp.o):(.text+0xcba): undefined reference to `WebPINewDecoder'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_zip.o):(.text+0xbf): undefined reference to `libdeflate_free_decompressor'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_zip.o):(.text+0xd1): undefined reference to `libdeflate_free_compressor'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_zip.o):(.text+0x2ed): undefined reference to `libdeflate_zlib_compress_bound'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_zip.o):(.text+0x32c): undefined reference to `libdeflate_zlib_compress'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_zip.o):(.text+0x412): undefined reference to `libdeflate_alloc_compressor'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_zip.o):(.text+0x864): undefined reference to `libdeflate_zlib_decompress'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_zip.o):(.text+0x99f): undefined reference to `libdeflate_alloc_decompressor'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libtiff.a(tif_zip.o):(.text+0xbf3): undefined reference to `libdeflate_free_compressor'
collect2.exe: error: ld returned 1 exit status

For what it worth:

[Deleted image]

And libpng too.

Error unsigned int...

It turned out I was missing some few things, but now following instructions more clearly:

User@MM-DESKTOP MINGW64 /c/gmic-pdn/gmic-sharp-native/build64
$ mingw32-make
[  0%] Built target gmic_extra_headers
Scanning dependencies of target GmicSharpNative
[ 25%] Building CXX object CMakeFiles/GmicSharpNative.dir/gmic/src/gmic.cpp.obj
[ 50%] Building CXX object CMakeFiles/GmicSharpNative.dir/src/GmicSharpNative.cpp.obj
C:\gmic-pdn\gmic-sharp-native\src\GmicSharpNative.cpp: In member function 'unsigned int GmicImageList::get_next_available_index()':
C:\gmic-pdn\gmic-sharp-native\src\GmicSharpNative.cpp:127:30: error: 'numeric_limits' is not a member of 'std'
  127 |         if (nextIndex < std::numeric_limits<unsigned int>::max())
      |                              ^~~~~~~~~~~~~~
C:\gmic-pdn\gmic-sharp-native\src\GmicSharpNative.cpp:127:45: error: expected primary-expression before 'unsigned'
  127 |         if (nextIndex < std::numeric_limits<unsigned int>::max())
      |                                             ^~~~~~~~
C:\gmic-pdn\gmic-sharp-native\src\GmicSharpNative.cpp:127:45: error: expected ')' before 'unsigned'
C:\gmic-pdn\gmic-sharp-native\src\GmicSharpNative.cpp:127:12: note: to match this '('
  127 |         if (nextIndex < std::numeric_limits<unsigned int>::max())
      |            ^
C:\gmic-pdn\gmic-sharp-native\src\GmicSharpNative.cpp:125:41: warning: control reaches end of non-void function [-Wreturn-type]
  125 |         uint32_t nextIndex = images.size();
      |                              ~~~~~~~~~~~^~
mingw32-make[2]: *** [CMakeFiles\GmicSharpNative.dir\build.make:91: CMakeFiles/GmicSharpNative.dir/src/GmicSharpNative.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:109: CMakeFiles/GmicSharpNative.dir/all] Error 2
mingw32-make: *** [Makefile:135: all] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.