闲的无聊用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 |
下载: | 下载 |
|
阅读(1897) | 评论(0) | 转发(0) |