ziyu4huang
ziyu4huang
MModular
Created by ziyu4huang on 10/14/2023 in #questions
Easy to install in offline enviroment, will mojo keep it and provide a package system ?
Recently I just tar entire .modular folder to another machine in our company, which is limit access internal only. I found it's quite easy make it work , I skip venv/jupyter parts, just: * modify mojo.cfg * add some missing .so the my LIBRARY env . (machine has libtinfo.so.6, but no libtinfo.so, I don't know why ) Then all is magically works. I really like this. 😄 I like this minimalist compiler installation just like Nim. Hope mojo can keep like this , and borrow Nim/Nimble package concept. Make install package easy on offline environment.
1 replies
MModular
Created by ziyu4huang on 10/9/2023 in #questions
How to call function in share library
I try to use external_call to load library and symbol. But I don't know how to call it like C . How to do it in Mojo ?? fn main(): let data = "./libexample.so" let data_ptr = to_char_ptr(data) #let flag: c_int = RTLD_NOW let flag: c_int = RTLD_LAZY let hdl = external_call["dlopen", c_void, Pointer[c_char], c_int](data_ptr, flag) print("hdl ", hdl) if hdl == 0: let error_msg_cstr = external_call"dlerror", Pointer[c_char] let msg = StringRef(error_msg_cstr.bitcastInt8) print("lib_handler error ", msg) else: let a = external_call"dlerror", Pointer[c_char] print("lib_handler ", hdl) let sym_name = to_char_ptr("hello_world") let fun_sym = external_call["dlsym", c_void, c_void, Pointer[c_char]](hdl, sym_name) print("fun_sym", fun_sym) print("end of main()")
6 replies
MModular
Created by ziyu4huang on 9/12/2023 in #questions
interoperability for calls from Python to Mojo
As of now, I've only seen examples that demonstrate interoperability from Mojo calling Python. When will Mojo support interoperability for calls from Python to Mojo?
1 replies