Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Notes on transplanting glib Library of SylixOS

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1.glib middleware

Glib library is the most commonly used C language function library under the Linux platform, and it has good portability and practicability.

Glib is the basic underlying core library of GTK+ and GNOME engineering. It is a practical lightweight C program library for comprehensive use. It provides the definition of common data structures of C language, related processing functions, interesting and practical macros, portable encapsulation and API of some runtime functions, such as event loops, threads, dynamic calls, object systems, etc. It can run on UNIX-like operating system platforms (such as LINUX,HP-UNIX, etc.), WINDOWS,OS2 and BeOS operating systems.

two。 Transplant idea

For the idea of porting Linux middleware to SylixOS, please refer to "the method of porting TN0029_SylixOS third-party middleware".

3. Transplant implementation

Http://ftp.gnome.org/pub/gnome/sources/glib/2.24/, where the glib source package is downloaded, uses glib-2.22.5.tar.gz. Compiling glib under Linux requires the support of libffi, so you need to cross-compile the libffi library first, using libffi-3.2.1.tar.gz. Download address of libffi source package: https://www.sourceware.org/libffi/.

3.1 generate configuration files under Linux

According to the evaluation, it is known that the glib project is relatively large, so there are too many problems to transplant and compile directly by the general method, which can not be solved quickly. To learn about the glib library on the official website, the whole project is divided into three small projects, as shown in figure 31.

Figure 3-1 glib Engineering frame Diagram

According to the glib engineering frame diagram, the whole can be divided into three modules: libgio, libgobject and libglib.

The source code downloaded from the official website is compiled and executed in the Linux environment to generate a configuration file as shown in figure 32.

Figure 3-2 Linux environment generates configuration files

Automatic configuration produces Makefile and config.h files, which are the key to migration. According to figure 31, the whole project is divided into three modules, and the configuration files of each module are also generated under each module during automatic configuration, as shown in figure 33, figure 34 and figure 35.

Figure 3-3 libgio project configuration

Figure 3-4 libgobject project configuration

Figure 3-5 libglib project configuration

So according to the Makefile under these three modules, the three modules libgio, libgobject and libglib are compiled respectively, and finally these three modules are integrated into a complete glib library project.

In this way, the configuration file is generated in the Linux environment, and then the entire source package is exported.

3.2 migrate to SylixOS

Import the source code project into the RealEvo-IDE development environment for development and compilation.

3.2.1 create a libgio module project

Create the libgio project and import the gio source code into the project as shown in figure 36.

Figure 3-6 libgio Project

Set the project to expert mode, that is, manually modify the Makefile. Configure the project's gio.mk according to the Makefile under the libgio module, as shown in figure 37. Then the compilation project is modified according to the error prompt.

Figure 3-7 gio.mk configuration for libgio

3.2.2 create a libgobject module project

Create the libgobject project and import the gobject source code into the project as shown in figure 38.

Figure 3-8 libgobject Project

Set the project to expert mode, that is, manually modify the Makefile. Configure the project's gobject.mk according to the Makefile under the libgobject module, as shown in figure 39. Then the compilation project is modified according to the error prompt.

Figure 3-9 object.mk configuration for libobject

3.2.3 create a libglib module project

Create the libglib project and import the libglib source code into the project as shown in figure 310.

Figure 3-10 libglib Project

Set the project to expert mode, that is, manually modify the Makefile. Configure the project's glib.mk according to the Makefile under the libglib module, as shown in figure 311. Then the compilation project is modified according to the error prompt.

Figure 3-11 glib.mk configuration for libglib

When all three modules are compiled and passed, the engineering integration is shown in figure 312.

Figure 3-12 libglib Engineering Integration

Integrate the * .mk configuration of the three projects into libglib.mk, as shown in figure 313.

Figure 3-13 libglib.mk Integration

In this way, the three projects are integrated and passed during initial compilation, and then when functional testing is carried out, the project is gradually improved.

3.2.5 modify compilation error 1.

