1. declare the interface of libray:
max.h
------------------------------
int max(int,int);
2. implement the interface:
max.c
------------------------------
#include "max.h"
int max(int a, int b)
{
return a > b ? a : b;
}
3. code the invoker:
main.c
------------------------------
#include <stdio.h>
#include "max.h"
int main(int argc, const char *const *const argv)
{
printf("max(3,5)=%d\n", max(3,5));
}
4. build script:
main.sh
------------------------------
#!/bin/bash
gcc -Wall -g -c -o max.o max.c
ar rcs libmax.a max.o
gcc -Wall -g -c -o main.o main.c
gcc -o main main.o -L. -lmax
./main
5. build shared library script:
------------------------------
#!/bin/bash
gcc -fPIC -Wall -g -c max.c
gcc -g -shared -Wl,-soname,libmax.so.0 -o libmax.so.0.0 max.o
/sbin/ldconfig -n . <---- generate link libmax.so.0 --> libmax.so.0.0
ln -sf libmax.so.0 libmax.so
gcc -Wall -g -c main.c -o main.o
gcc -g -o main_shared main.o -L. -lmax
LD_LIBRARY_PATH="." ./main_shared
6. asranmysql Makefile:
1 libasranmysql.so: asranmysql.o
2 gcc -g -shared -Wl,-soname,libasranmysql.so.0 -o libasranmysql.so.0.0 asranmysql.o -lmysqlclient
3 asranmysql.o: asranmysql.h asranmysql.c
4 gcc -fPIC -Wall -g -c asranmysql.c
5 install: libasranmysql.so.0.0
6 cp asranmysql.h /usr/local/include
7 cp libasranmysql.so.0.0 /usr/local/lib
8 ldconfig
9 ln -s /usr/local/lib/libasranmysql.so.0 /usr/local/lib/libasranmysql.so
10 uninstall:
11 rm /usr/local/include/asranmysql.h
12 rm /usr/local/lib/libasranmysql.*
13 clean:
14 rm asranmysql.o libasranmysql.so.0.0
分享到:
相关推荐
It does not presume or force a developer to use a particular tool or library. Flask supports extensions that can add application features as if they were implemented in Flask itself. Flask’s main ...
Build a library of reusable scripts with ScriptRunner Create, import, and edit geospatial data on disk or in memory Get to know more about dynamic mapping Create and add features to static maps ...
After that, you will learn how to test your Go application and use templates. By the end of this book you will be able to build your very own high performance apps using Echo. A Quick Start Guide ...
We then cover how you can use LLVM library calls to emit intermediate representation (IR) of simple and complex high-level language paradigms. Moving on, we show you how to implement optimizations at...
How to build and run the console samples on Windows, Linux and iOS This section describes how to run the NetCoreConsoleClient, NetCoreConsolePublisher and NetCoreConsoleServer sample applications. ...
link ▶Use standard order for readability and to avoid hidden dependencies: C library, C++ library, other libraries' .h, your project's .h. All of a project's header files should be listed as ...
2)How to use avfilter? a)To vertically flip a video, you would do: ./ffplay -vfilters vflip input_video.avi But the following commands(apply two vflip filter) will result in the orginal picture ...
offer, and write for full details on how to receive a free IntroPak containing a $15 credit toward your first month's on- line charges. 2. Check with your local software dealer or users' group. ...
Add the project directory to the include path, here's how to do it in details: Under Project > Properties navigate to the C/C++ folder and choose "General", In the field "Additional Include ...
Give examples of each memory concept and how it applies to SQL Server. Describe how SQL Server user and manages its memory. List the primary configuration options that affect memory. ...
In this book, we will cover drawing 2D and 3D graphics, both static and animations. We will also cover the various ways of handling user input and help set the mood of our game playing both 2D and 3D ...
your program to use IMAP instead of POP and expect everything in IMAP to be supported. Assuming your mail server supports IMAP, your JavaMail-based program can take Fundamentals of the JavaMail API...
// the Standard C++ Library basic_string<> template and add to it the // the following conveniences: // - The full MFC CString set of functions (including implicit cast) // - writing to/reading ...
if instead you have a static numbers of views you ought to look at Fragments and the ViewPager in the Compatibility Library instead. Usage In your layout android:id="@+id/viewflow" app:...
the help.) It might work with your OS if you know how to do that. If you are linking to the libraries, as Ocropus does, please link to libtesseract_api. History ======= The engine was developed at...
In general, this mode has been designed and implemented for Vista/Windows 7 Aero, but you can use it in any OSs/modes (see screenshot). The glass (aero) area can be combined with a page header - we'...
- C and assembly code only (C++ not required for codec library) - reentrant, statically linkable - low memory (details in docs/ subdirectory) - option to use Intel Integrated Performance ...
Document/View - When Not to Use It Avoiding the Document/View Architecture Playing Along with the Document/View Architecture Tricks with Templates Multiple Templates Adding a New Item to your ...
* Yeah, yeah, it's ugly, but I cannot find how to do this correctly * and this seems to work. I anybody has more info on the real-time * clock I'd be interested. Most of this was trial and error...