Here are some C and C++ libraries, DLLs, VCLs, source code, components, modules, application frameworks, class libraries, source code snippets, and the like, that you can use with your programs without payment of fees and royalties. Note that some libraries (etc) listed here may have certain restrictions about its use and/or distribution. Be sure you read the licence conditions in each package before using them.
A few types of libraries have been moved to their own pages, due to the large number of items in those categories. Here are some of the other pages containing free libraries on this site:
The information provided on this page comes without any warranty whatsoever. Use it at your own risk. Just because a program, book or service is listed here or has a good review does not mean that I endorse or approve of the program or of any of its contents. All the other standard disclaimers also apply.
If you want your applications to support Adobe Type 1 fonts, this rasterizing library might be just what you need. It requires a Unix system. It is implemented independently of X11, so it might be the solution for those of you who don't want to use the Type 1 rasterizer provided with X11R5 and later. The source code for the package has a filename like t1lib-*.tar.gz (where * is replaced by the version number). Latest: There is a Windows port of t1lib available as well.
Heard of True Type? Well, now you can include True Type support in your programs on systems that do not have True Type support by default. Linux and other OSes are supported.
This version of STL (Standard Template Library for C++) is available free of charge from their website. It is apparently also shipped with the current versions of the Borland C++ compilers.
If your compiler does not have a recent Standard Template Library implementation, you might want to consider this version available free from SGI.
The LinuxThreads library implements Posix 1003.1c threads on (as the name reveals) Linux. It provides kernel-level threads where scheduling is handled by the Linux kernel. Thus, unlike user-level thread packages, it can take advantage of multiprocessors.
This C library implements POSIX threads on a variety of operating systems, including Linux, FreeBSD, SCO Unix, Solaris, SunOS and DOS.
QpThread is a C++ framework for threads and Unix signals that operates on top of POSIX threads. It supports deferred cancellation (through C++ exceptions), timers, thread pools, etc.
ICU, or the International Components for Unicode, comprises C/C++ and Java libraries for Unicode support, internationalisation and globalisation (i8n/g11n). It supports Unicode text handling, full character properties and character set conversions, with more than 500 codepages, Unicode regular expressions, language sensitive collation and searching, normalisation (normalization), upper/lowercase, script transliterations, more than 230 locale data, multi-calendar and time zones, formatting of dates, times, numbers, currencies, messages, etc. If you are writing an application that requires internationalization and globalization support, and are working with Unicode, this is something that you should check out. It is licensed under the X License (an open source licence). Platforms supported include Windows, Linux, AIX, HP-UX, Solaris, etc.
This site is a source of "free peer-reviewed portable C++ source libraries" (quoted from the site). There are numerous libraries available, including libraries for managing date and time, filesystems, iterators, random numbers, regex, tests, strings, text processing, containers, math and numerics, data structures, memory, parsing, concurrent programming, algorithms, etc.
STLSoft is a collection of templates in header form that contain numerous classes and functions for Windows and Unix systems. Included in this library are ATLSTL (for creating COM components with the Active Template Library), COMSTL (allows the manipulation of the Component Object Model interfaces and API), .netSTL (applies STL techniques to the .NET framework), InetSTL (applies the STL techniques to the Internet APIs), MFCSTL (allows the manipulation of the Microsoft Foundation Classes or MFC), UNIXSTL (library for programming Unix-type systems), and WinSTL (allows you to program using the Windows API). The library comes with documentation and works with numerous compilers including Borland C++, Comeau C/C++, Digital Mars C/C++, GNU gcc, Intel C/C++, Metrowerks Codewarrior, Microsoft Visual C++, and OpenWatcom. As of version 1.8.1, STLSoft is licensed under the BSD license.
libunicows allows you to write programs that use Unicode on Windows 9x/ME with a compiler other than Microsoft Visual C++ (the Microsoft unicows library requires Visual C++). This library supports (at the time I write this) MinGW, Visual C++ 6, Borland C++, and Watcom (and OpenWatcom) C/C++. It comes with source code released under the MIT licence.
OSLib is a C library for programmers writing system software (whether it be embedded software or even entire operating system kernels). It comprises 4 libraries (the extender library, the standard C library, the math library and the kernel library).
The MIT Exokernel Operating System attempts to provide a level of abstraction of hardware so that you can concentrate on the other aspects of implementing an operating system. It may be useful to those of you planning to write an operating system.
The OSKit Project is a C framework of 34 components providing a wide variety of facilities that is useful for people planning to write operating system kernels, servers, boot loaders, embedded applications and the like. The function libraries provide numerous facilities, including some common C library services (string, memory, printf, etc), default handlers for traps and interrupts, kernel support functions such as those that set up and manipulate page tables (etc), support for multiprocessor systems, POSIX emulation system call libraries, memory management, threads, synchronization, scheduling, debugging aids, hard disk handling, file system implementations, device driver implementations (SCSI, IDE, network drivers), video driver implementations, etc. The portions of OSKit that contain machine-dependent code currently supports Intel x86 and Digital DNARD (StrongArm SA-110 CPU).
regex is a regular expression parser that is released into the public domain (or so the site says). It is useful if you want to write a program using regular expressions but don't want to use the GPL ones that come from the Free Software Foundation. (The package is somewhere in the middle of the page linked to; just scroll down to find it.)
glob is a parser to handle wildcards (similar to the way that Unix shells parse wildcards). It is released into the public domain (or so the site says). It is useful if you want to write a program with globbing facility but don't want to use the GPL ones that come from the Free Software Foundation. (The package is somewhere in the middle of the page linked to; just scroll down to find it.)
SynEdit is a multi-line edit control that you can use in your Delphi and Borland C++ Builder programs. Features include syntax highlighting for a variety of programming languages and a macro recorder. This is a VCL control that comes with source code.
libsigc++ has C++ classes that provide you a typesafe callback system. You can define signals and assign callback functions to those signals. It is licensed under the GNU Library General Public License (LGPL). It works on platforms with a standards-compliant C++ compiler, such as those with gcc (see the Free C/C++ Compilers page for gcc). A port for Microsoft Visual C++ (which does not implement partial specializating) has also been integrated into the distribution, so the library should also work with that compiler.
The Standard Function Library, or SFL, contains routines for compression, encryption, encoding, data type conversion, data output formatting, process control, dates, times, calendars, symbol tables, linked lists, configuration files, error message files, string manipulation, searching, Internet socket access, MIME, CGI, SMTP, batch programming, debug tracing, directory access, environment access, etc. It is designed with portability in mind. The library is written in ANSI C and is supported on MSDOS, Windows, OS/2, Linux, AIX, SunOS, HP/UX, Solaris, NetBSD, FreeBSD, SCO OpenServer, Digital Unix, and OpenVMS. The source code is also available.
HTML Tidy is an HTML validation library that comes with source code. It allows you to embed HTML validation facilities into your application, which may come in handy if you are writing your own editor.
Views extends STL to include domain views, which allows you to simplify your code when you work with containers.
GNU Lightning is a library of routines that allows programs to generate assembly language code at runtime. It abstracts the target CPU, exposing your program to a standardized RISC instruction set. The library is supposed to be fast, thus making it useful if you're developing a Just-In-Time compiler.
Ever wanted to create your own syntax-highlighting editor? Scintilla is a source code edit control, similar in concept to Microsoft's RichEdit control, that supports things like syntax highlighting, code completion and call tips. It also supports things like the use of proportional fonts, bold, italics, multiple foreground and background colours, and multiple fonts. The source code is available free, and the licence allows you to use the control in any project, free or commercial.
If you need to add speech to your programs, or enable it to process speech input, TurboPower's Async Professional provides you an easy access to Microsoft's Speech API (SAPI) allowing you to integrate voice/speech recognition and speech synthesis in your programs. It also handles the sending and receiving (as well as viewing and printing) of faxes (and converts BMP, DCX, PCX and TIF files automatically), alphanumeric and text (GSM/SMS) paging, high speed file transfers (including the major file transfer protocols like Zmodem and FTP), IP telephony (audio and video, Voice Over IP or VOIP), Internet communications (Winsock access), supports ISDN modems, RS-232 and RS-485 standards, and includes an XML-based modem database. And so on. Like most of the TurboPower tools, this open source toolkit may be used with Delphi and Borland C++ Builder and ActiveX environments like Microsoft Visual C++ and Visual Basic. If you use Borland Kylix on Linux, you might want to try the TurboPower Async Professional CLX version.
TurboPower SysTools contain numerous utility functions and classes for Borland Delphi and Borland C++ Builder as well as programming environments that support COM objects (like Microsoft Visual Basic, Microsoft Visual C++. Among the routines included in this library are string manipulation routines, date and time math routines, high-speed sorting, high-precision maths, runtime math expression analyzer, Microsoft Excel-like finance and statistical routines, email attachment MIME encoding and decoding, reusable containers (stacks, queues, trees, deques, hash tables), CRC data integrity checking, 1 dimensional and 2 dimensional (1-D and 2-D) bar codes, money routines, logging classes, patterns, random number distributions, text data manipulation and more. SysTools is open source, released by TurboPower under the Mozilla Public License. It works on Windows systems. There is also a version of TurboPower SysTools for Kylix.
TurboPower Orpheus contains over 120 VCL components such as data entry components, data entry validators, grid for presenting and editing 2 column information, status bars, progress bars, button and tab styles, reports, countdown and elapsed timer components, etc. Orpheus is open source, and may be used with development tools that support VCL such as Borland Delphi and C++Builder.
ShellShock contains native VCL components that allow your application to integrate with the Windows shell and Windows explorer. Included in this package are tree views, list views, combo boxes, enumeration of folder contents, monitoring of shell events, file operations (copy, delete, move, rename, together with Windows shell animations), drag and drop support, Windows shortcut creation and inspection, customization of common dialog boxes, minimization to the system tray, etc. You need to use a development tool that supports VCL such as Borland C++Builder and Delphi to use this toolkit. ShellShock comes with source code.
If you need to create demo versions of your programs, you might want to check out TurboPower's OnGuard library. The library provides you the ability to create applications that are time-limited, feature-limited, limited to a certain number of uses, limited to a certain number of concurrent network users, etc. Written in Object Pascal, it may be used in Windows development using tools like Borland C++Builder or Delphi.
TurboPower Essentials has 13 open source native VCL components that provides drop-down calendars and calculators, roll-up dialog boxes, 3-D labels, tiled backgrounds, scrolling messages, menu buttons, etc. You need to use a development tool that supports VCL such as Borland C++Builder and Delphi to use this toolkit.
Add time, task and contact management to your applications with Visual PlanIt's synchronized data-aware VCL components. You can create mult-column Outlook style contact grids; day, week, month event views, Outlook style task lists, connect-and-go database connectivity, printing, etc. The components are compatible with Delphi and C++Builder (and presumably any other development system that supports VCL components).
GetPot, an anagram of the ubiquitous getopt, allows programs to parse command lines and simple input files by simply including the header file for the library (the entire library is apparently in the header file). C++, Java, Ruby and Python versions are currently available. The library is distributed under the GNU LGPL.
MyLibC is a clone of glibc for Windows. The author wrote this to reduce the size of executables that resulted when glib was used on Windows. Sources are provided.
uClibc is a C library for developing embedded Linux systems. It supports shared libraries, multithreading and runs on standard Linux systems with support for ARM, i386, h8300, m68k, mips, mipsel, PowerPC, SH, SPARC, and v850 processors.
GradC++ ToolBox contains several C++ components dealing with threading, program options, logging, and initialisation of COBRA services. It comes with an administrative guide, programmers' guide and sources. The C++ library may be used free of charge for non-commercial purposes.
This library has functions which you can call from your MSDOS programs to access the long filenames (LFN) API found in Windows 95 and above. It thus makes it easy for you to write long file name (LFN) support. The library contains the POSIX.1 compatible opendir() functions, DOS findfirst() functions, open() functions, fopen() functions, mk/rm/chdir(), remove(), unlink(), rename(), getcwd(), getdcwd(), getcurdir(), fullpath(), lfn2sfn(). As you can see, all the hard work of accessing the API has been done for you - just use the usual familiar functions (whether Unix or DOS). It requires a Borland compiler to compile (which you can get it for free, legally - check out our Free C/C++ Compilers page).
This is a library that eases the work needed to port Unix programs to NT. There aren't many details on the website about the libraries' capabilities, but you can simply download it from their site and check it out yourself.
ClibPDF is a C library that allows you to create PDF files from your application or even CGI scripts. With PDF files becoming more popular on the Internet, it is beginning to look like it may be a good idea for more applications to be able to create and access PDF files. The library is free if you are using it for non-profit purposes.
This C++ graph library, based on the Standard Template Library (STL), contains classes useful when you work with graphs, nodes, and edges, as well as basic algorithms which can be used to build more complex graph algorithms. The library has been used on Solaris, Linux, Windows NT, 95, 98, HP-UX and FreeBSD, although it is possible that it works elsewhere as well.
Matrix TCL Lite is a C++ matrix template class that may be used for common matrix operations like any other built-in data types. It has been tested with Borland C++ 5.0 (both 16 and 32 bit); Borland C++ 5.5, C++ Builder version 1.0, 3.0, 4.0 and 5.0; MS Visual C++ version 4.0, 4.2, 5.0 and 6.0; SUN g++ under Sun Solaris; GNU C++ and SGI C++ version 7.2.1; Metrowerks CodeWarrior Pro 5; and Sybase Power++ v 2.1.
Ensemble is a toolkit for building reliable distributed applications. Included in this toolkit is a library of protocols which you can use to build your distributed applications. The library primarily uses UDP/IP sockets. You can write your applications in C, C++, Java (on Solaris and NT), and ML. Ensemble itself is written in ML and will apparently run on any platform that supports Objective Caml and sockets, including Windows, SunOS4, Solaris, Linux and RS6000-AIX. You can get the binaries for SunOS, Solaris, Linux and Windows NT. Source code is also available for download.
This is a plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Versions are available for C, Fortran 77 and Fortran 90 compilers on Linux, FreeBSD, OpenVMS, MS-DOS, Windows 95/98/NT, and other flavours of Unix. On some operating systems, Java, Perl, and Python are also supported. (Not all versions of the library are free, though.)
This C library "allows network management applications to access SMI MIB module information through a well defined API that hides the nasty details of locating and parsing SMIv1/v2 MIB modules."
This is a simple network library built on top of glib. It works on Linux, BSD, Mac OS X, Solaris, HP and Windows.
This is a "Unix-based Garmin CPS communication and analysis function library and development system. To quote/paraphrase from their documentation, it includes high level host communication routines that treat waypoints, almanacs, etc as objects; datum conversions; cartographic functions; etc. The source code is distributed under the GNU LGPL, and is written in ANSI C.
Whisper is a general purpose C++ application framework, which takes advantage of templates, multiple inheritance, STL and exceptions. It is portable to both Macintosh and Win32. It contains numerous debugging tools.
This is a CORBA 2 ORB (with associated libraries) that was originally developed by AT&T Laboratories, Cambridge, and is certified CORBA 2.1 compliant. OmniORB is distributed under the GNU GPL and the libraries in the package is distributed under the Library GPL. The package is designed in such a way so that you can actually distribute your applications that use the libraries without being forced to release your source code as well. Platforms supported include Solaris, Windows NT, Windows 95, Linux (x86, PowerPC), Digital Unix, AIX, HPUX, Open VMS (Alpha and Vax), NextStep, Reliant Unix, Phar Lap's Real Time ETS Kernel, SGI Irix, SCO Unixware, MacOS, OS RTEMS, SCO OpenServer, etc. In case you are wondering what CORBA is, it basically defines the interface and API that allows programs to communicate with each other even if they are running on separate machines on different hardware and operating systems. If you need more information, you can check up the Object Management Group's website for their beginner's guide.
GNU Common C++ is a C++ framework for developing portable threaded applications. It has abstractions for threads, sockets, XML parsing, serialization, config files, and so on, hiding the differences between platforms in its classes so that you can write code that is (hopefully) portable. It is released under the GNU GPL license.
Hoard is a malloc/free replacement that is supposed to be fast, scalable and memory efficient. It supports Linux and other Unix platforms.
This is a free implementation of the curses package of Unix. It has all the BSD curses facilities plus the System V enhancements. Platforms supported include Linux and most (if not all) Unix systems. It has been ported even to OS/2. For those not familiar with curses, this is library that allows programs to write to the screen in a terminal-independent manner.
A C++ class library that has a number of features, including classes for retrieving files via HTTP, sending and receiving email, database classes, thread support, string class, html parser, etc. It supports Unix platforms.
A garbage collector for C/C++ that can also function as a memory leak detector. You can simply replace your calls to malloc() with GC_malloc(). Win32, Win32s, OS/2, MacOS, AmigaDOS and Unix systems are supported.
Added : 04/12/1997 Amended : 04/12/1997 Licensing : N/A
This list is not exhaustive. If you are looking for a particular library, and you don't find it here, try an ordinary Web search engine (e.g. Google). If you do find a suitable library, why not use the submission form to add it to this list for the next person?
Due to the increasing size of this list, and problems with updating the automatic poster at rtfm.mit.edu, the full list is now only available on the Web (at "http://www.trumphurst.com/cpplibs/" and "http://purl.oclc.org/NET/C++Libraries").
Marshall Cline's C++ FAQ is available on his Web page.
I have not included a credits list, because it would be nearly as large as the rest of the file! Many thanks to all those who contributed, and I hope you won't be offended that I haven't mentioned you.
Please mail comments, criticisms, additions and amendments to me at cpplibs@trumphurst.com. However, please DO NOT mail me with requests for assistance in finding files mentioned in the list. I am unable to provide such a service. Definite information such as "file xyz is no longer at site xxx" IS welcome - even better if you can tell me an alternative site where it can be found. If you are new to the Internet, try to find out about tools such as archie, whois, www, gopher etc. I recommend the newsgroups "news.announce.newusers" and "news.answers" for starters. See also the Web "roadmap" to such services listed below.
Added : 01/01/1995 Amended : 16/05/2006 Licensing : N/A
Please add references at the end of your text in the form <tag>:<item> [;<link text>]
Where
Added : 01/01/1995 Amended : 09/04/2001 Licensing : N/A
Added : 01/01/1995 Amended : 26/04/2000 Licensing : N/A
Mail amendments or additions to this list
A Web form for submissions to this list
Mail the author for permission to distribute
Copyright (c) 2006 Nikki Locke, Trumphurst Ltd.
Permission is granted to distribute over the Internet without charge.
The author's permission is required (and usually given) to distribute
in any other way, including on CD.
鍘熸枃錛歨ttp://www.vckbase.com/document/viewdoc/?id=1540 |
|
C++ 鎵╁睍鍜屽祵鍏?Python
浣滆咃細鑳¢噾灞?/a>
甯哥敤鐨凱ython/C API浠嬬粛
銆銆涓嬮潰鏄緥瀛愪腑鐢ㄥ埌鐨勫嚑涓狿ython/C
API鐨勭畝瑕佷粙緇嶅強紺轟緥浠g爜銆傛敞鎰忥紝榪欏茍涓嶆槸榪欎簺鍑芥暟鐨勮緇嗕粙緇嶏紝鑰屼粎浠呮槸鎴戜滑鎵鐢ㄥ埌鐨勫姛鑳界畝浠嬶紝鏇磋緇嗗唴瀹硅鍙傝冩枃妗1]銆乕2]銆乕3]銆乕4]銆?br />
鎵撳紑Microsoft Visual Studio .NET 2003錛屾柊寤轟竴涓帶鍒跺彴紼嬪簭錛?include <Python.h>錛屽茍鍦╩ain鍑芥暟閲屽姞鍏ョず渚嬩唬鐮併?br />
//鍏堝畾涔変竴浜涘彉閲?
char *cstr;1. void Py_Initialize( )
PyObject *pstr, *pmod, *pdict;
PyObject *pfunc, *pargs;
鎵ц涓孌礟ython浠g爜錛屽氨濂借薄鏄湪__main__ 鍑芥暟閲岄潰鎵ц涓鏍楓備緥錛?/p>
PyRun_SimpleString("from time import time,ctime\n"3. PyObject* PyImport_ImportModule( char *name)
"print ''Today is'',ctime(time())\n");
瀵煎叆涓涓狿ython妯″潡錛屽弬鏁皀ame鍙互鏄?.py鏂囦歡鐨勬枃浠跺悕銆傜浉褰撲簬Python鍐呭緩鍑芥暟__import__()銆備緥錛?/p>
pmod = PyImport_ImportModule("mymod"); //mymod.py4. PyObject* PyModule_GetDict( PyObject *module)
鐩稿綋浜嶱ython妯″潡瀵硅薄鐨刜_dict__ 灞炴э紝寰楀埌妯″潡鍚嶇О絀洪棿涓嬬殑瀛楀吀瀵硅薄銆備緥錛?/p>
pdict = PyModule_GetDict(pmod);5. PyObject* PyRun_String( const char *str, int start, PyObject *globals, PyObject *locals)
鎵ц涓孌礟ython浠g爜銆?/p>
pstr = PyRun_String("message", Py_eval_input, pdict, pdict);6. int PyArg_Parse( PyObject *args, char *format, ...)
瑙f瀯Python鏁版嵁涓篊鐨勭被鍨嬶紝榪欐牱C紼嬪簭涓墠鍙互浣跨敤Python閲岀殑鏁版嵁銆備緥錛?/p>
/* convert to C and print it*/7. PyObject* PyObject_GetAttrString( PyObject *o, char *attr_name)
PyArg_Parse(pstr, "s", &cstr);
printf("%s\n", cstr);
榪斿洖妯″潡瀵硅薄o涓殑attr_name 灞炴ф垨鍑芥暟錛岀浉褰撲簬Python涓〃杈懼紡璇彞錛歰.attr_name銆備緥錛?/p>
/* to call mymod.transform(mymod.message) */8. PyObject* Py_BuildValue( char *format, ...)
pfunc = PyObject_GetAttrString(pmod, "transform");
鏋勫緩涓涓弬鏁板垪琛紝鎶奀綾誨瀷杞崲涓篜ython瀵硅薄錛屼嬌Python鍙互浣跨敤C綾誨瀷鏁版嵁錛屼緥錛?/p>
cstr="this is hjs''s test, to uppercase";9. PyEval_CallObject(PyObject* pfunc, PyObject* pargs)
pargs = Py_BuildValue("(s)", cstr);
銆銆姝ゅ嚱鏁版湁涓や釜鍙傛暟錛岄兘鎸囧悜Python瀵硅薄鎸囬拡錛宲func鏄璋冪敤鐨凱ython 鍑芥暟錛岄氬父鍙敤PyObject_GetAttrString()鑾峰緱錛沺args鏄嚱鏁扮殑鍙傛暟鍒楄〃錛岄氬父鍙敤Py_BuildValue()鏋勫緩銆備緥錛?/p>
pstr = PyEval_CallObject(pfunc, pargs);10. void Py_Finalize( )
PyArg_Parse(pstr, "s", &cstr);
printf("%s\n", cstr);
鍏抽棴Python瑙i噴鍣紝閲婃斁瑙i噴鍣ㄦ墍鍗犵敤鐨勮祫婧愩備緥錛?/p>
Py_Finalize();
銆銆Python2.4鐜娌℃湁鎻愪緵璋冭瘯鐗堟湰鐨凱ython24d.lib錛屾墍浠ヤ笂榪扮ず渚嬪湪release妯″紡涓嬬紪璇戙傜紪璇戝畬鎴愬悗錛屾妸鍙鏂囦歡鍜岄檮2緇欏嚭鐨刴ymod.py鏂囦歡鏀懼湪涓璧鳳紝鍐嶇偣鍑誨嵆鍙繍琛屻備負浜嗙畝鍖栫紪紼嬶紝闄? 緇欏嚭浜唖implepy.h銆傝繖鏍鳳紝璋冪敤mymod.transform鍙樻垚濡備笅褰㈠紡錛?/p>
//#include鈥漵implepy.h鈥?br />CSimplepy py;
py.ImportModule("mymod");
std::string str=py.CallObject("transform",
"this is hjs''s test, to uppercase");
printf("%s\n", str.c_str());
銆銆鎺ヤ笅鏉ワ紝鎴戜滑鏉ョ敤C++涓篜ython緙栧啓鎵╁睍妯″潡(鍔ㄦ侀摼鎺ュ簱)錛屽茍鍦≒ython紼嬪簭涓皟鐢–++寮鍙戠殑鎵╁睍鍔熻兘鍑芥暟銆傜敓鎴愪竴涓彇鍚嶄負pyUtil鐨刉in32 DLL宸ョ▼錛岄櫎浜唒yUtil.cpp鏂囦歡浠ュ錛屼粠宸ョ▼涓Щ闄ゆ墍鏈夊叾瀹冩枃浠訛紝騫跺~鍏ュ涓嬬殑浠g爜錛?
// pyUtil.cpp鍦≒ython浠g爜涓皟鐢ㄨ繖涓姩鎬侀摼鎺ュ簱錛?
#ifdef PYUTIL_EXPORTS
#define PYUTIL_API __declspec(dllexport)
#else
#define PYUTIL_API __declspec(dllimport)
#endif
#include<windows.h>
#include<string>
#include<Python.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
?)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
std::string Recognise_Img(const std::string url)
{
//榪斿洖緇撴灉
return "浠巇ll涓繑鍥炵殑鏁版嵁... : " +url;
}
static PyObject* Recognise(PyObject *self, PyObject *args)
{
const char *url;
std::string sts;
if (!PyArg_ParseTuple(args, "s", &url))
return NULL;
sts = Recognise_Img(url);
return Py_BuildValue("s", sts.c_str() );
}
static PyMethodDef AllMyMethods[] = {
{"Recognise", Recognise, METH_VARARGS},//鏆撮湶緇橮ython鐨勫嚱鏁?br /> {NULL, NULL} /* Sentinel */
};
extern "C" PYUTIL_API void initpyUtil()
{
PyObject *m, *d;
m = Py_InitModule("pyUtil", AllMyMethods); //鍒濆鍖栨湰妯″潡錛屽茍鏆撮湶鍑芥暟
d = PyModule_GetDict(m);
}
import pyUtil銆銆 鐢–++涓篜ython鍐欐墿灞曟椂錛屽鏋滄偍鎰挎剰浣跨敤Boost.Python搴撶殑璇濓紝寮鍙戣繃紼嬩細鍙樺緱鏇村紑蹇僇錛岃緙栧啓涓涓笌涓婅堪pyUtil鍚屾牱鍔熻兘鐨勫姩鎬? 閾炬帴搴擄紝鍙渶鎶婃枃浠跺唴瀹規浛鎹負涓嬮潰鐨勪唬鐮併傚綋鐒訛紝緙栬瘧闇瑕乥oost_python.lib鏀寔錛岃繍琛岄渶瑕乥oost_python.dll鏀寔銆?
result = pyUtil.Recognise("input url of specific data")
print "the result is: "+ result
#include<string>鎵鏈夌ず渚嬮兘鍦∕icrosoft Windows XP Professional + Microsoft Visual Studio .NET 2003 + Python2.4鐜涓嬫祴璇曢氳繃錛屾湰鏂囨墍鐢ㄧ殑Boost搴撲負1.33鐗堟湰銆?
#include <boost/python.hpp>
using namespace boost::python;
#pragma comment(lib, "boost_python.lib")
std::string strtmp;
char const* Recognise(const char* url)
{
strtmp ="浠巇ll涓繑鍥炵殑鏁版嵁... : ";
strtmp+=url;
return strtmp.c_str();
}
BOOST_PYTHON_MODULE(pyUtil)
{
def("Recognise", Recognise);
}
闄? text.txt
this is test text in text.txt.
闄? mymod.py
import string
message = ''original string''
message =message+message
msg_error=""
try:
text_file = open("text.txt", "r")
whole_thing = text_file.read()
print whole_thing
text_file.close()
except IOError, (errno, strerror):
print "I/O error(%s): %s" % (errno, strerror)
def transform(input):
#input = string.replace(input, ''life'', ''Python'')
return string.upper(input)
def change_msg(nul):
global message #濡傛灉娌℃湁姝よ錛宮essage鏄嚱鏁伴噷澶寸殑灞閮ㄥ彉閲?br /> message=''string changed''
return message
def r_file(nul):
return whole_thing
def get_msg(nul):
return message
闄? simplepy.h
#ifndef _SIMPLEPY_H_
#define _SIMPLEPY_H_
// simplepy.h v1.0
// Purpose: facilities for Embedded Python.
// by hujinshan @2005騫?鏈?鏃?:13:02
#include
using std::string;
#include
//--------------------------------------------------------------------
// Purpose: ease the job to embed Python into C++ applications
// by hujinshan @2005騫?鏈?鏃?:13:18
//--------------------------------------------------------------------
class CSimplepy // : private noncopyable
{
public:
///constructor
CSimplepy()
{
Py_Initialize();
pstr=NULL, pmod=NULL, pdict=NULL;
pfunc=NULL, pargs=NULL;
}
///destructor
virtual ~CSimplepy()
{
Py_Finalize();
}
///import the user module
bool ImportModule(const char* mod_name)
{
try{
pmod = PyImport_ImportModule(const_cast(mod_name));
if(pmod==NULL)
return false;
pdict = PyModule_GetDict(pmod);
}
catch(...)
{
return false;
}
if(pmod!=NULL && pdict!=NULL)
return true;
else
return false;
}
///Executes the Python source code from command in the __main__ module.
///If __main__ does not already exist, it is created.
///Returns 0 on success or -1 if an exception was raised.
///If there was an error, there is no way to get the exception information.
int Run_SimpleString(const char* str)
{
return PyRun_SimpleString(const_cast(str) );
}
///PyRun_String("message", Py_eval_input, pdict, pdict);
///Execute Python source code from str in the context specified by the dictionaries globals.
///The parameter start specifies the start token that should be used to parse the source code.
///Returns the result of executing the code as a Python object, or NULL if an exception was raised.
string Run_String(const char* str)
{
char *cstr;
pstr = PyRun_String(str, Py_eval_input, pdict, pdict);
if(pstr==NULL)
throw ("when Run_String, there is an exception was raised by Python environment.");
PyArg_Parse(pstr, "s", &cstr);
return string(cstr);
}
///support olny one parameter for python function, I think it''s just enough.
string CallObject(const char* func_name, const char* parameter)
{
pfunc=NULL;
pfunc = PyObject_GetAttrString(pmod, const_cast(func_name));
if(pfunc==NULL)
throw (string("do not found in Python module for: ")
+func_name).c_str();
char* cstr;
pargs = Py_BuildValue("(s)", const_cast(parameter));
pstr = PyEval_CallObject(pfunc, pargs);
if(pstr==NULL)
throw ("when PyEval_CallObject, there is an exception was raised by Python environment");
PyArg_Parse(pstr, "s", &cstr);
return string(cstr);
}
//PyObject *args;
//args = Py_BuildValue("(si)", label, count); /* make arg-list */
//pres = PyEval_CallObject(Handler, args);
protected:
PyObject *pstr, *pmod, *pdict;
PyObject *pfunc, *pargs;
};
#endif // _SIMPLEPY_H_
// end of file
鍘熸枃鍦板潃錛?a >http://teddyma.cnblogs.com/archive/2005/08/31/226688.html
Version:
Link: http://aspectsharp.sourceforge.net/
Status: beta
Dependency: antlr, Castle.DynamicProxy
Description:
Aspect# is an AOP (Aspect Oriented Programming) framework for the CLI (.Net and Mono). It relies on DynamicProxy and offers a built-in language to declare and configure aspects, and is compliant to AopAlliance. It became part of the Castle Project in June 2005.
-聽 Custom mini configuration language, not xml.
-聽 Mix/Intercept classes and methods through dicnamic proxy approach.
Restrictions:
- Classes to be created dynamic proxy for shouldn鈥檛 be sealed and only virtual methods can be intercepted.
-聽 Using intercepted classes is not completely transaparent to users that users should explicit create the dynamically proxied class through the AspectEngine.
-聽 No static weaving support.
Version: 0.7
Status: beta
Link: http://sourceforge.net/projects/aspectdng
Dependency: mono.petoolkit, rail
Description:
AspectDNG is a .NET aspect weaver, that's to say a tool that can "transplant" code into an existing assembly. This transplant is made after the standard .NET compilation, which means that both aspect and the so called "base" code (the one the transplant will be operated on) can be developped in any programming language that is compatible with .NET CLS. Another way to say that: AspectDNG works on assemblies (EXE or DLL) that may have been created out of C#, VB.NET, Eiffel.NET, Mananged C++...
-聽 Xml, Xpath based configuration file format.
-聽 IL level static Weaving.
-聽 Custom xml based disassembled language ILML which can be used to convert assemblies to and be modified/combined and then converted to assemblies.
Restrictions:
-聽 Static weaving only.
-聽 Not very stable.
Version:
Link: http://www.cs.virginia.edu/~eos
Status: beta
Dependency: none
Description:
Eos is an aspect-oriented extension for C# on Microsoft廬 .NET Framework鈩? Eos aims to improve upon the current aspect-oriented language model in three dimensions. First, it generalizes aspect instantiation & advice weaving model to eliminate the need for the work-arounds that are unavoidable today when aspects are used to express certain crosscutting concerns. Second it generalizes the join point model. Third it aims to eliminate the distinction between class and aspect constructs in favor of a single conceptual building block that combines the expressive capabilities of current classes and aspects, significantly improving conceptual integrity and uniformity in language design. The language is very similar to AspectJ except for constructs which are not implemented in Eos and constructs which AspectJ does not provides.
-聽 AspectJ like extended C# langauage and custom compiler.
Restrictions:
-聽 Static weaving only.
-聽 Not very stable.
Version: 0.7
Link: http://theagiledeveloper.com/category/15.aspx
Status: beta
Dependency: none
Description:
Encase is an aspect oriented programming framework for the .NET Platform written in C#. Encase is unique in that it provides aspects to be applied during runtime in managed code rather then being configuration file based that other AOP frameworks rely upon.聽The advantage of applying aspects in this way is that it promotes productivity to developers new and/or unfamiliar with AOP.
Restrictions:
-聽 Encase cannot mixin multiple classes that implement a shared interface? For instance, if class A implements Ialphabet, and class B implements Ialphabet, classes A and B can not both be mixed in as an aspect.
-聽 Encase can only provide interception and aspect weaving to virtual (overriable) methods and properties.
-聽 Encase is unable to apply aspects to sealed (NotInheritable) classes.
-聽 Like Aspect#, but more unstable.
Version:
Link: http://gael.fraiteur.net/postsharp.aspx
Status: alpha
Dependency: none
Description:
PostSharp is a free and open-source聽post-compiler for the .NET Framework. PostSharp is an extensible platform that makes it easy to develop and execute static program analysis and program transformation plug-ins.
-聽 Developped under .Net Framework 2.0 beta
-聽 There is a very good third pary collection library 鈥?鈥淴ipho.Collections鈥?for .Net 2.0 in the source code
Restrictions:
-聽 Not say to be a really aop framework yet.
Version:
Link: http://www.dcl.hpi.uni-potsdam
Status: beta
Dependency: none
Description:
The LOOM .NET project aims to investigate and promote the usage of AOP in the context of the Microsoft .NET framework. We have been developing two AOP tools (so called weavers) that all implement different approaches to weaving: A runtime weaver crating weaved objects on the fly and a static weaver.
Main
-聽 Support under .Net Framework 2.0 beta
-聽Include both dynamic proxy based dynamic interception and il level rail like static weaving support.
Restrictions:
-聽
Not very stable.
7.聽 Others
Libcurl涓轟竴涓厤璐瑰紑婧愮殑錛屽鎴風url浼犺緭搴擄紝鏀寔FTP錛?/span>FTPS錛?/span>TFTP錛?/span>HTTP錛?/span>HTTPS錛?/span>GOPHER錛?/span>TELNET錛?/span>DICT錛?/span>FILE鍜?/span>LDAP錛岃法騫沖彴錛屾敮鎸?/span>Windows錛?/span>Unix錛?/span>Linux絳夛紝綰跨▼瀹夊叏錛屾敮鎸?/span>Ipv6銆傚茍涓旀槗浜庝嬌鐢ㄣ?/span>
聽
浠?/span>http://curl.haxx.se/libcurl/ 涓嬭澆涓涓ǔ瀹氱殑鐗堟湰錛屾敞鎰忛夋嫨OS銆?/span>
聽
涓嬭澆涓嬫潵鐨勬槸婧愮爜鍖咃紝闇瑕佺紪璇戙?/span>
瑙e帇zip鏂囦歡錛岃繘鍏?/span>curl-7.14.0\lib鐩綍錛堟垜涓嬭澆鐨勬槸7.14.0錛夈?/span>
緙栬瘧Debug鐗堟湰銆傛柊寤轟竴涓壒澶勭悊bat鏂囦歡錛屽buildDebug.bat錛屽唴瀹瑰涓嬶細
call "C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat"
set CFG=debug-dll-ssl-dll-zlib-dll
set OPENSSL_PATH=E:\SSL\openssl-0.9.7e
set ZLIB_PATH=E:\zip\zlib123
nmake -f Makefile.vc6
聽
鍏惰緭鍑猴細libcurld_imp.lib, libcurld.dll
聽
緙栬瘧Release鐗堟湰銆傛柊寤轟竴涓壒澶勭悊鏂囦歡BuildRelease.bat錛屽唴瀹瑰涓嬶細
call "C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat"
set CFG=release-dll-ssl-dll-zlib-dll
set OPENSSL_PATH=E:\SSL\openssl-0.9.7e
set ZLIB_PATH=E:\zip\zlib123
nmake -f Makefile.vc6
聽
鍏惰緭鍑猴細libcurl_imp.lib, libcurl.dll
聽
涓婇潰緙栬瘧鐨勬槸libcurl鐨?/span> dll錛屼嬌鐢?/span>OpenSSL Dll鐗堟湰鍜?/span>Zlib Dll鐗堟湰銆傚鏋滄病鏈夛紝鍙互浠?/span>www.openssl.org鎴栬?/span>http://www.zlib.net/涓嬭澆銆?/span>
濡傛灉闇瑕佺紪璇戝叾浠栫増鏈紝鍙煡鐪?/span>Makefile.vc6錛岃瀹氱浉搴旂殑CFG 鍙傛暟鍗沖彲銆?/span>
聽
鍟嗕笟杞歡浣跨敤libcurl鏃訛紝鍙渶瑕佸寘鍚叾copywrite澹版槑鍗沖彲銆?/span>
聽
聽
涓嶆敮鎸?/span>SOCKS4銆?/span>
SOCKS5瀹炵幇鏈夌己闄鳳紝瀵艱嚧蹇呴』璁劇疆鐢ㄦ埛鍜屽瘑鐮併?/span>
榪炴帴 proxy 榪囩▼涓嶈兘璁劇疆瓚呮椂銆?/span>posted on 2005-11-29 17:03 Michael 闃呰(1072) 璇勮(2) 聽緙栬緫聽鏀惰棌
1銆丟TK+聽 (Gtkmm)
GTK+鏈鍒濇槸GIMP鐨勪笓鐢ㄥ紑鍙戝簱錛屽悗鏉ュ彂灞曚負Linux涓嬪紑鍙戝浘褰㈢晫闈㈢殑搴旂敤紼嬪簭鐨勪富嫻佸紑鍙戝伐鍏蜂箣涓銆侴TK+2.0鏄嚜鐢辮蔣浠訛紝騫朵笖鏄疓NU宸ョ▼鐨勪竴閮ㄥ垎銆侴TK+2.0鐨勮鍙崗璁槸LGPL銆?/p>
GTK+浣跨敤C璇█寮鍙戯紝浣嗘槸鍏惰璁¤呬嬌鐢ㄩ潰鍚戝璞℃妧鏈?鍦℅NOME騫沖彴涓婃彁渚涗簡C++(gtkmm)銆丳erl銆丷uby銆丣ava鍜孭ython(PyGTK)緇戝畾錛屽叾浠栫殑緇戝畾鏈堿da銆?D銆?Haskell銆丳HP鍜屾墍鏈夌殑.NET緙栫▼璇█銆?/p>
涓庡叾浠栧緢澶氶儴浠跺伐鍏風涓嶅悓錛孏TK+騫朵笉鍩轟簬Xt銆傝繖涓鍐崇瓥浼樺姡浜掕錛氫紭鐐規槸GTK+鍙互搴旂敤浜庡叾浠栫郴緇燂紝鍏剁伒媧繪т篃寰堝己錛涜岀己鐐瑰氨鏄畠鏃犳硶鍒╃敤浠ヤ紶緇熸柟娉曚負X11瀹氬埗鐨刋璧勬簮鏁版嵁搴撱?/p>
Glade鏄竴涓晫闈㈣璁″伐鍏鳳紝浣嗘槸瀹冧篃鍖呭惈浜嗕竴縐嶆弿榪癎UI鐣岄潰鐨刋ML璇█錛屽畠鍜宭ibglade涓璧峰伐浣滃氨鍙互鐩存帴浣跨敤GTK鍜孏NOME鎺т歡銆?/p>
2銆丵t
Qt鏄疶rolltech鍏徃鐨勪竴涓駭鍝併?
Qt鏄竴涓騫沖彴鐨凜++鍥懼艦鐢ㄦ埛鐣岄潰搴旂敤紼嬪簭妗嗘灦銆傚畠鎻愪緵緇欏簲鐢ㄧ▼搴忓紑鍙戣呭緩绔嬭壓鏈駭鐨勫浘褰㈢敤鎴風晫闈㈡墍闇鐨勬墍鐢ㄥ姛鑳姐俀t鏄畬鍏ㄩ潰鍚戝璞$殑寰堝鏄撴墿灞曪紝騫朵笖 鍏佽鐪熸鍦扮粍浠剁紪紼嬨?鑷粠1996騫存棭浜涙椂鍊欙紝Qt榪涘叆鍟嗕笟棰嗗煙錛屽畠宸茬粡鎴愪負鍏ㄤ笘鐣岃寖鍥村唴鏁板崈縐嶆垚鍔熺殑搴旂敤 紼嬪簭鐨勫熀紜銆俀t涔熸槸嫻佽鐨凩inux妗岄潰鐜KDE 鐨勫熀紜錛孠DE鏄墍鏈変富瑕佺殑Linux鍙戣鐗堢殑涓涓爣鍑嗙粍浠躲?
Qt鏀寔涓嬭堪騫沖彴錛?MS/Windows - 95銆?8銆丯T 4.0銆丮E銆佸拰2000
Unix/X11 - Linux銆丼un Solaris銆丠P-UX銆丆ompaq Tru64 UNIX銆両BM AIX銆丼GI IRIX鍜屽叾瀹冨緢澶歑11騫沖彴
Macintosh - Mac OS X
Embedded - 鏈夊撫緙撳啿(framebuffer)鏀寔鐨凩inux騫沖彴銆?3銆亀xWidgets
寮婧愯蔣浠訛紙LGPL錛夛紝閽堝C++銆丳ython浠ュ強Perl鐨勮法騫沖彴宸ュ叿闆嗐?/p>
璇︾粏浠嬬粛錛屽弬瑙?a >緇嗚堪 wxWindows
wxWidget浣滀負涓涓狢++ GUI Library浠?992鍙戝睍鍒扮幇鍦紝宸茬粡鍦ㄥ叏鐞冭寖鍥村唴浜х敓浜嗘瀬澶х殑褰卞搷鍔涳紝鍒╃敤榪欎釜綾誨簱榪涜GUI寮鍙戠殑杞歡鏇存槸涓嶈鍏舵暟銆?/p>wxWidgets鍘熷悕wxWindows錛屾槸鐢盝ulian Smart浜?992騫磋繕鍦ㄨ嫳鍥界埍涓佸牎澶у浜哄伐鏅鴻兘搴旂敤鐮旂┒鎵寮濮嬬殑涓涓」鐩侸ulian Smart鐜板湪鏄疉nthemion杞歡鍏徃鐨勬妧鏈葷洃銆?/p>
綆鍗曞湴璇達紝wxWidgets鎻愪緵浜嗙敤浜庡彲鍦ㄥ騫沖彴涓婂紑鍙慓UI搴旂敤紼嬪簭鐨勪竴鏁村綆鍗曟槗瀛︽槗鐢ㄧ殑API銆倃xWidgets鏀寔鐨勫騫沖彴鍖呮嫭
Windows 3.1/95/98/NT/2000/XP銆佸甫鏈塎otif
1.2鐗堟湰浠ヤ笂鐨刄nix銆佸甫鏈塆TK+鐨刄nix/Linux/*BSD銆丮ac絳夌瓑銆傚紑鍙戣呭彧闇瑕佺敤鑷繁浣跨敤鐨勭郴緇熷鉤鍙扮殑緙栬瘧鍣ㄧ紪璇戞簮紼嬪簭錛屽茍閾炬帴涓?br /> 鐩稿簲鐨勫簱鏂囦歡錛岀敓鎴愮殑紼嬪簭浠g爜鍗沖叿鏈夎騫沖彴鐨勫瑙傚拰鐣岄潰銆傚湪榪欎簺GUI涔嬩笂錛寃xWidgets榪樻彁渚涗簡鍦ㄧ嚎甯姪銆佺綉緇滅紪紼嬨佹祦澶勭悊銆佸縐嶅父鐢ㄥ浘褰㈡牸寮忔敮
鎸併佹暟鎹簱鏀寔銆丠TML瀵熺湅鍜屾墦鍗幫紝絳夌瓑鍚勭寮哄ぇ鐨勫姛鑳姐?/p>wxWidgets鏀寔鐨刉indows涓婄殑澶氱嫻佽緙栬瘧鍣ㄥ寘鎷細
Visual C++ 1.5, 4.0, 5.0, 6.0
Borland C++ 4.5, 5.0
Borland C++ Builder 1.0, 3.0
Watcom C++ 10.6 (Win32)
Cygwin
MinGW32
Metrowerks CodeWarrior 44銆丗ox
What is FOX?
![]()
FOX is a C++ based Toolkit for developing Graphical User Interfaces easily and effectively. It offers a wide, and growing, collection of Controls, and provides state of the art facilities such as drag and drop, selection, as well as OpenGL widgets for 3D graphical manipulation. FOX also implements icons, images, and user-convenience features such as status line help, and tooltips. Tooltips may even be used for 3D objects!
Considerable importance has been placed on making FOX one of the fastest toolkits around, and to minimize memory use:- FOX uses a number of techniques to speed up drawing and spatial layout of the GUI. Memory is conserved by allowing programmers to create and destroy GUI elements on the fly.
Even though FOX offers a large collection of Controls already, FOX leverages C++ to allow programmers to easily build additional Controls and GUI elements, simply by taking existing controls, and creating a derived class which simply adds or redefines the desired behavior.
One of the prime design goals of FOX is the ease of programming; thus, most controls can be created using a single line of C++ code; most parameters have sensible default values, so that they may be omitted, and layout managers ensure that designers of GUI's do not have to worry about precise alignments.
Another nice feature of FOX which significantly reduces the number of lines of code which have to be written is FOX's ability to have widgets connect to each other, and passing certain commands between them; for example, a menu entry Hide Toolbar can be directly connected to the Toolbar, and cause it to hide.
Finally, FOX makes it easy to maintain the state of the GUI in an application by having the GUI elements automatically updating themselves by interrogating the application's state. This feature eliminates the large amount of effort that may go into sensitizing, graying out, checking/unchecking etc. depending on the application state.
FOX is Platform Independence! ![]()
The list of platforms is growing! Currently, we have FOX running on a large number of operating systems, ranging from Linux, FreeBSD, SGI IRIX, HP-UX, IBM AIX, SUN Solaris, DEC/Compaq Tru64 UNIX, to MS-Window operating systems like Windows 9x, Windows NT, Windows ME and Windows 2000. Since most of the FOX implementation is completely oblivious to the underlying platform (in many cases it is not even including header files), applications work virtually identically on all these platforms.
For example, here is the FOX textedit sample application running under Windows NT.聽 And here is the same application running on a Silicon GraphicsOctane system.
涓漢姣旇緝鍠滄Gtkmm錛屼唬鐮佹瘮杈冨共鍑錛屽彧鏈塆UI錛屼絾鍦╓indows涓嬬殑鏁堟灉浼間箮娌℃湁鍘熺敓鐨刉indow鎺т歡濂?/p>
Features
- Use inheritance to derive custom widgets.
- Type-safe signal handlers, in standard C++.
- Polymorphism.
- Use of Standard C++ Library, including strings, containers, and iterators.
- Full internationalisation with UTF8.
- Complete C++ memory management
- Object composition
- Automatic deallocation of dynamically allocated widgets.
- Full use of C++ namespaces.
- No macros.
- Cross-platform: Linux (gcc), FreeBSD (gcc), NetBSD (gcc), Solaris (gcc, Forte), Win32 (gcc, MSVC++ .Net 2003), MacOS X (gcc), others
- Free software and free of cost for both Open Source and proprietary development.
- Discussed, designed and implemented in public.