在Windows上运行libxlsxwriter [英] Running libxlsxwriter on Windows

查看:792
本文介绍了在Windows上运行libxlsxwriter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用libxlsxwriter,但似乎可以使事情正确编译或运行.

I am trying to use libxlsxwriter, but I can seem to get things to compile or run correctly.

我遵循Windows的使用Mingw-w64msys2的说明,可在此处使用: http://libxlsxwriter .github.io/getting_started.html .

I followed the directions for Windows using Mingw-w64 and msys2 available here: http://libxlsxwriter.github.io/getting_started.html.

我从他们的网站上安装了msys2,并使用pacman -Syu更新了所有内容.然后我用推荐的安装了zlib:

I installed msys2 from their website and updated everything using pacman -Syu. Then I installed zlib with the recommended:

# Install the dev tools for libxlsxwriter.
pacman -S git gcc make zlib-devel

然后运行代码下载并编译libxlswriter:

Then I run the code to download and compile libxlswriter:

# Clone and build libxlsxwriter.
git clone https://github.com/jmcnamara/libxlsxwriter.git
cd libxlsxwriter/
make
make install
# run example
cd ..
cc myexcel.c -o myexcel -lxlsxwriter -lz

现在有一个名为myexcel的可执行文件,它应该创建一个基本的excel文档,但是当我双击它时,我得到了错误:

Now there is an executable named myexcel which should create an basic excel document, but when I double click it I get the errors:

The program can't start because msys-2.0.dll is missing from your computer.

我也因缺少msys-z.dll

我不确定我做错了什么或如何解决.

I'm not sure what I did wrong or how to fix it.

任何帮助将不胜感激

如果我跑步:

make examples
./examples/hello

hello world示例成功运行,因此似乎已正确安装了东西.我想我只是不明白如何运行它来运行用户制作的.c

The hello world example successfully runs so things seem to be installed properly. I guess I just don't understand how to get it to run a user made .c

推荐答案

MSYS控制台定义了MSYS命令和路径.打开控制台时的DLL:例如,如果MSYS安装在C:\msys64中,它将在本地将路径添加到C:\msys64\usr\bin,但不会将其添加到Windows系统PATH.

MSYS console defines the path to MSYS commands & DLLs when opening the console: ex if MSYS is installed in C:\msys64 it locally adds the path to C:\msys64\usr\bin but it does not add it to the Windows system PATH.

因此,如果您单击MSYS外部的可执行文件,则它找不到DLL,因为它们不在Windows PATH中.

So if you click on the executable outside MSYS, it cannot find the DLLs because they are not in windows PATH.

许多解决方案:

1)在用户或计算机PATH中添加C:\msys64\usr\bin(编辑环境变量).另外,您可以访问Windows CMD中的grep之类的命令.缺点是,与findsort之类的命令可能存在混淆/冲突.

1) add C:\msys64\usr\bin in user or computer PATH (edit environment variables). As a bonus you gain access to commands like grep in your windows CMD. As a drawback, there can be mixups/conflicts with commands like find or sort.

2)在可执行文件目录中创建一个包含以下内容的myexcel.bat文件:

2) create a myexcel.bat file containing the following in your executable directory:

@echo off
set PATH=C:\msys64\usr\bin;%PATH%
%~PD0\myexcel.exe

(%~PD0 prefix允许从.bat路径中找到可执行文件,因此,如果从另一个目录运行.bat文件,它仍然会找到可执行文件)

(%~PD0 prefix allows to find the executable from the .bat path so if .bat file is run from another directory it still finds the executable)

3)复制可执行文件所在的MSYS DLL.由于DLL与.exe位于同一目录中,因此Windows会找到它们.建议用于独立发行版,而不用于个人使用,因为它会创建大量副本.

3) copy the MSYS DLLs where your executable resides. Since the DLLs are in the same directory as the .exe Windows will find them. Recommended for a standalone distribution, not for personal use since it creates a lot of copies.

4)与MSYS .a库的静态链接.我不知道是否可以对所有库执行此操作.例如,似乎找不到libz.a.

4) static linkage against MSYS .a libs. I don't know if this can be done for all libs. Cannot seem to find libz.a for instance.

这篇关于在Windows上运行libxlsxwriter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