Skip to content

Change dll name #161

@yiv1

Description

@yiv1

This issue is a continuation #147

  1. fix(build): add -DLUA_BUILD_AS_DLL if building shared + Windows #150
    this merge solves the problem of building on windows

  2. improvement(build): add -Dlibrary_name for change name *.dll, *.so, *… #157
    this merge did not solve the problem of renaming the dll library

My steps:

Download fresh zig fetch --save git+https://github.com/natecraddock/ziglua from master.

build.zig

const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});

    const moduleLua = b.createModule(.{
        .root_source_file = b.path("./lua.zig"),
        .target = target,
        .optimize = .ReleaseFast,
    });
	
	const libraryLua = b.addLibrary(.{
        .linkage = .dynamic,
        .name = "lualib",
        .root_module = moduleLua,
    });

    const lua_dep = b.dependency("zlua", .{
        .target = target,
        .optimize = .ReleaseFast,
		.lang = .lua54,
		.shared = true,
		.library_name = "lua54",
    });

    libraryLua.root_module.addImport("zlua", lua_dep.module("zlua"));
	
	b.installArtifact(libraryLua);
}

Exec zig build got error error: option 'library_name' has unsupported type: *const [5:0]u8.

Exec zig build -Dlibrary_name=lua54

error: invalid option: -Dlibrary_name
error:   access the help menu with 'zig build -h'

zig build -h

build [steps] [options]

Steps:
  install (default)            Copy build artifacts to prefix path
  uninstall                    Remove build artifacts from prefix path

General Options:
  -p, --prefix [path]          Where to install files (default: zig-out)
  --prefix-lib-dir [path]      Where to install libraries
  --prefix-exe-dir [path]      Where to install executables
  --prefix-include-dir [path]  Where to install C header files

  --release[=mode]             Request release mode, optionally specifying a
                               preferred optimization mode: fast, safe, small

  -fdarling,  -fno-darling     Integration with system-installed Darling to
                               execute macOS programs on Linux hosts
                               (default: no)
  -fqemu,     -fno-qemu        Integration with system-installed QEMU to execute
                               foreign-architecture programs on Linux hosts
                               (default: no)
  --glibc-runtimes [path]      Enhances QEMU integration by providing glibc built
                               for multiple foreign architectures, allowing
                               execution of non-native programs that link with glibc.
  -frosetta,  -fno-rosetta     Rely on Rosetta to execute x86_64 programs on
                               ARM64 macOS hosts. (default: no)
  -fwasmtime, -fno-wasmtime    Integration with system-installed wasmtime to
                               execute WASI binaries. (default: no)
  -fwine,     -fno-wine        Integration with system-installed Wine to execute
                               Windows programs on Linux hosts. (default: no)

  -h, --help                   Print this help and exit
  -l, --list-steps             Print available steps
  --verbose                    Print commands before executing them
  --color [auto|off|on]        Enable or disable colored error messages
  --prominent-compile-errors   Buffer compile errors and display at end
  --summary [mode]             Control the printing of the build summary
    all                        Print the build summary in its entirety
    new                        Omit cached steps
    failures                   (Default) Only print failed steps
    none                       Do not print the build summary
  -j<N>                        Limit concurrent jobs (default is to use all CPU cores)
  --maxrss <bytes>             Limit memory usage (default is to use available memory)
  --skip-oom-steps             Instead of failing, skip steps that would exceed --maxrss
  --fetch                      Exit after fetching dependency tree
  --watch                      Continuously rebuild when source files are modified
  --fuzz                       Continuously search for unit test failures
  --debounce <ms>              Delay before rebuilding after changed file detected
     -fincremental             Enable incremental compilation
  -fno-incremental             Disable incremental compilation

Project-Specific Options:
  -Dtarget=[string]            The CPU architecture, OS, and ABI to build for
  -Dcpu=[string]               Target CPU features to add or subtract
  -Dofmt=[string]              Target object format
  -Ddynamic-linker=[string]    Path to interpreter on the target system

System Integration Options:
  --search-prefix [path]       Add a path to look for binaries, libraries, headers
  --sysroot [path]             Set the system root directory (usually /)
  --libc [file]                Provide a file which specifies libc paths

  --system [pkgdir]            Disable package fetching; enable all integrations
  -fsys=[name]                 Enable a system integration
  -fno-sys=[name]              Disable a system integration

  Available System Integrations:                Enabled:
  (none)                                        -

Advanced Options:
  -freference-trace[=num]      How many lines of reference trace should be shown per compile error
  -fno-reference-trace         Disable reference trace
  -fallow-so-scripts           Allows .so files to be GNU ld scripts
  -fno-allow-so-scripts        (default) .so files must be ELF files
  --build-file [file]          Override path to build.zig
  --cache-dir [path]           Override path to local Zig cache directory
  --global-cache-dir [path]    Override path to global Zig cache directory
  --zig-lib-dir [arg]          Override path to Zig lib directory
  --build-runner [file]        Override path to build runner
  --seed [integer]             For shuffling dependency traversal order (default: random)
  --debug-log [scope]          Enable debugging the compiler
  --debug-pkg-config           Fail if unknown pkg-config flags encountered
  --debug-rt                   Debug compiler runtime libraries
  --verbose-link               Enable compiler debug output for linking
  --verbose-air                Enable compiler debug output for Zig AIR
  --verbose-llvm-ir[=file]     Enable compiler debug output for LLVM IR
  --verbose-llvm-bc=[file]     Enable compiler debug output for LLVM BC
  --verbose-cimport            Enable compiler debug output for C imports
  --verbose-cc                 Enable compiler debug output for C compilation
  --verbose-llvm-cpu-features  Enable compiler debug output for LLVM CPU features

If i remove all library_name build success, but the import will be a library named lua.dll

Microsoft (R) COFF/PE Dumper Version 14.37.32825.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file C:\Users\***\lualib.dll

File Type: DLL

  Section contains the following imports:

    lua.dll
             180027818 Import Address Table
             1800276D8 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                           0 luaL_checkstack
                           0 luaL_checkversion_
                           0 lua_createtable
                           0 lua_pushcclosure
                           0 lua_pushinteger
                           0 lua_setfield
                           0 lua_settop
                           0 lua_tointegerx

    api-ms-win-crt-runtime-l1-1-0.dll
    ...

I need the import to be with the library name lua54.dll

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions