Jansson & Visual Studio 2012 [Win7]

1,617 views
Skip to first unread message

Lorenzo Sciandra

unread,
Apr 29, 2013, 6:36:52 AM4/29/13
to jansso...@googlegroups.com
Hey everyone!

I want to use Jansson for a project in which I have to create JSON data and send them to a server, but I have to work with Windows Visual Studio 2012 (Ultimate version) on a Windows 7 machine.

I've already searched all over the internet the proper way to make it work, but I'm really having a hard time with the install/configuration of Jansson: what am I missing?

I've downloaded the most recent version from here


and then tried what it said here


which say that - essentially - I can install it in two different ways. I've tried them both:

1) "Jansson can be built with Visual Studio 2010 (and probably newer versions, too). The solution and project files are in the win32/vs2010/ directory in the source distribution.

If I get it right (i'm not english mothertongue) in this case I just have to go into the win32/vs2010 folder and open the jansson visual studio project file, and then build it.
First thing: when I double click on the file it asks me to "update the project to use the Visual C++ 2012 compiler and libraries". Here I chose to update.
Then, from the upper menu bar I chose "Build/Build this solution" and this is what I had as output

"1>------ Build started: Project: jansson, Configuration: Debug Win32 ------
1>  value.c
1>  utf.c
1>  strconv.c
1>  strbuffer.c
1>  pack_unpack.c
1>  memory.c
1>  load.c
1>  hashtable.c
1>  error.c
1>  dump.c
1>  Generating Code...
1>     Creating library Output\Debug\jansson.lib and object Output\Debug\jansson.exp
1>  jansson.vcxproj -> C:\Users\Operator3\Desktop\akheron-jansson-6b1cba9\win32\vs2010\Output\Debug\jansson.dll"

So apparently all worked properly.
But if now I create a new project (Visual C++ / Win32 Console Application - empty project) and I write in it 

#include <jansson.h>

it returns an error saying that it cannot open it.
Why? What am I missing?


2) "This method is deprecated. Using CMake is now preferred."

Ok, to try this way I had to download the last version of Cmake from here http://www.cmake.org/cmake/resources/software.html  and install it.
After having done that, I opened cmd, set the cd to Desktop\akheron-jansson-6b1cba9 and wrote "make". Didn't worked. Tried with "cmake". Returned the list of all the possible ways to use the command, and so i finally tried "cmake -i" which seemed to work. After some time and some messages, it ended saying 

"Cmake completed. Run make to build project."

...and so i'm also stuck in this way, because simply writing "make" in the cmd don't work.



So, two ways and i'm stuck with both.  :(

Can anybody help?

TY (and sorry for the long post, but I wanted to make it as clear as i can)

Petri Lehtinen

unread,
Apr 29, 2013, 7:30:40 AM4/29/13
to jansso...@googlegroups.com
Hi.

CMake support was recently added as a third-party contribution, and
the documentation wasn't fully written yet. I merged a pull request a
few minutes ago that clarifies things. See:

http://www.digip.org/jansson/doc/dev/gettingstarted.html#cmake-various-platforms-including-windows

I think you need to run CMake like this:

cmake -G "Visual Studio 11" C:\path\to\jansson

This creates Visual Studio 11 project files instead of Makefiles.

(According to CMake documentation, Visual Studio 11 is the "newest" VS
generator, but I assume it should be compatible with VS12.)

Hope this helps.

Petri
> --
> --
> Jansson users mailing list
> jansso...@googlegroups.com
> http://groups.google.com/group/jansson-users
> ---
> You received this message because you are subscribed to the Google Groups
> "Jansson users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to jansson-user...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Lorenzo Sciandra

unread,
Apr 29, 2013, 1:29:47 PM4/29/13
to jansso...@googlegroups.com
Hey.

Thanks for the support. Well, what you wrote works: and with that I mean that it actually create the "right" projects and if i build the RUN_TESTS one it actually get a 100% success rate. (and, IMHO, i think that VS11 is actually the "same thing" of Visual Studio 2012 - or they're just completely compatible)

That said, my problem still remain. If I create a generic New Project located anywhere, when i add the

#include <jansson.h> 

line it still gets an error (the header can't be found).

Probably I have to do some sort of trick like the one I had to make when I installed openGL - if I remember well i had to move in the Program File folder some .h and .dll.

Any idea?


Thanks again.

Petri Lehtinen

unread,
Apr 30, 2013, 1:20:45 AM4/30/13
to jansso...@googlegroups.com
Lorenzo Sciandra wrote:
> Hey.
>
> Thanks for the support. Well, what you wrote works: and with that I mean that
> it actually create the "right" projects and if i build the RUN_TESTS one it
> actually get a 100% success rate. (and, IMHO, i think that VS11 is actually the
> "same thing" of Visual Studio 2012 - or they're just completely compatible)
>
> That said, my problem still remain. If I create a generic New Project located
> anywhere, when i add the
>
> #include <jansson.h>
>
> line it still gets an error (the header can't be found).
>
> Probably I have to do some sort of trick like the one I had to make when I
> installed openGL - if I remember well i had to move in the Program File folder
> some .h and .dll.
>
> Any idea?

To link with Jansson, you need jansson.h, jansson_config.h and
jansson.dll added to your project. I'm not sure how to add them to
using VS, but that's what you should do anyway :)

Petri

Lorenzo Sciandra

unread,
Apr 30, 2013, 6:20:05 AM4/30/13
to jansso...@googlegroups.com
Ok, I found out how to make it works on VS12.

After you do the cmake part - and so you have the jansson folder with all the previous stuff PLUS the new /build - and create a new Empty C++ Project in VS12, you have to go to Project/Properties (alt+F7) and:

1) In the Configuration Properties / C-C++/ General in the first field "Additional Include Directories" write the absolute path which ends with "...\akheron-jansson-6b1cba9\build\include"

2) In the Configuration Properties / Linker / General in the 9th field "Additional Library Directories" write  the absolute path which ends with "...\akheron-jansson-6b1cba9\build\lib\Debug"

3) In the Configuration Properties / Linker / Input in the first field "Additional Dependencies" write (both add and overwrite the default stuff are cool to me) "jansson.lib"


And then it works :D

I wrote it so if another desperate n00b like me has my problem now he can work it out ;)


TY for the support
Reply all
Reply to author
Forward
0 new messages