cmake引用jansson库

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

描述

 
在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
meidir 说:
2024年1月27日 00:55

Amusing article. It seems that most of the ways are depending on the creative thinking aspect. “All marriages are mixed marriages.” by Chantal Saperstein.. 홈카지노검증

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月14日 22:04

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. bestoto

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.


登录 *


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