Jump to content

Dll compilation issue


Recommended Posts

Hi,

I compile with g++ (cygwin gcc-3.3.3-3 WindowsXPSP1) a simple dll, with a source similar to this thread: layer's first dll

However, when I try to DllCall it or to DllLoad it, Autoit just freeze (I must CTRL+Break it). It never returns. :( (with autoit 3.1.1 latest beta 37, 38...)

If I make a test C program, which try to "LoadLibrary", it works...

The shared dll produced does contain a DllMain.

I tried various compilation options. (see below for an example of a compilation log)

Have you any clue about the correct option to produce a dll loadable with AutoIt ?

Or is gcc cygwin a non-compatible option to produce Autoit loadable dll ?

Thanks in advance.

VonC

------- COMPILATION LOG SAMPLE -----------

**** Incremental build of configuration Custom for project Sample ****

make -k all

Building file: ../Sample.cpp

g++ -O0 -Wall -c -fmessage-length=0 -v -oSample.o ../Sample.cpp

Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/specs

Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,java,objc,pascal --enable-nls --without-included-gettext --enable-libgcj --with-system-zlib --enable-interpreter --enable-threads=posix --enable-java-gc=boehm --enable-sjlj-exceptions --disable-version-specific-runtime-libs --disable-win32-registry

Thread model: posix

gcc version 3.3.3 (cygwin special)

/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/cc1plus.exe -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../include/w32api -idirafter /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cygwin/lib/../../include/w32api ../Sample.cpp -D__GNUG__=3 -quiet -dumpbase Sample.cpp -auxbase-strip Sample.o -O0 -Wall -version -fmessage-length=0 -o /cygdrive/c/temp/ccNcEYz6.s

GNU C++ version 3.3.3 (cygwin special) (i686-pc-cygwin)

compiled by GNU C version 3.3.3 (cygwin special).

GGC heuristics: --param ggc-min-expand=56 --param ggc-min-heapsize=49086

ignoring nonexistent directory "/usr/local/include"

ignoring nonexistent directory "/usr/i686-pc-cygwin/include"

ignoring duplicate directory "/usr/i686-pc-cygwin/lib/../../include/w32api"

#include "..." search starts here:

#include <...> search starts here:

/usr/include/c++/3.3.3

/usr/include/c++/3.3.3/i686-pc-cygwin

/usr/include/c++/3.3.3/backward

/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include

/usr/include

/usr/include/w32api

End of search list.

/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cygwin/bin/as.exe --traditional-format -oSample.o /cygdrive/c/temp/ccNcEYz6.s

Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/specs

Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,java,objc,pascal --enable-nls --without-included-gettext --enable-libgcj --with-system-zlib --enable-interpreter --enable-threads=posix --enable-java-gc=boehm --enable-sjlj-exceptions --disable-version-specific-runtime-libs --disable-win32-registry

Thread model: posix

gcc version 3.3.3 (cygwin special)

/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/cc1plus.exe -E -D__GNUG__=3 -quiet -v -P -MM -MG -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../include/w32api -idirafter /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cygwin/lib/../../include/w32api ../Sample.cpp -Wall -w -fmessage-length=0 -O0

ignoring nonexistent directory "/usr/local/include"

ignoring nonexistent directory "/usr/i686-pc-cygwin/include"

ignoring duplicate directory "/usr/i686-pc-cygwin/lib/../../include/w32api"

#include "..." search starts here:

#include <...> search starts here:

/usr/include/c++/3.3.3

/usr/include/c++/3.3.3/i686-pc-cygwin

/usr/include/c++/3.3.3/backward

/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include

/usr/include

/usr/include/w32api

End of search list.

Finished building: ../Sample.cpp

Building target: Sample.dll

g++ -shared -o Sample.dll Sample.o

Finished building: Sample.dll

Build complete for project Sample

-- VonCMinefield

Link to comment
Share on other sites

Up, Up :(

To sumarize my problem exposed in the previous post:

Do you have an example of a gcc commande-line able to compile a C source file into a Dll ?

(a Dll that you can then 'DllCall' or 'DllOpen' in an Autoit script)

Again, My gcc command-line does produce a Dll, but the Autoit script freezes when it 'DllCall' or 'DllOpen' it :(

-- VonCMinefield

Link to comment
Share on other sites

Up again, :(

Ok, let me rephrase the question:

Anyone with a valid gcc command-line to produce a dll that can be called within an Autoit script ?

Rq: the only compiler I have access to is a gcc one, the gcc with cygwin...

Thanks in advance.

-- VonCMinefield

Link to comment
Share on other sites

Up again,  :(

Ok, let me rephrase the question:

Rq: the only compiler I have access to is a gcc one, the gcc with cygwin...

Thanks in advance.

<{POST_SNAPBACK}>

Why don't you upload your dll and the script you are using to access this dll and people might be a bit more responsive.
Link to comment
Share on other sites

I use this to compile a DLL:

gcc -c MyDll.c
gcc -shared -o MyDll.dll MyDll.o -Wl,--out-implib,libmessage.a

MyDll.c:

#define EXPORT __declspec(dllexport)
EXPORT int ReturnInt(int src)
{
    return src;
}

AutoIt:

$ret = DllCall("MyDll.dll","int","ReturnInt","int",5)
MsgBox(0,"Should be 5",$ret[0])
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
Link to comment
Share on other sites

I use this to compile a DLL:

gcc -c MyDll.c
gcc -shared -o MyDll.dll MyDll.o -Wl,--out-implib,libmessage.a
Hi Ejoc,

And thanks for this answer.

I tried exactly your Dll.c and the two gcc line, creating a MyDll.dll (and a libmessage.a ?)

The result of a DllCall (or DllOpen) remains the same: freeze...

I suppose my cygwin gcc is somehow incorrect...

C:\>which gcc

/usr/bin/gcc

C:\>gcc --version

gcc (GCC) 3.3.3 (cygwin special)

-- VonCMinefield

Link to comment
Share on other sites

Can you at least show the AutoIt lines you are using to call the functions or are you using all 3 examples I posted? Otherwise I guess it's your compiler, I use either MingGW by it's self or I use Dev-C++ when I work on AutoIt source.

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
Link to comment
Share on other sites

Can you at least show the AutoIt lines you are using to call the functions or are you using all 3 examples I posted?  Otherwise I guess it's your compiler, I use either MingGW by it's self or I use Dev-C++ when I work on AutoIt source.

<{POST_SNAPBACK}>

Well... the Autoit line is precisely the one you use in your example.

$ret = DllCall("MyDll.dll","int","ReturnInt","int",5)

MsgBox(0,"Should be 5",$ret[0])

The MsgBox never displays, because the Autoit script freezes in the DllCall Step.

I will try with a standalone installation of MingGW instead of a gcc included in a cygwin distribution

Anyway, thank you for your inputs and advices :(

-- VonCMinefield

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...