cmake引用jansson库

妙音 posted @ 2024年1月09日 14:50 in cxx with tags json jansson c , 1287 阅读

描述

 
在ubuntun系统上使用clion开发c程序, cmake如何引入jansson库.
 

下载jansson

 
wget http://digip.org/jansson/releases/jansson-2.13.tar.gz

tar -xvf
 

编译jansson

cd jansson-2.13
mkidr build
cd build
cmake ../
make
 

查看编译结果

 
├── include
│      ├── jansson_config.h
│      └── jansson.h
├── lib
│     └── libjansson.a
 
 

clion创建C程序

File->New->Project->选中"C Executable"
 

CMakeLists.txt引用jansson

 
cmake_minimum_required(VERSION 3.22)
project(demo_task C)

set(CMAKE_C_STANDARD 11)

#自定义库, jansson放在了source目录下
set(LIBHOME "/home/xxx/workspace/source/")

# jansson
include_directories(${LIBHOME}/jansson-2.13/build/include)
link_directories(${LIBHOME}/jansson-2.13/build/lib)
link_libraries(jansson)

add_executable(demo_task main.c)
 

main.c使用jansson

 
创建demo.json并放入任意json数据, jansson读取demo.json,并打印结果
 
#include <stdio.h>
#include <jansson.h>

int main() {
    json_t *json;
    json_error_t error;

    json = json_load_file("../demo.json", 0, &error);
    if(!json) {
        /* the error variable contains error information */
    }
    char *result = json_dumps(json, 0);
    printf("%s\n", result);
    free(result);

    return 0;
}
 
 

运行

 
clion运行并查看结果
 
 
 
 
 
Avatar_small
pavzi.com 说:
2024年1月10日 13:29

Pavzi.com provides all the news about Gadgets, the Economy, Technology, Business, Finance and many more. The main concept or our aim behind this website has been the will to provide resources with full information on each topic which can be accessed through the Internet. To ensure that every reader gets what is important and worthy about the topic they search and link to hear from us. pavzi.com Our site is a multiple Niche or category website which will ensure to provide information and resources on each and every topic. Some of the evergreen topics you will see on our website are Career, Job Recruitment, Educational, Technology, Reviews and others. We are targeting mostly so it is true that Tech, Finance, and Product Reviews. The only reason we have started this website is to make this site the need for your daily search use.

Avatar_small
Cheap Assignment Wri 说:
2024年1月10日 14:33

Thank you for providing the references on incorporating the Jansson library into CMake projects. Your guidance on using CLion for C development on Ubuntu has been incredibly helpful. I've successfully integrated the Jansson library into my project, and it's working seamlessly.

Avatar_small
sophia 说:
2024年1月23日 23:03

Metaverse games have long exceeded the stage of being a trend, with several games now having market capitalizations above $1 Billion..   casino online

Avatar_small
robinjack 说:
2024年1月25日 20:19

The GDP (Gross Domestic Product) of the 41 Heavily Indebted Poor Countries (567 million people) is less than the wealth of the world’s 7 richest people combined.   madrasah ibtidaiyah al muhajirin

Avatar_small
robinjack 说:
2024年2月14日 17:23

Spiritual guidance is the ability to receive messages from a higher source that can give us insight into our lives. It can be received in a variety of ways, including meditation, prayer, and by connecting with your spirit guides. You can also receive guidance from others in your life or through ordinary coincidences, such as seeing a light around the correct answer on a multiple-choice exam.. what does it mean to dream about a female coworker

Avatar_small
sophia 说:
2024年2月16日 01:51

MusicVerter is a free SoundCloud to MP3 downloader. Download any SoundCloud song or playlist directly into an MP3 file for free with just one click. Try it now! SoundCloud Downloader - SoundCloud To MP3 Converter. soundcloud downloader

Avatar_small
Masaood TBA 说:
2024年2月24日 19:56

Al Masaood Tyres is a premier destination for all your tire needs in Abu Dhabi, known for its exceptional service and extensive range of top-tier tire brands. With a team of skilled professionals, they provide expert advice and efficient solutions to ensure your vehicle's optimal performance and safety on the road.

Avatar_small
10 deep hoodie 说:
2024年3月06日 03:53

The 10 Deep hoodie is an absolute must-have! The quality and comfort of this hoodie are unmatched, making it perfect for any casual or streetwear look. 10 deep hoodie

Avatar_small
sophia 说:
2024年3月13日 01:19 I havent any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. gmail.com login
Avatar_small
Thai Townhouse Prope 说:
2024年3月19日 14:03

Thai-Move is a web based search platform which allows people from anywhere in the world to search for any type of property in Thailand. Agents from all over Thailand can list all of their properties easily and in one place giving the people searching the ability to not only search for everything without switching websites, but be able to save and compare one property to the next.

Avatar_small
נייק טי אן 说:
2024年3月19日 16:52

מחפשים נעלי נייק ? אצלנו במול שוז אתם במקום הנכון לנעלי נייק גברים, נייק נשים או ילדים! באתר תמצאו מגוון דגמי נעלי ספורט נייק לפעילויות שונות כגון כדורגל, כדורסל, , טניס ועוד. זקוקים לייעוץ בנוגע לבחירת נעלי נייק? צרו עימנו קשר !

Avatar_small
Redhead Pick Up Line 说:
2024年3月19日 19:36

Imagine approaching a flame-haired beauty with a playful grin and saying, "Is it just me, or is it getting hotter in here? Oh wait, it's just your fiery locks stealing all the attention." This line not only acknowledges the unique allure of red hair but also serves as a lighthearted compliment, sure to bring a smile to their face and spark a conversation.

Avatar_small
educational apps 说:
2024年3月29日 09:33

Educational apps are invaluable tools for modern learners of all ages. With their interactive features and diverse content, these apps make learning accessible anytime, anywhere. <a href="https://takesapp.com/top-10-educational-apps-for-kids/">educational apps</a>

Avatar_small
Limousine Dubai 说:
2024年4月21日 00:11

Limousine Dubai offers unparalleled luxury and comfort for your transportation needs in the vibrant city of Dubai. <a href="https://www.limousinedxb.com/">Limousine Dubai</a>

Avatar_small
Key fob replacement 说:
2024年4月30日 00:59

Our Services Need help with locks? MyKey Locksmith has you covered! Our professional team of locksmiths are here to provide reliable, fast, and trustworthy service.

Avatar_small
pleasant view apartm 说:
2024年5月02日 21:18

Experience spacious floor plans and exceptional on-site management and maintenance at Renewal Heights Apartments. Your comfort and satisfaction are paramount to us. Indulge in our recently renovated units, boasting energy-efficient windows, thermal siding, and modernized LED lighting.

Avatar_small
Siding 说:
2024年5月03日 01:27

Rama Siding is a professional siding contractor based in Toronto, servicing the GTA for over 25 years. A father and son business focused on providing value and ensuring that every customer we serve is satisfied.

Avatar_small
animated video produ 说:
2024年5月03日 06:30

We’re an explainer video production company with the passion to create storytelling videos that deliver engaging and compelling content. Our animated explainer video production services deliver engaging video content for businesses and nonprofits. We make video explainers that engage your audience, increase conversions, and boost your bottom line. <a href="https://explainervideos.ca">animated video production cost</a>

Avatar_small
books medicos 说:
2024年5月10日 07:18

Their journey from ancient repositories of scrolls to modern digital archives is a testament to their enduring significance in shaping the intellectual landscape of society.

Avatar_small
tech 说:
2024年6月18日 08:56

This is a fabulous post I seen because of offer it. It is really what I expected to see trust in future you will continue in sharing such a mind boggling post Veelgestelde vragen over visa voor Cambodja

Avatar_small
retail jobs near me 说:
2024年6月21日 00:39

Unlock the Potential of Candidates with 100+ Professional Assessment Tests Our platform offers a range of professional tests to evaluate candidate skills and suitability, helping you make informed hiring decisions.

Avatar_small
Revenue cycle manage 说:
2024年6月28日 05:03

