2018-06-16 22:01:23 +01:00
|
|
|
const std = @import("std");
|
|
|
|
|
|
|
|
pub fn main() !void {
|
2020-01-30 03:22:01 +00:00
|
|
|
const args = try std.process.argsAlloc(std.testing.allocator);
|
|
|
|
defer std.process.argsFree(std.testing.allocator, args);
|
2018-06-16 22:01:23 +01:00
|
|
|
|
|
|
|
const dynlib_name = args[1];
|
|
|
|
|
2019-05-30 04:45:28 +01:00
|
|
|
var lib = try std.DynLib.open(dynlib_name);
|
2018-06-16 22:01:23 +01:00
|
|
|
defer lib.close();
|
|
|
|
|
2020-01-06 20:34:50 +00:00
|
|
|
const addFn = lib.lookup(fn (i32, i32) callconv(.C) i32, "add") orelse return error.SymbolNotFound;
|
2018-06-16 22:01:23 +01:00
|
|
|
|
|
|
|
const result = addFn(12, 34);
|
|
|
|
std.debug.assert(result == 46);
|
|
|
|
}
|