Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1661612
  • 博文数量: 230
  • 博客积分: 10045
  • 博客等级: 上将
  • 技术积分: 3357
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-30 20:40
文章分类

全部博文(230)

文章存档

2011年(7)

2010年(35)

2009年(62)

2008年(126)

我的朋友

分类:

2008-08-27 17:44:58

闲的无聊用ocaml写了一个DLL/LIB转.A文件的GUI封装。使用的是labtk,ocaml的强类型的确是比较强,害的我filepattern的值改了半天才编译过去。

手动执行转换可以参加下面的文档:
文件:将dll或lib文件转换成a文件.pdf
大小:44KB
下载:下载


GUI版本的ocaml源代码如下:
(*
GUI wrapper for dll/lib to .a file

Author: bilbo
Date: Aug 27, 2008
Version: 0.1

Notes:
type filePattern = {
typename : string;
extensions : string list;
mactypes : string list;
}

val getOpenFile : ?defaultextension:string ->
?filetypes:filePattern list ->
?initialdir:string ->
?initialfile:string ->
?parent:'a Widget.widget -> ?title:string -> unit -> string

*)


open Tk ;;
open Sys;;

let top = openTk () ;;

Wm.title_set top "Convert DLL/LIB to .a" ;;
Wm.geometry_set top "290x70"

let get_base_name fname suffix = (Filename.chop_suffix (Filename.basename fname) suffix);;

let b = Button.create
~text:"DLL To A"
~command:(fun () ->
let f = (getOpenFile ~initialdir:"." ~filetypes:[{typename = "DLL"; extensions = [".dll"]; mactypes =[""]}] ())
in (print_endline f; flush stdout);
match (Filename.check_suffix f ".dll") with
| false -> ()
| true ->
let cmd = Printf.sprintf "pexports %s > %s.def" f (get_base_name f ".dll")
in ignore (Sys.command cmd);
let cmd = Printf.sprintf "dlltool -k -d %s.def -l lib%s.a" (get_base_name f ".dll") (get_base_name f ".dll")
in ignore (Sys.command cmd))
top ;;

let c = Button.create
~text:"Lib To A"
~command:(fun () ->
let f = (getOpenFile ~initialdir:"." ~filetypes:[{typename = "LIB"; extensions = [".lib"]; mactypes =[""]}] ())
in (print_endline f; flush stdout);
match (Filename.check_suffix f ".lib") with
| false -> ()
| true ->
let cmd = Printf.sprintf "reimp -d %s" f
in ignore (Sys.command cmd);
let cmd = Printf.sprintf "dlltool -k -d %s.def -l lib%s.a" (get_base_name f ".lib") (get_base_name f ".lib")
in ignore (Sys.command cmd))
top ;;

let l = Label.create
~text:" "
top ;;

pack [b] ~side:`Top ~fill:`X ;;
pack [l] ~side:`Top ~fill:`X ;;
pack [c] ~side:`Top ~fill:`X ;;

let _ = Printexc.print mainLoop ();;

源代码可以从这里下载。
文件:gui.rar
大小:439KB
下载:下载





阅读(1859) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~