mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #157] Error creating tmpfile(s) on WindowsXP #128
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#128
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @goyzhang on GitHub (Mar 19, 2018).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/157
Originally assigned to: @jmcnamara on GitHub.
I'm working on a project which has to be on Windows XP SP3 platform. I tested my codes on Windows 7 and 10. They all work fine. However,on the XP side, I keep getting this error message when workbook_close() is called. After that an empty xlsx file will be created for output.

It seems like the program is somehow unable to create a temp file. Is there any workaround?
@jmcnamara commented on GitHub (Mar 19, 2018):
Hi,
Libxlsxwriter uses a library called tmpfileplus to ensure that the library can create the temporary files it needs to create an xlsx file.
The code for that is in the libxslxwriter repo: https://github.com/jmcnamara/libxlsxwriter/blob/master/third_party/tmpfileplus/tmpfileplus.c
In particular this part is important:
Are those directories/environmental variables (
TMPorTEMP) accessible to your application? Or was the application compiled without_WIN32so that it is trying to useTMPDIRwhich doesn't exist on Win XP?Either way you can directly control the tempdir location from your application, if required, as follows: Specifying a TEMP directory for libxlsxwriter.
John
@goyzhang commented on GitHub (Mar 20, 2018):
Thank you. The directory refer to
c:\docume~1\admini~1\locals~1\tempin WinXP. The directory exists and I was in Administrator. I did compile in WIN32.lxw_workbook_optionsfails to work.lxw_workbook_options options = { LXW_FALSE,(char*)"C:\\Temp" };In WinXP, I tried C:\Temp but no luck. The project is a VS2017 dll. Maybe I should take a deeper look at what was really going on.
@goyzhang commented on GitHub (Mar 20, 2018):
@jmcnamara Hi John,
After some trial-and-error by turning SHOW_DPRINTF on, I found out that in
static FILE *mktempfile_internal(const char *tmpdir, const char *pfx, char **tmpname_ptr, int keep)the functionis_valid_diris returning the wrong value under WinXP(it should return 1). After forcing it to return 1,everything works fine. I'm a starter on C programing, any idea how is that happen and how to fix it? Thank you.@jmcnamara commented on GitHub (Mar 20, 2018):
What value did it return?
Also, what compiler are you using?
@goyzhang commented on GitHub (Mar 20, 2018):
It returns 0 as
(stat(path, &st) == 0)is False. I use Visual Studio 2015 - Windows XP (v140_xp) platform toolset. So I think it's MSBuild by default?@goyzhang commented on GitHub (Mar 21, 2018):
@jmcnamara Problem solved by changing the code generation runtime library from /MT to /MD. Not sure if the dynamic linking would bring any side effect.
@ghost commented on GitHub (May 3, 2018):
In our case, we could not use /MD. The problem seems to be with tmpfileplus. Works well when building with define USE_STANDARD_TMPFILE.