Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8209785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:50:51+00:00 2026-06-07T09:50:51+00:00

I created simple application, which uses sqlite3 as it’s datastore back-end. I faced no

  • 0

I created simple application, which uses sqlite3 as it’s datastore back-end. I faced no problems when building and running it on Linux, but after I tried to build it on Windows, I see weird linking error:

Linking dist\build\hnotes\hnotes.exe ...
C:\Documents and Settings\Admin\Application Data\cabal\sqlite-0.5.2.2\ghc-7.0.4/libHSsqlite-0.5.2.2.
a(sqlite3-local.o):sqlite3-local.c:(.text+0x21): undefined reference to `sqlite3_temp_directory'
C:\Documents and Settings\Admin\Application Data\cabal\sqlite-0.5.2.2\ghc-7.0.4/libHSsqlite-0.5.2.2.
a(sqlite3-local.o):sqlite3-local.c:(.text+0x40): undefined reference to `sqlite3_temp_directory'
collect2: v ld     1
cabal.EXE: Error: some packages failed to install:
hnotes-0.1 failed during the building phase. The exception was:
ExitFailure 1

What may be wrong there? I suspect that qalite3.dll has to be added to linking stage, but have no idea how to do that. Adding –extra-lib-dirs=path-to-sqlite-dll doesn’t help either (perhaps because I need to update my cabal file somehow, to support this?).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:50:53+00:00Added an answer on June 7, 2026 at 9:50 am

    Not sure if It’s a bug or not, but the error comes from the sqlite3.h include of the sqlite package.

    A look in the file shows this

    /*
    ** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000>
    **
    ** If this global variable is made to point to a string which is
    ** the name of a folder (a.k.a. directory), then all temporary files
    ** created by SQLite will be placed in that directory.  If this variable
    ** is a NULL pointer, then SQLite performs a search for an appropriate
    ** temporary file directory.
    **
    ** It is not safe to modify this variable once a [database connection]
    ** has been opened.  It is intended that this variable be set once
    ** as part of process initialization and before any SQLite interface
    ** routines have been call and remain unchanged thereafter.
    */
    SQLITE_EXTERN char *sqlite3_temp_directory;
    

    so it’s declared as an extern. So simple test:

    module Main where
    
    import Database.SQLite
    
    main 
     = do hwd <- openConnection "test"
          closeConnection hwd
          putStrLn "done"
    

    This crashes during linking as expected with the error you have above.
    So I created a small C test file foo.c

    #include "sqlite-0.5.2.2\\include\\sqlite3-local.h"
    
    char* sqlite3_temp_directory = "C:\\test2";
    

    So I’m defining a temp_directory and then I pass the c file along during compilation of the haskell source

    $ ghc test.hs foo.c
    [1 of 1] Compiling Main             ( test.hs, test.o )
    Linking test.exe ...
    

    and then running it also returns the expected result

    $ ./test
    done
    

    So it seems that you just need to give a value for the sqlite3_temp_directory, which if you set it to a NULL pointer will use the TMP/TEMP etc variables as defined in the SQLLITE manual.

    edit, follow up on why it worked on Linux but not on windows

    In the sqlite package, there’s a file sqlite3.c under the folder sqlite3.6. This provides a bunch of defaults for the sqlite package.

    when on linux OS_UNIX is defined and when on linux it uses the defines under OS_WIN.
    The function we’re interested in is the function which sets the temporary directory. for unix this’ll be unixGetTempname and for windows winGetTempname.

    If you look at the implementation of both these functions, for the unix one it has list of directories that it’ll try

      static const char *azDirs[] = {
         0,
         "/var/tmp",
         "/usr/tmp",
         "/tmp",
         ".",
      };
    

    it tries to access them in order and the one it can write to it uses to generate a temporary folder in.

    For windows however one of the first lines are:

      if( sqlite3_temp_directory ){
        sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
      }else if( isNT() ){
    

    so for windows sqlite3_temp_directory is actually used. This is why it doesn’t compile if It can’t find it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple situation. I've created an application which uses SQL Server as database. I could
I have created a simple win 32 application..in which it has a textbox and
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
I have a web application code which uses jsp, servlet and ejb. I created
I want to produce a simple enough application which uses a QTreeView widget to
I develop a simple MVC3 CRUD application - simple controllers / views, which uses
I want to create a simple server application which runs on the desktop, and
I want to create a simple j2me application for a start which links with
I created a simple application inspired by this example in order to test all
I created a simple Sudoku application, where each 3x3 squares is a user control,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.