0

i want to use this library https://github.com/json-c/json-c with my C program in codeblocks(windows) but i dont know how to make makefile/cmake on windows. I dont know how to do it in this particular example. There is only something like "Config.cmake.in".

Any ideas?

phd
  • 82,685
  • 13
  • 120
  • 165

1 Answers1

0

You didn't state what kind of build environment you are using on Windows. So find below a short description how i built the 32-bit version of json library on Windows 10 using cmake 3.14.3 and Visual Studio 2015. CMake supports several generators for Visual Studio as well as MinGW (see CMake documentation).

  1. Open command window (cmd.exe) change to root directory of json-c library source.
  2. Setup build configuration for 32 bit target in directory "build" using command line "cmake -G "Visual Studio 14 2015" -A Win32 -B build"
  3. Open command window for Visual Studio 2015 x86 environment (link at start menu) and change to build directory created during previous step.
  4. Run "msbuild json-c.sln" to build Debug version of json-c dynamic library
  5. Run "msbuild json-c.sln /p:Configuration=Release" to build Release version of json-c dynamic library

After that you should be able to add the built library to your project.

Mathias Schmid
  • 431
  • 4
  • 7
  • Thank you so much for the answer. What do you mean by environment? I want to create this library and add it to my C project (gcc compiler) in codeblocks on windows. – BestSnowWitch May 20 '19 at 08:47
  • By build environment i mean that i used Microsoft C/C++ compiler and linker part of my installation of Visual Studio 2015 and thus my description is based on that. – Mathias Schmid May 20 '19 at 09:07
  • Please take a look at CMake documenation for gcc based build environment configuration. There is a section specific to CodeBlocks ( https://cmake.org/cmake/help/v3.14/generator/CodeBlocks.html ). – Mathias Schmid May 20 '19 at 09:10
  • Setup build configuration for CodeBlocks using 'cmake -G "CodeBlocks - MinGW Makefiles" -B build' works on my setup as well. Make sure location of CodeBlocks MinGW gcc toolchain is part of PATH environment variable. – Mathias Schmid May 20 '19 at 13:57
  • Thank you for all your help. I will check your instructions soon and give feedback if i succeeded. – BestSnowWitch May 20 '19 at 14:13