compiling extensions for Windows x64 with mingw-w64
(1) By ericgj72 on 2020-09-28 15:27:41 [link] [source]
It compiles fine, but then gives this error trying to load it (via python 3.8 x64 SQLite3 library):
The specified procedure could not be found
I have read this similar question on Stack Overflow, but I do not think it applies here as the CSV source does have the proper template for a SQLite extension and I have built it successfully in the past as a 32-bit DLL using mingw.
Has anyone successfully used mingw-w64 to build SQLite extensions or should I be looking at another compiler?
(2) By Keith Medcalf (kmedcalf) on 2020-09-28 17:29:02 in reply to 1 [link] [source]
All the time. For simple compiles:
gcc -s -O3 -m32 -I/source/bld csv.c -o csv.dll
gcc -s -O3 -m64 -I/source/bld csv.c -o csv.dll
for 32-bit or 64-bit respectively. Headers are in /source/bld
If you want to enable the various available security features you have to do that on the command line since GCC/MinGW does not do that by default.
>gcc -s -O3 -m64 -mdll -I/source/bld csv.c -o csv.dll >python Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 >>> db = sqlite3.connect(':memory:') >>> db.load_extension('csv.dll') >>> ^Z
(6) By ericgj72 on 2020-09-28 20:42:59 in reply to 2 [link] [source]
Many thanks. I think it was the 'wrong solstice' issue (spring instead of fall??). This machine is on python 3.8.1, sqlite v.3.28.0. But just in case I used your suggested gcc flags when building it. Thanks again!
(9) By Keith Medcalf (kmedcalf) on 2020-09-28 23:15:50 in reply to 6 [link] [source]
Note that I usually use the following flags for 32 and 64 bit builds to "turn on" all the Windows Security features such as nx and ASLR.
-m32 -mdll -mthreads -Wl,-Bstatic,--nxcompat,--dynamicbase,--large-address-aware,--image-base,0x10000000 -static-libgcc
-m64 -mdll -mthreads -Wl,-Bstatic,--nxcompat,--dynamicbase,--high-entropy-va,--image-base,0x180000000 -static-libgcc
in addition to such things as -s (strip) -On (optimization) -pipe etc.
(3.1) By Keith Medcalf (kmedcalf) on 2020-09-28 17:52:56 edited from 3.0 in reply to 1 [link] [source]
Are you using reverse-solstice path names rather than solstices? Note that the documentation says that the name is manufactured from the characters between the last '/' and the next thereafter following '.' converted to lowercase.
If the filename uses \ instead of / then this will not work because there is no / so trying to load \dinky\hocker\shoots\smack.dll will result in looking for the entry point sqlite3_\dinky\hocker\shoots\smack_init which does not exist. You would have to load /dinky/hocker/shoots/smack.dll so that the correct entry point name sqlite3_smack_init is used. Or specify the entry point name by manual.
I believe this has been fixed but perhaps not in the sqlite3.dll that you are using since it is likely an "old" version.
(4) By Scott Robison (casaderobison) on 2020-09-28 19:16:57 in reply to 3.1 [link] [source]
I'm not sure if "solstice" is a term I've just not heard as a common alias for the slash, or if it might be an autocorrect glitch, but its formal name as defined by Unicode "solidus". Similar sound. Just FYI. Also "reverse solidus". See Unicode chart.
(5.1) By TripeHound on 2020-09-28 19:53:02 edited from 5.0 in reply to 3.1 [link] [source]
Keith, given your seemingly-encyclopaedic knowledge of all things to do with dates, time-zones and the like, I'm surprised at you confusing a "solstice" ("when the Sun appears to reach its most northerly or southerly excursion relative to the celestial equator") and the "solidus" (the Unicode name for the "slash" and, when reversed, the "backslash"). :-)
(Scott's reply wasn't there when I started this...)
(7) By Scott Robison (casaderobison) on 2020-09-28 20:56:40 in reply to 5.1 [link] [source]
The joys of delayed moderation. Note: Not meant critically, just a statement.
(8) By Keith Medcalf (kmedcalf) on 2020-09-28 22:54:18 in reply to 5.1 [source]
I sit corrected.