This sentence is added to some header files here, because the GIO_ calculation macro is not defined here.

# if defined (_ _ GIO_GIO_H_INSIDE__) & &! defined (GIO_COMPILATION)

# error "Only can be included directly."

# endif

Errors that often occur during compilation. The solution is to define # define GIO_COMPILATION in acoinfo.h

The _ _ GIO_GIO_H_INSIDE__ macro defines # define in gio.h.

two。

GIO_MODULE_DIR (used on line 388 of the giomodule.c file, undefined), this Makefile is defined under Linux as the path to / lib/gio/modules under the installation directory, and # define GIO_MODULE_DIR "/ lib/modules" in acoinfo.h; mainly to load the module under the path.

3.

The use of dirent structures in glocalfileenumerator.c files conflicts with the system. The dirent structure stores short filename information, which is not consistent with glib. For compilation use, define the dirent structure in acoinfo.h.

SylixOS structure:

Struct dirent {

Char dameName [name _ MAX + 1]; / * filename * /

Unsignedchar dumbtype; / * File type (possibly DT_UNKNOWN) * /

Char d_shortname [13]; / * fat short file name (may not exist) * /

PVOID * dadopresv; / * reserved * /

}

Redefine (found under Linux):

Struct acoinfo_dirent

{

Long diterino; / * inode number Inode number * /

Off_t dashes off; / * offset of offset to this dirent in the catalog file * /

Unsignedshort dumped recline; / * length of this d_name file name length * /

Unsignedchar dumbtype; / * the type of d_name file type * /

Char d_name [NAME_MAX+1]; / * file name (null-terminated) filename, with a maximum length of 256 characters * /

}

4.

Times [0] .tv _ usec = statbuf.st_atim.tv_nsec / 1000; (glocalfileinfo.c file 2099 lines 2132 lines 974 lines 985 lines 996 lines) the calculation time accuracy is subtle, which is different from that under Linux, so it is modified to be owned by SylixOS.

SylixOS structure

Struct stat {

Dev_t st_dev / * device * /

Ino_t st_ino; / * inode * /

Mode_t st_mode; / * protection * /

Nlink_t st_nlink; / * number of hard links * /

Uid_t st_uid; / * user ID of owner * /

Gid_t st_gid; / * group ID of owner * /

Dev_t st_rdev; / * device type (if inode device) * /

Off_t st_size; / * total size, in bytes * /

Time_t st_atime; / * time of last access * /

Time_t st_mtime; / * time of last modification * /

Time_t st_ctime; / * time of last create * /

Blksize_t st_blksize; / * blocksize for filesystem Imax O * /

Blkcnt_t st_blocks; / * number of blocks allocated * /

Void * st_resv1

Void * st_resv2

Void * st_resv3

}

Linux structure

Struct stat {

Unsignedlong st_dev; / * Device. , /

Unsignedlong st_ino; / * File serial number. , /

Unsignedint st_mode; / * File mode. , /

Unsignedint st_nlink; / * Link count. , /

Unsignedint st_uid; / * User ID of the file's owner. , /

Unsignedint st_gid; / * Group ID of the file's group. , /

Unsignedlong st_rdev; / * Device number, if device. , /

Unsignedlong _ _ pad1

Long st_size; / * Size of file, in bytes. , /

Int st_blksize; / * Optimal block size for Imax O. * /

Int _ _ pad2

Long st_blocks; / * Number 512-byte blocks allocated. , /

Long st_atime; / * Time of last access. , /

Unsignedlong st_atime_nsec

Long st_mtime; / * Time of last modification. , /

Unsignedlong st_mtime_nsec

Long st_ctime; / * Time of last status change. , /

Unsignedlong st_ctime_nsec

Unsignedint _ _ unused4

Unsignedint _ _ unused5

}

5.

There is no libintl.h header file under our system, which is mainly used as a data window control. SylixOS does not support it for the time being, so close the macro enable _ NLS in config.h.

6.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report