emmt / AndorCameras.jl

A Julia interface to Andor cameras
Other
3 stars 3 forks source link

Build error #3

Closed joreb closed 3 years ago

joreb commented 3 years ago

┌ Error: Error building AndorCameras: │ "E:\Programs\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe" -I. -I"C:\Program Files\AndorSDK3" -O2 -Wall \ │ -DAT_DLL=\""C:\Program Files\AndorSDK3"\atcore.dll\" gendeps.c -o gendeps │ gendeps.c: In function 'main': │ gendeps.c:57:77: error: 'AT_0xffffffff' undeclared (first use in this function) │ #define DEF_ATCONST(name, format) printf("const " #name format "\n", JOIN(AT,name)) │ ^~~ │ gendeps.c:59:20: note: in definition of macro '_JOIN' │ #define _JOIN(a,b) a##b │ ^ │ gendeps.c:57:72: note: in expansion of macro 'JOIN' │ #define DEF_ATCONST(name, format) printf("const " #name format "\n", JOIN(AT,name)) │ ^~~~ │ gendeps.c:136:3: note: in expansion of macro 'DEF_AT_CONST' │ DEF_AT_CONST(INFINITE, " = MSEC(0x%X)"); │ ^~~~ │ gendeps.c:57:77: note: each undeclared identifier is reported only once for each function it appears in │ #define DEF_ATCONST(name, format) printf("const " #name format "\n", JOIN(AT,name)) │ ^~~ │ gendeps.c:59:20: note: in definition of macro '_JOIN' │ #define _JOIN(a,b) a##b │ ^ │ gendeps.c:57:72: note: in expansion of macro 'JOIN' │ #define DEF_ATCONST(name, format) printf("const " #name format "\n", JOIN(AT,name)) │ ^~~~ │ gendeps.c:136:3: note: in expansion of macro 'DEF_AT_CONST' │ DEF_AT_CONST(INFINITE, " = MSEC(0x%X)"); │ ^~~~ │ gendeps.c:57:77: error: 'AT_1' undeclared (first use in this function); did you mean 'AT_H'? │ #define DEF_ATCONST(name, format) printf("const " #name format "\n", JOIN(AT,name)) │ ^~~ │ gendeps.c:59:20: note: in definition of macro '_JOIN' │ #define _JOIN(a,b) a##b │ ^ │ gendeps.c:57:72: note: in expansion of macro 'JOIN' │ #define DEF_ATCONST(name, format) printf("const " #name format "\n", JOIN(AT,name)) │ ^~~~ │ gendeps.c:139:3: note: in expansion of macro 'DEF_AT_CONST' │ DEF_AT_CONST(TRUE, " = BOOL(%d)"); │ ^~~~ │ gendeps.c:57:77: error: 'AT_0' undeclared (first use in this function); did you mean 'AT_H'? │ #define DEF_ATCONST(name, format) printf("const " #name format "\n", JOIN(AT,name)) │ ^~~ │ gendeps.c:59:20: note: in definition of macro '_JOIN' │ #define _JOIN(a,b) a##b │ ^ │ gendeps.c:57:72: note: in expansion of macro 'JOIN' │ #define DEF_ATCONST(name, format) printf("const " #name format "\n", JOIN(AT,name)) │ ^~~~ │ gendeps.c:142:3: note: in expansion of macro 'DEF_AT_CONST' │ DEF_AT_CONST(FALSE, " = BOOL(%d)"); │ ^~~~ │ make: *** [Makefile:49: gendeps] Error 1 │ ERROR: LoadError: failed process: Process(make all, ProcessExited(2)) [2] │ Stacktrace: │ [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at .\error.jl:42 │ [2] pipeline_error at .\process.jl:705 [inlined] │ [3] #run#505(::Bool, ::Function, ::Cmd) at .\process.jl:663 │ [4] run(::Cmd) at .\process.jl:661 │ [5] top-level scope at none:0 │ [6] include at .\boot.jl:317 [inlined] │ [7] include_relative(::Module, ::String) at .\loading.jl:1044 │ [8] include(::Module, ::String) at .\sysimg.jl:29 │ [9] include(::String) at .\client.jl:392 │ [10] top-level scope at none:0 │ in expression starting at E:\Work\Julia_code\dev\AndorCameras\deps\build.jl:1 └ @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Pkg\src\Operations.jl:1096

I have the following error whilst building in julia 1.0.5 in windows any idea why? i have cmake and hardcoded my SDK path

emmt commented 3 years ago

I do not have an Andor camera on a Windows machine. Can you provide a list of the contents of the directory C:\Program Files\AndorSDK3? Which version of the SDK have you installed?

joreb commented 3 years ago

sdk3 The SDK verion is 3.15 .

Thank you for the support!!!

emmt commented 3 years ago

My understanding is that all files (headers and dll's) are in the same directory for you (not 2 separate directories as on Linux). But this is not the problem here because you managed to have the correct C flags:

┌ Error: Error building AndorCameras: │ "E:\Programs\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe" -I. -I"C:\Program Files\AndorSDK3" -O2 │ -Wall -DAT_DLL=""C:\Program Files\AndorSDK3"\atcore.dll" gendeps.c -o gendeps

and the compiler does not complain about a missing atcore.h file. According to the error message, the issue is in the pre-processing pass. Can you run the following command (the -E flags only runs the C preprocessor) and send me the result (gendeps.i) at eric.thiebaut@univ-lyon1.fr :

"E:/Programs/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe" -I. -I"C:/Program Files/AndorSDK3" -DAT_DLL="C:/Program Files/AndorSDK3/atcore.dll" -E gendeps.c -o gendeps.i
emmt commented 3 years ago

I think I have found the bug. Can you just update your clone of the repository (git pull -r), rebuild and let me know if that worked for you.

emmt commented 3 years ago

I have just pushed modifications (with updated instructions in README.md) to make the installation more flexible and Windows-aware. This should simplify this process for you.

joreb commented 3 years ago

Error: Error building AndorCameras: │ gcc -I. -IE:\Programs\AndorSDK3\ -O2 -Wall \ │ -DAT_DLL=\"E:\Programs\AndorSDK3\atcore.dll\" gendeps.c -o gendeps │ gendeps.c: In function 'main': │ gendeps.c:46:35: warning: unknown escape sequence: '\P' │ printf("const _DLL = \"%s\"\n", AT_DLL); │ ^~ │ gendeps.c:46:35: warning: unknown escape sequence: '\A' │ rm -f "deps.jl" │ process_begin: CreateProcess(NULL, rm -f deps.jl, ...) failed. │ make (e=2): The system cannot find the file specified. │ make: *** [Makefile:44: deps.jl] Error 2 │ │ I will run the following command: │ make deps.jl AT_INCDIR="E:\Programs\AndorSDK3\" AT_LIBDIR="E:\Programs\AndorSDK3\" AT_DLL="E:\Programs\AndorSDK3\atcore.dll" │ │ ERROR: LoadError: failed process: Process(make deps.jl 'AT_INCDIR=E:\Programs\AndorSDK3\' 'AT_LIBDIR=E:\Programs\AndorSDK3\' 'AT_DLL=E:\Programs\AndorSDK3\atcore.dll', ProcessExited(2)) [2] │ Stacktrace: │ [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at .\error.jl:42 │ [2] pipeline_error at .\process.jl:705 [inlined] │ [3] #run#505(::Bool, ::Function, ::Cmd) at .\process.jl:663 │ [4] run at .\process.jl:661 [inlined] │ [5] top-level scope at E:\Work\Julia_code\packages\AndorCameras\cij0a\deps\build.jl:64 [inlined] │ [6] top-level scope at .\none:0 │ [7] include at .\boot.jl:317 [inlined] │ [8] include_relative(::Module, ::String) at .\loading.jl:1044 │ [9] include(::Module, ::String) at .\sysimg.jl:29 │ [10] include(::String) at .\client.jl:392 │ [11] top-level scope at none:0 │ in expression starting at E:\Work\Julia_code\packages\AndorCameras\cij0a\deps\build.jl:3 └ @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Pkg\src\Operations.jl:1096

I have run into a new error seemingly deps.jl is not generated at least that is what I understand

emmt commented 3 years ago

Do not use a backslash \ as a directory separator in strings because it is interpreted as an escape sequence in C. This explains the warning messages aboutUse the same separator as Unix (that is a slash /) which is supported by Windows since a while. In your case the compilation command should look like:

make deps.jl 'AT_INCDIR=E:/Programs/AndorSDK3' 'AT_LIBDIR=E:/Programs/AndorSDK3' 'AT_DLL=E:/Programs/AndorSDK3/atcore.dll'

In julia, before running the build, the environment variables should be defined as:

ENV["AT_INCDIR"] ="E:/Programs/AndorSDK3"
ENV["AT_LIBDIR"] = "E:/Programs/AndorSDK3"

or just:

ENV["AT_DIR"] ="E:/Programs/AndorSDK3"

leaving the others undefined.

I realize that, in Windows, joinpath and normpath both use backslashes \ as directory separators, so I have modified the build script to always use slashes /. So please git pull -r before trying again.

joreb commented 3 years ago

Hi!!!!

, Thank you so much for the support again.

I think I figured out the bug the rm -f and chown arent available in windows. ERROR

This makes the deps.jl without any errors .

I run into an image acquisition issue though.

Capture

also the findzyla is a bash script right? . Its very unfortunate I am imposed to work on windows . I will tweak it to work with windows.

My apologies for being such a noob ...

julia> cam=open(AndorCameras.Camera,0)
AndorCameras.Camera:
    family: "Andor sCMOS", model: "ZYLA-5.5-USB3",Error showing value of type AndorCameras.Camera:
ERROR: strings must not have embedded NULL characters
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] widestringtostring(::Array{UInt16,1}) at E:\Work\Julia_code\dev\AndorCameras\src\AT.jl:315
 [3] getindex(::AndorCameras.Camera, ::AndorCameras.StringFeature) at E:\Work\Julia_code\dev\AndorCameras\src\base.jl:207
 [4] show(::IOContext{REPL.Terminals.TTYTerminal}, ::AndorCameras.Camera) at E:\Work\Julia_code\dev\AndorCameras\src\base.jl:278
 [5] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::AndorCameras.Camera) at .\sysimg.jl:194
 [6] display(::REPL.REPLDisplay, ::MIME{Symbol("text/plain")}, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\REPL\src\REPL.jl:131
 [7] display(::REPL.REPLDisplay, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\REPL\src\REPL.jl:135
 [8] display(::Any) at .\multimedia.jl:287
 [9] #invokelatest#1 at .\essentials.jl:697 [inlined]
 [10] invokelatest at .\essentials.jl:696 [inlined]
 [11] print_response(::IO, ::Any, ::Any, ::Bool, ::Bool, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\REPL\src\REPL.jl:154
 [12] print_response(::REPL.AbstractREPL, ::Any, ::Any, ::Bool, ::Bool) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\REPL\src\REPL.jl:139
 [13] (::getfield(REPL, Symbol("#do_respond#40")){Bool,getfield(REPL, Symbol("##50#59")){REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\REPL\src\REPL.jl:713
 [14] #invokelatest#1 at .\essentials.jl:697 [inlined]
 [15] invokelatest at .\essentials.jl:696 [inlined]
 [16] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\REPL\src\LineEdit.jl:2273
 [17] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\REPL\src\REPL.jl:1034
 [18] run_repl(::REPL.AbstractREPL, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\REPL\src\REPL.jl:191
 [19] (::getfield(Base, Symbol("##720#722")){Bool,Bool,Bool,Bool})(::Module) at .\client.jl:355
 [20] #invokelatest#1 at .\essentials.jl:697 [inlined]
 [21] invokelatest at .\essentials.jl:696 [inlined]
 [22] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at .\client.jl:339
 [23] exec_options(::Base.JLOptions

julia> img=read(cam)
ERROR: strings must not have embedded NULL characters
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] widestringtostring(::Array{UInt16,1}) at E:\Work\Julia_code\dev\AndorCameras\src\AT.jl:315
 [3] repr(::AndorCameras.Camera, ::AndorCameras.EnumeratedFeature, ::Int64) at E:\Work\Julia_code\dev\AndorCameras\src\base.jl:237
 [4] repr at E:\Work\Julia_code\dev\AndorCameras\src\base.jl:230 [inlined]
 [5] getpixelformat(::AndorCameras.Camera) at E:\Work\Julia_code\dev\AndorCameras\src\public.jl:194
 [6] getcapturebitstype(::AndorCameras.Camera) at E:\Work\Julia_code\dev\AndorCameras\src\public.jl:254
 [7] #read#3(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::AndorCameras.Camera) at E:\Work\Julia_code\packages\ScientificCameras\udRp4\src\methods.jl:102
 [8] read(::AndorCameras.Camera) at E:\Work\Julia_code\packages\ScientificCameras\udRp4\src\methods.jl:102
 [9] top-level scope at none:0 ```

 Sorry for the late edit !!!
emmt commented 3 years ago

This is a progress, bravo!

I think that having the package work on Windows would be nice so I am in favor of pursuing that quest ;-)

If you agree to keep testing, I see 2 things I can do:

  1. Solve this embedded NULL characters issue.
  2. Avoid using make. After all, knowing the path to a descent C compiler, all the commands can be directly done by Julia. I can however keep the Makefile for building Linux utilities. Another possibility is to parse the definitions in atcore.h directly with Julia. This would not be too difficult with a couple of regular expressions.

BTW for further discussions, it would be better if you provide the console output as text (which can be searched) rather than picture.

emmt commented 3 years ago

Can you provide the generated deps.jl for a comparison to what I get on Linux?

joreb commented 3 years ago
#
# deps.jl --
#
# Definitions of types and constants for interfacing Andor cameras in Julia.
#
# *DO NOT EDIT* as this file is automatically generated for your machine.
#
#------------------------------------------------------------------------------
#
# This file is part of "AndorCameras.jl" released under the MIT license.
#
# Copyright (C) 2017-2021, Éric Thiébaut.
#

# Path to the dynamic library.
const _DLL = "E:/Programs/AndorSDK3/atcore.dll"

# Types.
const STATUS  = Cint     # for returned status
const HANDLE  = Cint     # AT_H in <atcore.h>
const INDEX   = Cint     # for camera index
const ENUM    = Cint     # for enumeration
const BOOL    = Cint
const INT     = Int64    # AT_64 in <atcore.h>
const FLOAT   = Cdouble
const BYTE    = UInt8    # AT_U8 in <atcore.h>
const WCHAR   = Cwchar_t # AT_WC in <atcore.h>
const STRING  = Cwstring
const FEATURE = Ptr{WCHAR}
const LENGTH  = Cint     # for string length
const MSEC    = Cuint    # for timeout in milliseconds

# Constants.
const INFINITE = MSEC(0xFFFFFFFF)
const TRUE = BOOL(1)
const FALSE = BOOL(0)
const HANDLE_UNINITIALISED = HANDLE(-1)
const HANDLE_SYSTEM = HANDLE(1)

# Status codes.
const SUCCESS = STATUS(0)
const CALLBACK_SUCCESS = STATUS(0)
const ERR_NOTINITIALISED = STATUS(1)
const ERR_NOTIMPLEMENTED = STATUS(2)
const ERR_READONLY = STATUS(3)
const ERR_NOTREADABLE = STATUS(4)
const ERR_NOTWRITABLE = STATUS(5)
const ERR_OUTOFRANGE = STATUS(6)
const ERR_INDEXNOTAVAILABLE = STATUS(7)
const ERR_INDEXNOTIMPLEMENTED = STATUS(8)
const ERR_EXCEEDEDMAXSTRINGLENGTH = STATUS(9)
const ERR_CONNECTION = STATUS(10)
const ERR_NODATA = STATUS(11)
const ERR_INVALIDHANDLE = STATUS(12)
const ERR_TIMEDOUT = STATUS(13)
const ERR_BUFFERFULL = STATUS(14)
const ERR_INVALIDSIZE = STATUS(15)
const ERR_INVALIDALIGNMENT = STATUS(16)
const ERR_COMM = STATUS(17)
const ERR_STRINGNOTAVAILABLE = STATUS(18)
const ERR_STRINGNOTIMPLEMENTED = STATUS(19)
const ERR_NULL_FEATURE = STATUS(20)
const ERR_NULL_HANDLE = STATUS(21)
const ERR_NULL_IMPLEMENTED_VAR = STATUS(22)
const ERR_NULL_READABLE_VAR = STATUS(23)
const ERR_NULL_READONLY_VAR = STATUS(24)
const ERR_NULL_WRITABLE_VAR = STATUS(25)
const ERR_NULL_MINVALUE = STATUS(26)
const ERR_NULL_MAXVALUE = STATUS(27)
const ERR_NULL_VALUE = STATUS(28)
const ERR_NULL_STRING = STATUS(29)
const ERR_NULL_COUNT_VAR = STATUS(30)
const ERR_NULL_ISAVAILABLE_VAR = STATUS(31)
const ERR_NULL_MAXSTRINGLENGTH = STATUS(32)
const ERR_NULL_EVCALLBACK = STATUS(33)
const ERR_NULL_QUEUE_PTR = STATUS(34)
const ERR_NULL_WAIT_PTR = STATUS(35)
const ERR_NULL_PTRSIZE = STATUS(36)
const ERR_NOMEMORY = STATUS(37)
const ERR_DEVICEINUSE = STATUS(38)
const ERR_DEVICENOTFOUND = STATUS(39)
const ERR_HARDWARE_OVERFLOW = STATUS(100)
emmt commented 3 years ago

Thanks! Apart from a few things needed to reset the USB device on Linux, the definitions are the same.

I have just modified the installation rules so that no compiler and no make executable are needed on Windows, the atcore.h header file is parsed by a simple Julia scrip to extract definitions. You may check that this works for you. This however does not yet solve the "NULL character" issue so you may prefer waiting a bit.

emmt commented 3 years ago

I have completly changed the way wide-character strings are handled in AndorCameras. I can only test on the simulated camera on Linux but this should solve the "NULL character" issue for Windows.

The API is cleaner and, as far as I can say, a compiler should not be needed anymore (except for resetting the USB device on Linux but a far better solution would be to have a Julia interface to the USB library).