As a billing consultant, we have assisted providers and facilities in solving medical billing problems and increasing their cash flow and reducing cost. [url=https://atozbillings.com/]Revenue cycle management[/url]

Avatar_small
Cyberpunk Jacket 说:
2024年6月28日 19:12

I am impressed with the high quality and fit of the suit I ordered from America Jackets. Highly recommended! Next, I’ll be ordering Ryan Reynolds Shearling Jacket from them.

Avatar_small
Jiu Jitsu Outfits 说:
2024年7月06日 23:06

Playwell's success has come about by understanding customers' needs, listening to comments and suggestions, and by providing quality goods at competitive prices. As technology advances, so do the pressures brought about by increased expectations of performance and productivity.

Avatar_small
토지노 说:
2024年7月08日 00:35

Is the 토지노 membership registration process complicated?

Avatar_small
Car key programming 说:
2024年7月08日 20:11

Whether you need a car key replacement, a remote keyless entry system, a car fob programming, or a car lockout service, we can help you with any of your auto locksmith needs.

Avatar_small
downspouts 说:
2024年7月09日 12:32

Rama Siding is a professional siding contractor based in Toronto, servicing the GTA for over 25 years. A father and son business focused on providing value and ensuring that every customer we serve is satisfied.

Avatar_small
chloe 说:
2024年7月15日 16:49

Seeking <a href="https://ukassignmentwritershelp.co.uk/">uk assignment writers help</a> ensures that students receive personalized guidance and support in the completion of their academic tasks. These professionals offer expertise in various subjects, ensuring assignments are not only completed on time but also meet rigorous academic standards. Partnering with reputable services can significantly enhance your learning experience by providing valuable insights and improving overall academic performance.

Avatar_small
BizSAFE 说:
2024年7月20日 15:32

We revolutionised the way companies assess their workplace risks and prepare their Risk Assessment and bizSAFE documentation.

Avatar_small
Scaffolding Equipmen 说:
2024年7月22日 19:34

SS Scaffolding is a reliable and professional scaffolding company with over 30 years of experience providing residential and commercial scaffolding services all across Sydney including north shore, south east, west and central Sydney.

Avatar_small
Key fob replacement 说:
2024年8月01日 18:57

Our Services Need help with locks? MyKey Locksmith has you covered! Our professional team of locksmiths are here to provide reliable, fast, and trustworthy service.

Avatar_small
car sports 说:
2024年10月12日 18:53
In NASCAR, no one embodied the spirit of the sport more than Dale Earnhardt. Known as "The Intimidator," Earnhardt won seven NASCAR championships before his untimely death during a race in 2001. His legacy lives on as one of the greatest to ever compete in the sport.
 
Avatar_small
drypure.in 说:
2024年10月23日 19:02

For professional care, try DryPure's carpet cleaning services. They offer expert cleaning with eco-friendly products, ensuring your carpet looks as good as new. With their pickup and drop service, maintaining clean carpets has never been easier.
Schedule your Pickup: https://www.drypure.in/

Avatar_small
Jimi 说:
2024年10月23日 23:08

Macronutrients—proteins, fats, and carbohydrates—play a crucial role in weight loss beyond just counting calories. While calories measure energy intake, the quality of those calories matters. Protein supports muscle growth and repair, boosting metabolism. Healthy fats promote satiety, keeping you full longer, while carbohydrates provide essential energy for workouts and daily activity. Focusing on a balanced intake of macronutrients can improve body composition, regulate hunger, and enhance fat loss. Therefore, prioritizing macronutrients is key to sustainable weight loss, proving that calories alone aren't everything.

Avatar_small
Robinjack 说:
2024年11月02日 18:14

Nice to be visiting your blog once more, it has been months for me. Well this article that ive been waited for therefore long. i want this article to finish my assignment within the faculty, and it has same topic together with your article. Thanks, nice share. swim wear for ladies

Avatar_small
Robinjack 说:
2024年11月04日 17:07

Great read for new drivers in Calgary! Driving School in Calgary AB, here’s the link: url here https://www.thecreativeallianceexperience.com/air-brake-q-endorsement-calgary

Avatar_small
Robinjack 说:
2024年11月05日 17:39

We are told that the first three aliens have already been killed and that Four is on the run with his guardian to Paradise, Ohio. G3D Models Dubai

Avatar_small
Robinjack 说:
2024年11月05日 17:39

Thank you, I have been looking for facts about this topic for ages and yours is the best I’ve discovered so far. php laravel software developer

Avatar_small
AHMEDHASSAN 说:
2024年11月14日 18:30

The primary difference lies in the cars and race formats. Formula 1 cars are open-wheel and designed for high-speed circuit racing, while NASCAR features stock cars racing on oval tracks. <a href="https://councilsports.com/">Car sports</a>

Avatar_small
Robinjack 说:
2024年11月17日 16:27 Thanks for publishing about this. There’s a heap of useful fitness info on the internet. You’ve got a lot of that info here on your website. I’m impressed – I try to keep a couple blogs fairly current, but it’s a struggle at times. You’ve done a fabtastic job with this one. How do you do it? buy gold tucson
Avatar_small
Robinjack 说:
2024年11月23日 22:13

Wow! Thank you! I constantly needed to write on my site something like that. Can I include a part of your post to my website? Jack daniels Frank sinatra century

Avatar_small
Robinjack 说:
2024年11月23日 23:14

Nutri Agro olaraq vizyonumuz, kənd təsərrüfatı sektorunda lider mövqeyimizi möhkəmləndirərək, müştərilərimizə və tərəfdaşlarımıza yüksək keyfiyyətli, innovativ və ekoloji baxımdan davamlı məhsullar təqdim etməkdir. Biz, aqrar sektorda müsbət dəyişikliklərə ilham verməyi və qlobal miqyasda kənd təsərrüfatının inkişafına davamlı töhfə verməyi hədəfləyirik. Dünyada kənd təsərrüfatı istehsalının artan əhəmiyyətini nəzərə alaraq, Nutri Agro olaraq ən təsirli formulalarla orqanik gübrələr istehsal edir və bu məhsulların həm daxili, həm də xarici bazarlarda satışını həyata keçiririk. https://nutriagro.az

Avatar_small
Robinjack 说:
2024年11月24日 17:47

Your customers will want to see the fine details of your embroidery work. newborn photography

Avatar_small
Robinjack 说:
2024年11月26日 18:46

Hey! I simply wish to give a huge thumbs up for the great info you’ve gotten here on this post. I can be coming back to your weblog for extra soon. https://ecoliven.com/top-movers-in-calgary-for-your-next-move

Avatar_small
オンカジ 说:
2024年11月29日 02:58

オンカジのスロットは、ジャックポットのチャンスがあるため、大きな勝利を目指したい人に最適です。
https://www.outlookindia.com/plugin-play/%E6%9C%80%E9%AB%98%E3%81%AE%E3%82%AA%E3%83%B3%E3%83%A9%E3%82%A4%E3%83%B3%E3%82%AB%E3%82%B8%E3%83%8E%E3%82%B5%E3%82%A4%E3%83%88%E3%82%92%E8%A6%8B%E3%81%A4%E3%81%91%E3%82%8B%E6%96%B9%E6%B3%95

Avatar_small
Robinjack 说:
2024年12月01日 22:40

I got what you intend,bookmarked , very decent internet site . Aspire credit card

Avatar_small
Robinjack 说:
2024年12月02日 23:53

if you want to hire some good wedding singers, always look for a singer with a background in classical music* https://doctornal.com/step-by-step-guide-to-installing-a-gas-furnace-in-calgary

Avatar_small
Robinjack 说:
2024年12月04日 21:43

Hi. Cool article. There’s an issue with your website in firefox, and you might want to check this… The browser is the market chief and a good section of people will pass over your great writing because of this problem. https://vrnnw.com/how-to-build-a-concrete-retaining-wall-in-calgary-step-by-step

Avatar_small
tech 说:
2024年12月07日 22:22

I intend to peruse this. I'll make sure to return. I appreciate you sharing. moreover, this post provides the light that allows us to see truth. This one is excellent and provides detailed information. I appreciate this well-written essay. الدليل السريع لتأشيرة العبور السعودية

Avatar_small
por 说:
2024年12月13日 15:18

naza88win The best web Good for casino number 1

Avatar_small
<a href="https://onc 说:
2024年12月17日 18:39

初心者には、登録ボーナスが充実しているオンラインカジノが始めやすくておすすめです。
https://oncasiworld.com/


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter